Skip to content

Git designed for AI agents.

land: review fixes for the fixed-process range decision

Federico Elia285a1ca9c8ce
diff --git a/doc/graft/LAND-BATCHING.md b/doc/graft/LAND-BATCHING.md
index ab13e09..bbce348 100644
--- a/doc/graft/LAND-BATCHING.md
+++ b/doc/graft/LAND-BATCHING.md
@@ -88,7 +88,8 @@ outcomes.
### How a request is decided and rebased
Since phase 4b ([PLAN8.md](PLAN8.md)), each request of an attempt costs one
-short git process, and one more when it diverges from the tip:
+short git process, one more when it diverges from the tip, and at most four in
+all when committer dates are skewed:
1. The commit ID is peeled to a commit by an object info process of the
attempt's quarantine (`git cat-file --batch-check`), taken from the catfile
@@ -96,17 +97,20 @@ short git process, and one more when it diverges from the tip:
and at most the next one.
2. One listing of the commits that the change adds to the running tip
(`ancestry.Checker.List`, `git rev-list --parents commit ^tip`) decides the
- landing (`rebase.Plan`): the change is already landed when the list is
- empty; it fast-forwards the tip when the tip is a parent of a listed commit;
- otherwise it diverges. Both facts are exact even when committer dates are
- skewed. A skewed history can make `git rev-list` list commits that the tip
+ landing (`rebase.Plan`): an empty list means the change is already landed;
+ the tip being a parent of a listed commit means a fast-forward; both facts
+ hold even when committer dates are skewed. Otherwise the change diverges, or,
+ under skew, may still turn out to be already landed (see below). A skewed
+ history can make `git rev-list` list commits that the tip
already has (its walk stops early when the commits it still has to visit are
older than those it listed), never fewer. So for a diverging change one
`git merge-base --independent tip <bottoms>` tells whether the listing is
exact: it drops exactly the bottoms of the listing (listed commits none of
whose parents is listed) that the tip reaches, and the listing has extra
commits exactly when one of them is dropped. Without skew that is the only
- extra process. With skew (counted by `graft_revrange_skewed_listings_total`)
+ extra process. With skew (counted by `graft_revrange_skewed_listings_total`;
+ the commits removed from listings of the repository rebase todo are counted
+ by `graft_revrange_skew_extra_commits_total`)
`git merge-base --all` decides: the change is already landed when its only
merge base is the commit itself; otherwise one listing below the merge
bases either is a chain of commits with one parent each down to the only
diff --git a/internal/graft/ancestry/ancestry.go b/internal/graft/ancestry/ancestry.go
index c00b76f..0856b04 100644
--- a/internal/graft/ancestry/ancestry.go
+++ b/internal/graft/ancestry/ancestry.go
@@ -155,7 +155,6 @@ func (c graphChecker) List(ctx context.Context, head git.ObjectID, exclude []git
w := graphWalk{
checker: c,
flags: map[git.ObjectID]uint8{},
- queued: map[git.ObjectID]bool{},
taken: map[git.ObjectID]bool{},
}
@@ -175,7 +174,6 @@ func (c graphChecker) List(ctx context.Context, head git.ObjectID, exclude []git
if flags == fromHead {
w.headOnly--
}
- delete(w.queued, next.id)
w.taken[next.id] = true
parents, err := c.source.Parents(ctx, next.id)
@@ -233,8 +231,6 @@ type graphWalk struct {
flags map[git.ObjectID]uint8
// queue holds the commits that the walk reached and did not take yet.
queue generationQueue
- // queued holds the commits of queue.
- queued map[git.ObjectID]bool
// taken holds the commits that the walk took from queue.
taken map[git.ObjectID]bool
// headOnly counts the commits of queue whose flags are fromHead alone.
@@ -267,7 +263,6 @@ func (w *graphWalk) add(ctx context.Context, id git.ObjectID, flags uint8) error
}
w.flags[id] = flags
- w.queued[id] = true
if flags == fromHead {
w.headOnly++
}
diff --git a/internal/graft/rebase/plan.go b/internal/graft/rebase/plan.go
index 6fcccab..bfdf730 100644
--- a/internal/graft/rebase/plan.go
+++ b/internal/graft/rebase/plan.go
@@ -56,7 +56,8 @@ type LandPlan struct {
// reaches when committer dates are skewed, never fewer than the range (see revrange). Two facts
// are exact from such a listing, so they cost nothing more:
//
-// - The listing is empty exactly when the range is: commit is already landed.
+// - An empty listing means an empty range: commit is already landed. Not conversely: with skew
+// an already landed commit can have a non-empty listing, and the merge bases below settle it.
// - tip is a parent of a listed commit exactly when tip is reachable from commit. A listed commit
// is reachable from commit, so tip is then reachable from commit; and on a path from commit down
// to tip, the commit right above tip is in the range, so it is listed. That is a fast-forward.
diff --git a/internal/graft/rebase/plan_skew_test.go b/internal/graft/rebase/plan_skew_test.go
index 38a6711..bd64c9d 100644
--- a/internal/graft/rebase/plan_skew_test.go
+++ b/internal/graft/rebase/plan_skew_test.go
@@ -211,7 +211,10 @@ func TestPlanOfAMergeOfTheTipIntoTheChange(t *testing.T) {
_, err = plan.Replay()
require.ErrorIs(t, err, ErrMergesInRange)
- require.LessOrEqual(t, checker.processes(), 4)
+ // The skew path must run: the plain listing alone already refuses this merge, so only the
+ // exact counts show that the skew handling (one merge-base, one listing below it) was taken.
+ require.Equal(t, 4, checker.processes())
+ require.Equal(t, 1, checker.mergeBases)
require.Zero(t, checker.reachables)
require.Less(t, elapsed, 10*time.Second)
t.Logf("%d listed below the merge base by git rev-list; %d processes, %v", len(relisted), checker.processes(), elapsed)