File tree Expand file tree Collapse file tree 3 files changed +31
-4
lines changed
Expand file tree Collapse file tree 3 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -1130,8 +1130,10 @@ static int dfs_on_ref(const struct reference *ref, void *cb_data)
11301130 return 0 ;
11311131
11321132 commit = lookup_commit (the_repository , maybe_peeled );
1133- if (!commit )
1133+ if (!commit || commit -> object . flags & SEEN )
11341134 return 0 ;
1135+ commit -> object .flags |= SEEN ;
1136+
11351137 if (repo_parse_commit (the_repository , commit ) ||
11361138 commit_graph_position (commit ) != COMMIT_NOT_FROM_GRAPH )
11371139 return 0 ;
@@ -1141,7 +1143,7 @@ static int dfs_on_ref(const struct reference *ref, void *cb_data)
11411143 if (data -> num_not_in_graph >= data -> limit )
11421144 return 1 ;
11431145
1144- commit_list_append (commit , & stack );
1146+ commit_list_insert (commit , & stack );
11451147
11461148 while (!result && stack ) {
11471149 struct commit_list * parent ;
@@ -1162,7 +1164,7 @@ static int dfs_on_ref(const struct reference *ref, void *cb_data)
11621164 break ;
11631165 }
11641166
1165- commit_list_append (parent -> item , & stack );
1167+ commit_list_insert (parent -> item , & stack );
11661168 }
11671169 }
11681170
Original file line number Diff line number Diff line change @@ -1117,13 +1117,13 @@ void odb_free(struct object_database *o)
11171117 oidmap_clear (& o -> replace_map , 1 );
11181118 pthread_mutex_destroy (& o -> replace_mutex );
11191119
1120+ odb_close (o );
11201121 odb_free_sources (o );
11211122
11221123 for (size_t i = 0 ; i < o -> cached_object_nr ; i ++ )
11231124 free ((char * ) o -> cached_objects [i ].value .buf );
11241125 free (o -> cached_objects );
11251126
1126- odb_close (o );
11271127 packfile_store_free (o -> packfiles );
11281128 string_list_clear (& o -> submodule_source_paths , 0 );
11291129
Original file line number Diff line number Diff line change @@ -206,6 +206,31 @@ test_expect_success 'commit-graph auto condition' '
206206 test_subcommand $COMMIT_GRAPH_WRITE <cg-two-satisfied.txt
207207'
208208
209+ test_expect_success ' commit-graph auto condition with merges' '
210+ test_when_finished "rm -rf repo" &&
211+ git init repo &&
212+ (
213+ cd repo &&
214+ git config set maintenance.auto false &&
215+ test_commit initial &&
216+ git switch --create feature &&
217+ test_commit feature-1 &&
218+ test_commit feature-2 &&
219+ git switch - &&
220+ test_commit main-1 &&
221+ test_commit main-2 &&
222+ git merge feature &&
223+
224+ # We have 6 commits, none of which are covered by a commit
225+ # graph. So this must be the boundary at which we start to
226+ # perform maintenance.
227+ test_must_fail git -c maintenance.commit-graph.auto=7 \
228+ maintenance is-needed --auto --task=commit-graph &&
229+ git -c maintenance.commit-graph.auto=6 \
230+ maintenance is-needed --auto --task=commit-graph
231+ )
232+ '
233+
209234test_expect_success ' run --task=bogus' '
210235 test_must_fail git maintenance run --task=bogus 2>err &&
211236 test_grep "is not a valid task" err
You can’t perform that action at this time.
0 commit comments