cmd_fetch_pack(): handle non-option arguments outside of the loop
authorMichael Haggerty <mhagger@alum.mit.edu>
Mon, 21 May 2012 07:59:57 +0000 (09:59 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 May 2012 19:57:19 +0000 (12:57 -0700)
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>
builtin/fetch-pack.c

index 25c79ca8c4399b675c2f22a96b3128254640056f..5c72226c408c261f6e8532d51ce5ca583d610171 100644 (file)
@@ -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