Do not quote SP.
[gitweb.git] / clone-pack.c
index 9567900aab1ce477a2c748cf1ce3d47c169b9c78..f9b263a441eb2559a904e3db9fb35fac05b9590e 100644 (file)
@@ -5,7 +5,8 @@
 
 static int quiet;
 static int keep_pack;
-static const char clone_pack_usage[] = "git-clone-pack [-q] [--exec=<git-upload-pack>] [<host>:]<directory> [<heads>]*";
+static const char clone_pack_usage[] =
+"git-clone-pack [-q] [--keep] [--exec=<git-upload-pack>] [<host>:]<directory> [<heads>]*";
 static const char *exec = "git-upload-pack";
 
 static void clone_handshake(int fd[2], struct ref *ref)
@@ -35,6 +36,12 @@ static void write_one_ref(struct ref *ref)
        int fd;
        char *hex;
 
+       if (!strncmp(ref->name, "refs/", 5) &&
+           check_ref_format(ref->name + 5)) {
+               error("refusing to create funny ref '%s' locally", ref->name);
+               return;
+       }
+
        if (safe_create_leading_directories(path))
                die("unable to create leading directory for %s", ref->name);
        fd = open(path, O_CREAT | O_EXCL | O_WRONLY, 0666);
@@ -221,9 +228,11 @@ static int finish_pack(const char *pack_tmp_name)
        snprintf(final, sizeof(final),
                 "%s/pack/pack-%s.pack", get_object_directory(), hash);
        move_temp_to_file(pack_tmp_name, final);
+       chmod(final, 0444);
        snprintf(final, sizeof(final),
                 "%s/pack/pack-%s.idx", get_object_directory(), hash);
        move_temp_to_file(idx, final);
+       chmod(final, 0444);
        return 0;
 
  error_die:
@@ -278,7 +287,7 @@ static int clone_pack(int fd[2], int nr_match, char **match)
        struct ref *refs;
        int status;
 
-       get_remote_heads(fd[0], &refs, nr_match, match);
+       get_remote_heads(fd[0], &refs, nr_match, match, 1);
        if (!refs) {
                packet_flush(fd[1]);
                die("no matching remote head");