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>

Michael Haggerty committed May 21, 2012 at 09:59 UTC 4cc00fcf5daf63648b7fd9382ca3e02033a0e1ec
1 file changed +7 -5
builtin/fetch-pack.c
+7 -5
@@ -909,7 +909,6 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
909
910 packet_trace_identity("fetch-pack");
911
912 - nr_heads = 0;
912 heads = NULL;
913 for (i = 1; i < argc; i++) {
914 const char *arg = argv[i];
@@ -971,14 +970,17 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
970 }
971 usage(fetch_pack_usage);
972 }
974 - dest = arg;
975 - heads = (char **)(argv + i + 1);
976 - nr_heads = argc - i - 1;
973 break;
974 }
979 - if (!dest)
975 +
976 + if (i < argc)
977 + dest = argv[i++];
978 + else
979 usage(fetch_pack_usage);
980
981 + heads = (char **)(argv + i);
982 + nr_heads = argc - i;
983 +
984 if (args.stdin_refs) {
985 /*
986 * Copy refs from cmdline to new growable list, then