archive: don't let remote clients get unreachable commits
[gitweb.git] / upload-pack.c
index bdbd67bc1d0198e54c8b6607d65ef98e72bde03f..b98b1d61c127de6368d24cc3c3b16a054724ed74 100644 (file)
@@ -11,7 +11,7 @@
 #include "list-objects.h"
 #include "run-command.h"
 
-static const char upload_pack_usage[] = "git-upload-pack [--strict] [--timeout=nn] <dir>";
+static const char upload_pack_usage[] = "git upload-pack [--strict] [--timeout=nn] <dir>";
 
 /* bits #0..7 in revision.h, #8..10 in commit.c */
 #define THEY_HAVE      (1u << 11)
@@ -78,11 +78,12 @@ static void show_commit(struct commit *commit)
        commit->buffer = NULL;
 }
 
-static void show_object(struct object *obj, const char *name)
+static void show_object(struct object *obj, const struct name_path *path, const char *component)
 {
        /* An object with name "foo\n0000000..." can be used to
         * confuse downstream git-pack-objects very badly.
         */
+       const char *name = path_name(path, component);
        const char *ep = strchr(name, '\n');
        if (ep) {
                fprintf(pack_pipe, "%s %.*s\n", sha1_to_hex(obj->sha1),
@@ -92,6 +93,7 @@ static void show_object(struct object *obj, const char *name)
        else
                fprintf(pack_pipe, "%s %s\n",
                                sha1_to_hex(obj->sha1), name);
+       free((char *)name);
 }
 
 static void show_edge(struct commit *commit)
@@ -616,6 +618,8 @@ int main(int argc, char **argv)
        int i;
        int strict = 0;
 
+       git_extract_argv0_path(argv[0]);
+
        for (i = 1; i < argc; i++) {
                char *arg = argv[i];