remote-curl: pass ref SHA-1 to fetch-pack as well
[gitweb.git] / builtin / fetch-pack.c
index aba44655524ff722d90de09760945f5f30088752..aa6e5967e7acefc4206867747104c6d7d4bdf7db 100644 (file)
@@ -1,6 +1,8 @@
 #include "builtin.h"
 #include "pkt-line.h"
 #include "fetch-pack.h"
+#include "remote.h"
+#include "connect.h"
 
 static const char fetch_pack_usage[] =
 "git fetch-pack [--all] [--stdin] [--quiet|-q] [--keep|-k] [--thin] "
@@ -11,6 +13,13 @@ static void add_sought_entry_mem(struct ref ***sought, int *nr, int *alloc,
                                 const char *name, int namelen)
 {
        struct ref *ref = xcalloc(1, sizeof(*ref) + namelen + 1);
+       unsigned char sha1[20];
+
+       if (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {
+               hashcpy(ref->old_sha1, sha1);
+               name += 41;
+               namelen -= 41;
+       }
 
        memcpy(ref->name, name, namelen);
        ref->name[namelen] = '\0';
@@ -100,6 +109,10 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
                        pack_lockfile_ptr = &pack_lockfile;
                        continue;
                }
+               if (!strcmp("--check-self-contained-and-connected", arg)) {
+                       args.check_self_contained_and_connected = 1;
+                       continue;
+               }
                usage(fetch_pack_usage);
        }
 
@@ -144,14 +157,19 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
                                   args.verbose ? CONNECT_VERBOSE : 0);
        }
 
-       get_remote_heads(fd[0], NULL, 0, &ref, 0, NULL);
+       get_remote_heads(fd[0], NULL, 0, &ref, 0, NULL, NULL);
 
        ref = fetch_pack(&args, fd, conn, ref, dest,
-                        sought, nr_sought, pack_lockfile_ptr);
+                        sought, nr_sought, NULL, pack_lockfile_ptr);
        if (pack_lockfile) {
                printf("lock %s\n", pack_lockfile);
                fflush(stdout);
        }
+       if (args.check_self_contained_and_connected &&
+           args.self_contained_and_connected) {
+               printf("connectivity-ok\n");
+               fflush(stdout);
+       }
        close(fd[0]);
        close(fd[1]);
        if (finish_connect(conn))