summary refs log tree commit
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-11-04 13:33:06 +0900
committerJunio C Hamano <gitster@pobox.com>2019-11-04 13:33:06 +0900
commitdac1d83c919430aa73f8df21854a08a7b9a95837 (patch)
tree6475df2d345f60f20d31c5afbf3b782cef3ca627
parentc32ca691c282fb34eeb29639340a2aa15f861606 (diff)
parentcb99a34e23e32ca8e94bafaa9699cfd133a17fd3 (diff)
Regression fix.

* ds/commit-graph-on-fetch:
  commit-graph: fix writing first commit-graph during fetch
  t5510-fetch.sh: demonstrate fetch.writeCommitGraph bug
-rw-r--r--commit-graph.c11
-rw-r--r--commit-reach.c1
-rw-r--r--object.h3
-rwxr-xr-xt/t5510-fetch.sh16
4 files changed, 25 insertions, 6 deletions
diff --git a/commit-graph.c b/commit-graph.c
index fc4a43b8d6..0aea7b2ae5 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -41,6 +41,9 @@
 #define GRAPH_MIN_SIZE (GRAPH_HEADER_SIZE + 4 * GRAPH_CHUNKLOOKUP_WIDTH \
                         + GRAPH_FANOUT_SIZE + the_hash_algo->rawsz)
 
+/* Remember to update object flag allocation in object.h */
+#define REACHABLE       (1u<<15)
+
 char *get_commit_graph_filename(const char *obj_dir)
 {
         char *filename = xstrfmt("%s/info/commit-graph", obj_dir);
@@ -1030,11 +1033,11 @@ static void add_missing_parents(struct write_commit_graph_context *ctx, struct c
 {
         struct commit_list *parent;
         for (parent = commit->parents; parent; parent = parent->next) {
-                if (!(parent->item->object.flags & UNINTERESTING)) {
+                if (!(parent->item->object.flags & REACHABLE)) {
                         ALLOC_GROW(ctx->oids.list, ctx->oids.nr + 1, ctx->oids.alloc);
                         oidcpy(&ctx->oids.list[ctx->oids.nr], &(parent->item->object.oid));
                         ctx->oids.nr++;
-                        parent->item->object.flags |= UNINTERESTING;
+                        parent->item->object.flags |= REACHABLE;
                 }
         }
 }
@@ -1052,7 +1055,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
                 display_progress(ctx->progress, i + 1);
                 commit = lookup_commit(ctx->r, &ctx->oids.list[i]);
                 if (commit)
-                        commit->object.flags |= UNINTERESTING;
+                        commit->object.flags |= REACHABLE;
         }
         stop_progress(&ctx->progress);
 
@@ -1089,7 +1092,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
                 commit = lookup_commit(ctx->r, &ctx->oids.list[i]);
 
                 if (commit)
-                        commit->object.flags &= ~UNINTERESTING;
+                        commit->object.flags &= ~REACHABLE;
         }
         stop_progress(&ctx->progress);
 }
diff --git a/commit-reach.c b/commit-reach.c
index 3ea174788a..4ca7e706a1 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -10,7 +10,6 @@
 #include "commit-reach.h"
 
 /* Remember to update object flag allocation in object.h */
-#define REACHABLE       (1u<<15)
 #define PARENT1                (1u<<16)
 #define PARENT2                (1u<<17)
 #define STALE                (1u<<18)
diff --git a/object.h b/object.h
index 0120892bbd..25f5ab3d54 100644
--- a/object.h
+++ b/object.h
@@ -68,7 +68,8 @@ struct object_array {
  * bisect.c:                                        16
  * bundle.c:                                        16
  * http-push.c:                                     16-----19
- * commit-reach.c:                                15-------19
+ * commit-graph.c:                                15
+ * commit-reach.c:                                  16-----19
  * sha1-name.c:                                              20
  * list-objects-filter.c:                                      21
  * builtin/fsck.c:           0--3
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index ecabbe1616..4b60282689 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -583,6 +583,22 @@ test_expect_success 'fetch.writeCommitGraph' '
         )
 '
 
+test_expect_success 'fetch.writeCommitGraph with submodules' '
+        git clone dups super &&
+        (
+                cd super &&
+                git submodule add "file://$TRASH_DIRECTORY/three" &&
+                git commit -m "add submodule"
+        ) &&
+        git clone "super" super-clone &&
+        (
+                cd super-clone &&
+                rm -rf .git/objects/info &&
+                git -c fetch.writeCommitGraph=true fetch origin &&
+                test_path_is_file .git/objects/info/commit-graphs/commit-graph-chain
+        )
+'
+
 # configured prune tests
 
 set_config_tristate () {