Skip to content

Commit 44c1590

Browse files
authored
Merge pull request #2383 from derrickstolee/fetch-first-write-fail
Fix `fetch.writeCommitGraph` failure first fetch
2 parents 9356bff + 6d01e90 commit 44c1590

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

commit-graph.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
#define GRAPH_MIN_SIZE (GRAPH_HEADER_SIZE + 4 * GRAPH_CHUNKLOOKUP_WIDTH \
4242
+ GRAPH_FANOUT_SIZE + the_hash_algo->rawsz)
4343

44+
/* Remember to update object flag allocation in object.h */
45+
#define REACHABLE (1u<<15)
46+
4447
char *get_commit_graph_filename(const char *obj_dir)
4548
{
4649
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
10301033
{
10311034
struct commit_list *parent;
10321035
for (parent = commit->parents; parent; parent = parent->next) {
1033-
if (!(parent->item->object.flags & UNINTERESTING)) {
1036+
if (!(parent->item->object.flags & REACHABLE)) {
10341037
ALLOC_GROW(ctx->oids.list, ctx->oids.nr + 1, ctx->oids.alloc);
10351038
oidcpy(&ctx->oids.list[ctx->oids.nr], &(parent->item->object.oid));
10361039
ctx->oids.nr++;
1037-
parent->item->object.flags |= UNINTERESTING;
1040+
parent->item->object.flags |= REACHABLE;
10381041
}
10391042
}
10401043
}
@@ -1052,7 +1055,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
10521055
display_progress(ctx->progress, i + 1);
10531056
commit = lookup_commit(ctx->r, &ctx->oids.list[i]);
10541057
if (commit)
1055-
commit->object.flags |= UNINTERESTING;
1058+
commit->object.flags |= REACHABLE;
10561059
}
10571060
stop_progress(&ctx->progress);
10581061

@@ -1089,7 +1092,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
10891092
commit = lookup_commit(ctx->r, &ctx->oids.list[i]);
10901093

10911094
if (commit)
1092-
commit->object.flags &= ~UNINTERESTING;
1095+
commit->object.flags &= ~REACHABLE;
10931096
}
10941097
stop_progress(&ctx->progress);
10951098
}

commit-reach.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "commit-reach.h"
1111

1212
/* Remember to update object flag allocation in object.h */
13-
#define REACHABLE (1u<<15)
1413
#define PARENT1 (1u<<16)
1514
#define PARENT2 (1u<<17)
1615
#define STALE (1u<<18)

object.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ struct object_array {
6868
* bisect.c: 16
6969
* bundle.c: 16
7070
* http-push.c: 16-----19
71-
* commit-reach.c: 15-------19
71+
* commit-graph.c: 15
72+
* commit-reach.c: 16-----19
7273
* sha1-name.c: 20
7374
* list-objects-filter.c: 21
7475
* builtin/fsck.c: 0--3

t/t5510-fetch.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,22 @@ test_expect_success 'fetch.writeCommitGraph' '
583583
)
584584
'
585585

586+
test_expect_success 'fetch.writeCommitGraph with submodules' '
587+
git clone dups super &&
588+
(
589+
cd super &&
590+
git submodule add "file://$TRASH_DIRECTORY/three" &&
591+
git commit -m "add submodule"
592+
) &&
593+
git clone "super" super-clone &&
594+
(
595+
cd super-clone &&
596+
rm -rf .git/objects/info &&
597+
git -c fetch.writeCommitGraph=true fetch origin &&
598+
test_path_is_file .git/objects/info/commit-graphs/commit-graph-chain
599+
)
600+
'
601+
586602
# configured prune tests
587603

588604
set_config_tristate () {

0 commit comments

Comments
 (0)