summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f360d84)
raw | patch | inline | side by side (parent: f360d84)
author | Jay Soffian <jaysoffian@gmail.com> | |
Tue, 10 Nov 2009 08:19:43 +0000 (09:19 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 10 Nov 2009 09:02:12 +0000 (01:02 -0800) |
Teach fetch --dry-run as users of "git remote prune" switching to "git fetch
--prune" may expect it. Unfortunately OPT__DRY_RUN() cannot be used as fetch
already uses "-n" for something else.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
--prune" may expect it. Unfortunately OPT__DRY_RUN() cannot be used as fetch
already uses "-n" for something else.
Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/fetch-options.txt | patch | blob | history | |
builtin-fetch.c | patch | blob | history |
index 500637a08b9f45a14052d0273d4a79c4e91fddbd..ab6419fe6e44c7008cbff4e1fae48a70cfb82ac0 100644 (file)
`git clone` with `--depth=<depth>` option (see linkgit:git-clone[1])
by the specified number of commits.
+ifndef::git-pull[]
+--dry-run::
+ Show what would be done, without making any changes.
+endif::git-pull[]
+
-f::
--force::
When 'git-fetch' is used with `<rbranch>:<lbranch>`
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 81974ea363c445700c856c10d565779c944282ce..76ec5eab48bd08eea4da32ca802e720cff35d5ba 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
TAGS_SET = 2
};
-static int all, append, force, keep, multiple, prune, update_head_ok, verbosity;
+static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity;
static int tags = TAGS_DEFAULT;
static const char *depth;
static const char *upload_pack;
"do not fetch all tags (--no-tags)", TAGS_UNSET),
OPT_BOOLEAN('p', "prune", &prune,
"prune tracking branches no longer on remote"),
+ OPT_BOOLEAN(0, "dry-run", &dry_run,
+ "dry run"),
OPT_BOOLEAN('k', "keep", &keep, "keep downloaded pack"),
OPT_BOOLEAN('u', "update-head-ok", &update_head_ok,
"allow updating of HEAD ref"),
char *rla = getenv("GIT_REFLOG_ACTION");
static struct ref_lock *lock;
+ if (dry_run)
+ return 0;
if (!rla)
rla = default_rla.buf;
snprintf(msg, sizeof(msg), "%s: %s", rla, action);
char note[1024];
const char *what, *kind;
struct ref *rm;
- char *url, *filename = git_path("FETCH_HEAD");
+ char *url, *filename = dry_run ? "/dev/null" : git_path("FETCH_HEAD");
fp = fopen(filename, "a");
if (!fp)
die("Don't know how to fetch from %s", transport->url);
/* if not appending, truncate FETCH_HEAD */
- if (!append) {
+ if (!append && !dry_run) {
char *filename = git_path("FETCH_HEAD");
FILE *fp = fopen(filename, "w");
if (!fp)
static int fetch_multiple(struct string_list *list)
{
int i, result = 0;
- const char *argv[] = { "fetch", NULL, NULL, NULL, NULL, NULL };
+ const char *argv[] = { "fetch", NULL, NULL, NULL, NULL, NULL, NULL };
int argc = 1;
+ if (dry_run)
+ argv[argc++] = "--dry-run";
if (prune)
argv[argc++] = "--prune";
if (verbosity >= 2)