summaryrefslogtreecommitdiff
path: root/builtin/fetch-pack.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2012-05-21 07:59:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-05-22 19:57:19 (GMT)
commit4cc00fcf5daf63648b7fd9382ca3e02033a0e1ec (patch)
tree0386e1cab40b41fedd741739ca7ed27cdca41aad /builtin/fetch-pack.c
parent9d19c6ea52755edec9b8e6d5b838b712fc7e97f6 (diff)
downloadgit-4cc00fcf5daf63648b7fd9382ca3e02033a0e1ec.zip
git-4cc00fcf5daf63648b7fd9382ca3e02033a0e1ec.tar.gz
git-4cc00fcf5daf63648b7fd9382ca3e02033a0e1ec.tar.bz2
cmd_fetch_pack(): handle non-option arguments outside of the loop
This makes it more obvious that the code is always executed unless there is an error, and that the first initialization of nr_heads is unnecessary. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch-pack.c')
-rw-r--r--builtin/fetch-pack.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 25c79ca..5c72226 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -909,7 +909,6 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
packet_trace_identity("fetch-pack");
- nr_heads = 0;
heads = NULL;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
@@ -971,14 +970,17 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
}
usage(fetch_pack_usage);
}
- dest = arg;
- heads = (char **)(argv + i + 1);
- nr_heads = argc - i - 1;
break;
}
- if (!dest)
+
+ if (i < argc)
+ dest = argv[i++];
+ else
usage(fetch_pack_usage);
+ heads = (char **)(argv + i);
+ nr_heads = argc - i;
+
if (args.stdin_refs) {
/*
* Copy refs from cmdline to new growable list, then