Merge branch 'jk/shallow-update-fix'
authorJunio C Hamano <gitster@pobox.com>
Fri, 21 Mar 2014 19:33:29 +0000 (12:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Mar 2014 19:33:29 +0000 (12:33 -0700)
Serving objects from a shallow repository needs to write a
new file to hold the temporary shallow boundaries but it was not
cleaned when we exit due to die() or a signal.

* jk/shallow-update-fix:
shallow: verify shallow file after taking lock
shallow: automatically clean up shallow tempfiles
shallow: use stat_validity to check for up-to-date file

1  2 
fetch-pack.c
upload-pack.c
diff --combined fetch-pack.c
index f061f1fe85ea20549f860c4bf37980941f480833,ae8550eb48ae1c96dff2fcd1e47333cee7bc79fd..90d47da8a902f24bb6a7ae63654a104626751b1e
@@@ -439,8 -439,7 +439,8 @@@ done
        }
        strbuf_release(&req_buf);
  
 -      consume_shallow_list(args, fd[0]);
 +      if (!got_ready || !no_done)
 +              consume_shallow_list(args, fd[0]);
        while (flushes || multi_ack) {
                int ack = get_ack(fd[0], result_sha1);
                if (ack) {
@@@ -948,17 -947,6 +948,6 @@@ static void update_shallow(struct fetch
        if (!si->shallow || !si->shallow->nr)
                return;
  
-       if (alternate_shallow_file) {
-               /*
-                * The temporary shallow file is only useful for
-                * index-pack and unpack-objects because it may
-                * contain more roots than we want. Delete it.
-                */
-               if (*alternate_shallow_file)
-                       unlink(alternate_shallow_file);
-               free((char *)alternate_shallow_file);
-       }
        if (args->cloning) {
                /*
                 * remote is shallow, but this is a clone, there are
diff --combined upload-pack.c
index 9314c250ffd72ef44dd6b675e0f3592e3e283a04,a3c52f691da5e5ce95d70a9ed43cffd00f620ccd..3a6f9f5b0d76ed080a2c47b903ae8e1e66aed00e
@@@ -81,7 -81,7 +81,7 @@@ static void create_pack_file(void
        const char *argv[12];
        int i, arg = 0;
        FILE *pipe_fd;
-       char *shallow_file = NULL;
+       const char *shallow_file = NULL;
  
        if (shallow_nr) {
                shallow_file = setup_temporary_shallow(NULL);
                error("git upload-pack: git-pack-objects died with error.");
                goto fail;
        }
-       if (shallow_file) {
-               if (*shallow_file)
-                       unlink(shallow_file);
-               free(shallow_file);
-       }
  
        /* flush the data */
        if (0 <= buffered) {
@@@ -796,7 -791,7 +791,7 @@@ int main(int argc, char **argv
  
        packet_trace_identity("upload-pack");
        git_extract_argv0_path(argv[0]);
 -      read_replace_refs = 0;
 +      check_replace_refs = 0;
  
        for (i = 1; i < argc; i++) {
                char *arg = argv[i];