Skip to content

Commit

Permalink
cmd_fetch_pack(): handle non-option arguments outside of the loop
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael Haggerty authored and Junio C Hamano committed May 22, 2012
1 parent 9d19c6e commit 4cc00fc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions builtin/fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4cc00fc

Please sign in to comment.