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.mdindex 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 rebasedSince 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 theattempt'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 tipalready has (its walk stops early when the commits it still has to visit areolder than those it listed), never fewer. So for a diverging change one`git merge-base --independent tip <bottoms>` tells whether the listing isexact: it drops exactly the bottoms of the listing (listed commits none ofwhose parents is listed) that the tip reaches, and the listing has extracommits 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 onlymerge base is the commit itself; otherwise one listing below the mergebases either is a chain of commits with one parent each down to the onlydiff --git a/internal/graft/ancestry/ancestry.go b/internal/graft/ancestry/ancestry.goindex 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 []gitw := 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 []gitif flags == fromHead {w.headOnly--}- delete(w.queued, next.id)w.taken[next.id] = trueparents, 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] = trueif flags == fromHead {w.headOnly++}diff --git a/internal/graft/rebase/plan.go b/internal/graft/rebase/plan.goindex 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.goindex 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)