Re: [PATCH] commit-reach: parse commits in the given repository
From: Kristofer Karlsson <hidden>
Date: 2026-09-16 14:55:46
On Wed, 16 Sept 2026 at 16:00, Orestis Floros [off-list ref] wrote:
+test_expect_success 'setup for commit-graphs in superproject and submodule' '
+ git init commit-graph &&
+ (cd commit-graph &&
+ git init sub &&
+ for i in 1 2 3 4 5 6 7 8 9 10
+ do
+ test_commit -C sub "sub-$i" || return 1
+ done &&
+
+ git -C sub checkout --detach sub-1 &&
+ git add sub &&
+ git commit -m base &&
+
+ # Write the commit-graph of the superproject while it only
+ # contains a single commit. Any commit-graph position of the
+ # submodule is thus out of bounds for the superproject.
+ git commit-graph write --reachable &&
+
+ git checkout -b side &&
+ git -C sub checkout --detach sub-5 &&
+ git add sub &&
+ git commit -m side &&
+
+ git checkout main &&
+ git -C sub checkout --detach sub-10 &&
+ git add sub &&
+ git commit -m main &&
+
+ git -C sub commit-graph write --reachable)
+'
+
+test_expect_success 'merge does not mix up superproject and submodule commit-graphs' '
+ (cd commit-graph &&
+ git merge side &&
+ git rev-parse HEAD:sub >actual &&
+ git -C sub rev-parse sub-10^{commit} >expect &&
+ test_cmp expect actual)
+'
+
test_doneI ran the new tests with and without the code change and can confirm it reproduces the bug. The code makes sense to me. As a bonus, this brings commit-reach.c down from 17 to 11 the_repository references, getting us slightly closer to eventually dropping USE_THE_REPOSITORY_VARIABLE there. - Kristofer