receive-pack: don't copy "dir" parameter
authorJeff King <peff@peff.net>
Thu, 24 Jul 2014 04:40:43 +0000 (00:40 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 24 Jul 2014 20:57:49 +0000 (13:57 -0700)
We used to do this so could pass a mutable string to
enter_repo. But since 1c64b48 (enter_repo: do not modify
input, 2011-10-04), this is not necessary.

The resulting code is simpler, and it fixes a minor leak.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/receive-pack.c
index c3230817db4a7676eb74335b254f30597e66edd9..be8c2db26cde55df967d9a1ba6ea02ea08024ffc 100644 (file)
@@ -1125,7 +1125,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
        int advertise_refs = 0;
        int stateless_rpc = 0;
        int i;
-       char *dir = NULL;
+       const char *dir = NULL;
        struct command *commands;
        struct sha1_array shallow = SHA1_ARRAY_INIT;
        struct sha1_array ref = SHA1_ARRAY_INIT;
@@ -1160,7 +1160,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
                }
                if (dir)
                        usage(receive_pack_usage);
-               dir = xstrdup(arg);
+               dir = arg;
        }
        if (!dir)
                usage(receive_pack_usage);