Git designed for AI agents.
Merge branch 'main' into c1-fixes
Federico Elia47dab7305b02
diff --cc doc/graft/LAND-BATCHING.mdindex 37d6e5e,5b2d4e6..86ee67a--- a/doc/graft/LAND-BATCHING.md+++ b/doc/graft/LAND-BATCHING.md@@@ -483,18 -494,17 +494,19 @@@ member) and removed it; see [PLAN8.md](an exponential backoff from 100 ms to 2 s with full jitter, stopped by thecontext, reported in `LandResult.UnavailableRetries`. A client that does notuse the SDK must do the same: retry `Unavailable`, and only `Unavailable`, with- a bounded backoff, and only for the lands below.- - Merge and fast-forward lands are retried by default. The response of a call- can be lost after the change landed; the change itself is then on the- branch, and the retry reports it as already landed.- - A land with a `Resolution` (the re-land of a conflict package) is a merge of- the tip and the change, whatever its strategy: it is retried by default- too, and the retry finds the change already landed.- - Rebase lands, with or without server-side conflict resolution, are not retried by- default (`RebaseLands` turns it on). The branch holds a rebased copy of the- change, and the server cannot yet tell that this change landed: a retry- replays it, and a change that a later commit reverted in between (for- example graft-verify reverting the culprit) would land again.+ a bounded backoff. Every strategy is retried by default+ (`UnavailableRetry.SkipRebaseLands` turns it off for rebase lands). The+ response of a call can be lost after the change landed, and the retry then+ lands nothing and reports `already_landed`: with a merge or a fast-forward,+ the change itself is on the branch; with a rebase, with or without conflict+ resolution, the branch holds a rebased copy, and the server answers from its+ record of the first land (the land identity of [PLAN11](PLAN11.md)), with+ `landed_commit_id` the copy and `landed_sequence` its changelog sequence.+ This holds also when a later commit reverted the change in between (for+ example graft-verify reverting the culprit): the change is not landed again,+ and `reverted_by_commit_id` names the revert.++ A land with a `resolution` (the re-land of a conflict package) is always a merge of the tip and the change, so++ `SkipRebaseLands` does not apply to it: the retry finds the change on the branch and reports `already_landed`.- A land that arrives alone waits up to `window` before its batch runs. Set`window = "0s"` to remove the wait, or `disabled = true` to remove batching.- Requests that do not qualify (see *When a land is batched*) run unbatched anddiff --cc internal/gitaly/service/operations/land_attempt.goindex ce3422f,481febf..6a2bbba--- a/internal/gitaly/service/operations/land_attempt.go+++ b/internal/gitaly/service/operations/land_attempt.go@@@ -197,26 -197,16 +197,36 @@@ func (a *landingAttempt) decide(ctx conreturn landStep{commit: commitID, tip: commitID}, nil}+ // commit_id is not on the branch, but an earlier land may have put it there as a rewritten+ // commit, whose response was lost. Its record answers, so the change is not landed twice.+ earlier, err := a.landedEarlier(ctx, req.reference(), tip, commitID)+ if err != nil {+ return landStep{}, err+ }+ if earlier != nil {+ return landStep{commit: commitID, tip: tip, alreadyLanded: true, earlier: earlier}, nil+ }++ // A resolution from the caller lands as a merge commit of the tip and the change, when it was+ // made against this tip; it replaces the server's attempt to merge or rebase.+ if in.GetResolution() != nil {+ res, err := a.server.landWithResolution(ctx, in, a.repo, tip, commitID, req.committer, req.precheck)+ if err != nil {+ var unresolved *landUnresolvedError+ if errors.As(err, &unresolved) {+ // The paths of UserLandError are bounded like the files of the package.+ files := unresolved.listing.files[:min(len(unresolved.listing.files), landMaxPackageFiles)]+ paths := make([][]byte, 0, len(files))+ for _, f := range files {+ paths = append(paths, []byte(f.conflict.path))+ }+ return landStep{}, landWithPackage(ctx, landMergeConflictError(tip, commitID, paths, err), err)+ }+ return landStep{}, err+ }+ return landStep{commit: commitID, tip: res.commit, rewritten: true, resolution: &res}, nil+ }+newTip, err := a.computeTip(ctx, in, plan, tip, commitID, req.committer)var resolution *landResolutionif err != nil {diff --cc internal/gitaly/service/operations/server.goindex 89fbbdb,84901c3..2b8c4a5--- a/internal/gitaly/service/operations/server.go+++ b/internal/gitaly/service/operations/server.go@@@ -113,10 -82,9 +116,11 @@@ func NewServer(deps *service.DependencilocalRepoFactory: deps.GetRepositoryFactory(),resolveCfg: resolveCfg,conflictResolver: conflictResolver,+ resolverErr: resolverErr,+ verifyPool: verifyPool,shutdownCtx: deps.GetShutdownContext(),storageSync: deps.GetGraftStorageSyncer(),+ graftStorage: deps.GetGraftStorage(),}// The lanes may run the batches with the server, so they are taken after it is created.diff --cc proto/go/gitalypb/operations.pb.goindex 3dff2b1,226b633..e20000a--- a/proto/go/gitalypb/operations.pb.go+++ b/proto/go/gitalypb/operations.pb.go@@@ -5099,764 -4922,20 +5099,807 @@@ func (x *LandConflictFile) GetHunks() [return nil}-type isUserLandError_Error interface {- isUserLandError_Error()+func (x *LandConflictFile) GetOutcome() LandConflictFile_Outcome {+ if x != nil {+ return x.Outcome+ }+ return LandConflictFile_OUTCOME_UNSPECIFIED}-type UserLandError_MergeConflict struct {- // merge_conflict is set if the change does not apply cleanly onto the- // current branch tip.- MergeConflict *MergeConflictError `protobuf:"bytes,1,opt,name=merge_conflict,json=mergeConflict,proto3,oneof"`+func (x *LandConflictFile) GetReason() string {+ if x != nil {+ return x.Reason+ }+ return ""}-type UserLandError_NotAncestor struct {- // not_ancestor is set if STRATEGY_FF_ONLY was requested and the branch- // tip is not an ancestor of commit_id.- NotAncestor *NotAncestorError `protobuf:"bytes,2,opt,name=not_ancestor,json=notAncestor,proto3,oneof"`+func (x *LandConflictFile) GetSyntaxUnchecked() bool {+ if x != nil {+ return x.SyntaxUnchecked+ }+ return false+}++func (x *LandConflictFile) GetHunksOmitted() string {+ if x != nil {+ return x.HunksOmitted+ }+ return ""+}++func (x *LandConflictFile) GetProposal() *LandConflictProposal {+ if x != nil {+ return x.Proposal+ }+ return nil+}++// LandConflictProposal is the resolver's resolution of one conflicting file.+type LandConflictProposal struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // action is "write" or "delete".+ Action string `protobuf:"bytes,1,opt,name=action,proto3" json:"action,omitempty"`+ // oid is the blob of the resolved content, for a write; it is kept in the+ // repository by LandConflict.proposal_ref.+ Oid string `protobuf:"bytes,2,opt,name=oid,proto3" json:"oid,omitempty"`+ // mode is the file mode of a write.+ Mode string `protobuf:"bytes,3,opt,name=mode,proto3" json:"mode,omitempty"`+ // resolver names what made it: the resolver and its strategies.+ Resolver string `protobuf:"bytes,4,opt,name=resolver,proto3" json:"resolver,omitempty"`+ // explanation is the resolver's explanation, cut to 512 bytes.+ Explanation string `protobuf:"bytes,5,opt,name=explanation,proto3" json:"explanation,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *LandConflictProposal) Reset() {+ *x = LandConflictProposal{}+ mi := &file_operations_proto_msgTypes[52]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *LandConflictProposal) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*LandConflictProposal) ProtoMessage() {}++func (x *LandConflictProposal) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[52]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use LandConflictProposal.ProtoReflect.Descriptor instead.+func (*LandConflictProposal) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{52}+}++func (x *LandConflictProposal) GetAction() string {+ if x != nil {+ return x.Action+ }+ return ""+}++func (x *LandConflictProposal) GetOid() string {+ if x != nil {+ return x.Oid+ }+ return ""+}++func (x *LandConflictProposal) GetMode() string {+ if x != nil {+ return x.Mode+ }+ return ""+}++func (x *LandConflictProposal) GetResolver() string {+ if x != nil {+ return x.Resolver+ }+ return ""+}++func (x *LandConflictProposal) GetExplanation() string {+ if x != nil {+ return x.Explanation+ }+ return ""+}++// LandConflictSide is one side of a conflicting file; its content is read by oid.+type LandConflictSide struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // oid is the object ID of the blob. It is set only for a blob in the tree of the+ // merge base, the tip or the landed commit, which the repository keeps. A side+ // that the merge wrote for this conflict alone (such as the content merge of a+ // rename) is not kept after the land fails, so it has no oid and unavailable says+ // why.+ Oid string `protobuf:"bytes,1,opt,name=oid,proto3" json:"oid,omitempty"`+ // mode is the file mode.+ Mode string `protobuf:"bytes,2,opt,name=mode,proto3" json:"mode,omitempty"`+ // unavailable is set instead of oid when the side's blob is not kept in the+ // repository: its content cannot be read.+ Unavailable string `protobuf:"bytes,3,opt,name=unavailable,proto3" json:"unavailable,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *LandConflictSide) Reset() {+ *x = LandConflictSide{}+ mi := &file_operations_proto_msgTypes[53]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *LandConflictSide) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*LandConflictSide) ProtoMessage() {}++func (x *LandConflictSide) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[53]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use LandConflictSide.ProtoReflect.Descriptor instead.+func (*LandConflictSide) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{53}+}++func (x *LandConflictSide) GetOid() string {+ if x != nil {+ return x.Oid+ }+ return ""+}++func (x *LandConflictSide) GetMode() string {+ if x != nil {+ return x.Mode+ }+ return ""+}++func (x *LandConflictSide) GetUnavailable() string {+ if x != nil {+ return x.Unavailable+ }+ return ""+}++// LandConflictMessage is a message of the merge about a conflict, as git+// merge-tree reports it. A conflict without a conflicting file (a directory rename+// split, say) is described by its message alone.+type LandConflictMessage struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // paths are the paths the message is about.+ Paths [][]byte `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"`+ // type is the kind of the conflict, such as "CONFLICT (rename/delete)".+ Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`+ // message is the message, cut to 512 bytes.+ Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *LandConflictMessage) Reset() {+ *x = LandConflictMessage{}+ mi := &file_operations_proto_msgTypes[54]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *LandConflictMessage) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*LandConflictMessage) ProtoMessage() {}++func (x *LandConflictMessage) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[54]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use LandConflictMessage.ProtoReflect.Descriptor instead.+func (*LandConflictMessage) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{54}+}++func (x *LandConflictMessage) GetPaths() [][]byte {+ if x != nil {+ return x.Paths+ }+ return nil+}++func (x *LandConflictMessage) GetType() string {+ if x != nil {+ return x.Type+ }+ return ""+}++func (x *LandConflictMessage) GetMessage() string {+ if x != nil {+ return x.Message+ }+ return ""+}++// LandConflictHunk is a conflicting region as line ranges of each side. Each range+// counts the lines of the side it names (base of the base side's file, ours of the+// tip's, theirs of the landed commit's), 1-based and half-open ([start, end)); an+// empty range (start == end) is an insertion point before line start.+type LandConflictHunk struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // base is the range in the base side.+ Base *LineRange `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"`+ // ours is the range in the tip's side.+ Ours *LineRange `protobuf:"bytes,2,opt,name=ours,proto3" json:"ours,omitempty"`+ // theirs is the range in the landed commit's side.+ Theirs *LineRange `protobuf:"bytes,3,opt,name=theirs,proto3" json:"theirs,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *LandConflictHunk) Reset() {+ *x = LandConflictHunk{}+ mi := &file_operations_proto_msgTypes[55]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *LandConflictHunk) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*LandConflictHunk) ProtoMessage() {}++func (x *LandConflictHunk) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[55]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use LandConflictHunk.ProtoReflect.Descriptor instead.+func (*LandConflictHunk) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{55}+}++func (x *LandConflictHunk) GetBase() *LineRange {+ if x != nil {+ return x.Base+ }+ return nil+}++func (x *LandConflictHunk) GetOurs() *LineRange {+ if x != nil {+ return x.Ours+ }+ return nil+}++func (x *LandConflictHunk) GetTheirs() *LineRange {+ if x != nil {+ return x.Theirs+ }+ return nil+}++// LineRange is a half-open range of 1-based lines.+type LineRange struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // start is the first line of the range.+ Start uint32 `protobuf:"varint,1,opt,name=start,proto3" json:"start,omitempty"`+ // end is the line after the last line of the range.+ End uint32 `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *LineRange) Reset() {+ *x = LineRange{}+ mi := &file_operations_proto_msgTypes[56]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *LineRange) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*LineRange) ProtoMessage() {}++func (x *LineRange) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[56]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use LineRange.ProtoReflect.Descriptor instead.+func (*LineRange) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{56}+}++func (x *LineRange) GetStart() uint32 {+ if x != nil {+ return x.Start+ }+ return 0+}++func (x *LineRange) GetEnd() uint32 {+ if x != nil {+ return x.End+ }+ return 0+}++// LandResolution is the caller's resolution of the conflicts of a LandConflict.+type LandResolution struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // tip is the tip that the resolution was made against, from LandConflict.tip.+ Tip string `protobuf:"bytes,1,opt,name=tip,proto3" json:"tip,omitempty"`+ // commit is the landed commit, LandConflict.commit; it must equal commit_id.+ Commit string `protobuf:"bytes,2,opt,name=commit,proto3" json:"commit,omitempty"`+ // files resolve every conflicting path exactly once.+ Files []*LandResolvedFile `protobuf:"bytes,3,rep,name=files,proto3" json:"files,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *LandResolution) Reset() {+ *x = LandResolution{}+ mi := &file_operations_proto_msgTypes[57]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *LandResolution) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*LandResolution) ProtoMessage() {}++func (x *LandResolution) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[57]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use LandResolution.ProtoReflect.Descriptor instead.+func (*LandResolution) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{57}+}++func (x *LandResolution) GetTip() string {+ if x != nil {+ return x.Tip+ }+ return ""+}++func (x *LandResolution) GetCommit() string {+ if x != nil {+ return x.Commit+ }+ return ""+}++func (x *LandResolution) GetFiles() []*LandResolvedFile {+ if x != nil {+ return x.Files+ }+ return nil+}++// LandResolvedFile resolves one conflicting path.+type LandResolvedFile struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // path is the path of the conflict.+ Path []byte `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`+ // action is what becomes of the path.+ Action LandResolvedFile_Action `protobuf:"varint,2,opt,name=action,proto3,enum=gitaly.LandResolvedFile_Action" json:"action,omitempty"`+ // mode is 100644, 100755 or 120000 for ACTION_WRITE.+ Mode string `protobuf:"bytes,3,opt,name=mode,proto3" json:"mode,omitempty"`+ // content is the file's content for ACTION_WRITE.+ Content []byte `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *LandResolvedFile) Reset() {+ *x = LandResolvedFile{}+ mi := &file_operations_proto_msgTypes[58]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *LandResolvedFile) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*LandResolvedFile) ProtoMessage() {}++func (x *LandResolvedFile) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[58]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use LandResolvedFile.ProtoReflect.Descriptor instead.+func (*LandResolvedFile) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{58}+}++func (x *LandResolvedFile) GetPath() []byte {+ if x != nil {+ return x.Path+ }+ return nil+}++func (x *LandResolvedFile) GetAction() LandResolvedFile_Action {+ if x != nil {+ return x.Action+ }+ return LandResolvedFile_ACTION_UNSPECIFIED+}++func (x *LandResolvedFile) GetMode() string {+ if x != nil {+ return x.Mode+ }+ return ""+}++func (x *LandResolvedFile) GetContent() []byte {+ if x != nil {+ return x.Content+ }+ return nil+}++// UserLandResponse is a response for the UserLand RPC.+type UserLandResponse struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // branch_update describes the branch update. Its commit_id is the commit+ // now at the branch tip.+ BranchUpdate *OperationBranchUpdate `protobuf:"bytes,1,opt,name=branch_update,json=branchUpdate,proto3" json:"branch_update,omitempty"`+ // landed_commit_id is the commit now at the branch tip: commit_id itself- // when fast-forwarded, otherwise the rebased or merge commit.++ // when fast-forwarded, otherwise the rebased or merge commit. When++ // already_landed comes from the record of an earlier land (landed_sequence++ // is set), it is the commit that land put on the branch, which holds the++ // change.+ LandedCommitId string `protobuf:"bytes,2,opt,name=landed_commit_id,json=landedCommitId,proto3" json:"landed_commit_id,omitempty"`+ // rewritten is true if the server rebased or merged.+ Rewritten bool `protobuf:"varint,3,opt,name=rewritten,proto3" json:"rewritten,omitempty"`+ // attempts is the number of compare-and-swap attempts used.+ Attempts int32 `protobuf:"varint,4,opt,name=attempts,proto3" json:"attempts,omitempty"`- // already_landed is true if commit_id was already reachable from the tip- // and the branch was left unchanged.++ // already_landed is true if the change is already on the branch and the++ // branch was left unchanged: commit_id is reachable from the tip, or an++ // earlier land of commit_id on this branch put a commit on it that is still++ // reachable from the tip (landed_sequence is then set). Such a change is not++ // landed again, also when a later commit reverted it: landing it again needs++ // a new commit.+ AlreadyLanded bool `protobuf:"varint,5,opt,name=already_landed,json=alreadyLanded,proto3" json:"already_landed,omitempty"`+ // old_tip is the branch tip that was replaced (zero OID if created).+ OldTip string `protobuf:"bytes,6,opt,name=old_tip,json=oldTip,proto3" json:"old_tip,omitempty"`+ // resolved_paths lists the files whose conflicts the server's resolver+ // resolved. Empty unless conflicts were resolved.+ ResolvedPaths [][]byte `protobuf:"bytes,7,rep,name=resolved_paths,json=resolvedPaths,proto3" json:"resolved_paths,omitempty"`+ // resolver identifies the resolver that produced the resolution (as reported+ // by the resolver, e.g. "graft-resolve/trivial" or+ // "graft-resolve/openai:llama3"). Empty unless conflicts were resolved.+ Resolver string `protobuf:"bytes,8,opt,name=resolver,proto3" json:"resolver,omitempty"`+ // batch_size is the number of requests in the landing batch this request+ // was part of (see [graft.land.batch]); 1 when it landed on its own.+ BatchSize int32 `protobuf:"varint,9,opt,name=batch_size,json=batchSize,proto3" json:"batch_size,omitempty"`+ // batch_position is the 1-based position of this request in its batch.+ BatchPosition int32 `protobuf:"varint,10,opt,name=batch_position,json=batchPosition,proto3" json:"batch_position,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache++ // landed_sequence is set when already_landed comes from the record of an++ // earlier land of commit_id on the branch: the changelog sequence of the++ // update that landed it as landed_commit_id. Zero otherwise.++ LandedSequence uint64 `protobuf:"varint,11,opt,name=landed_sequence,json=landedSequence,proto3" json:"landed_sequence,omitempty"`++ // reverted_by_commit_id is the commit on the branch, after++ // landed_commit_id, whose message says that it reverts landed_commit_id++ // ("This reverts commit <landed_commit_id>", as git revert and graft-verify++ // write it). It is looked for only when landed_sequence is set, and is++ // empty when no such commit is found.++ RevertedByCommitId string `protobuf:"bytes,12,opt,name=reverted_by_commit_id,json=revertedByCommitId,proto3" json:"reverted_by_commit_id,omitempty"`++ // already_landed_detail explains an already_landed answer that++ // landed_sequence is set for: "landed as <landed_commit_id> at changelog++ // <landed_sequence>", followed by "; it was reverted later by++ // <reverted_by_commit_id>" when that is set. Empty otherwise.++ AlreadyLandedDetail string `protobuf:"bytes,13,opt,name=already_landed_detail,json=alreadyLandedDetail,proto3" json:"already_landed_detail,omitempty"`++ unknownFields protoimpl.UnknownFields++ sizeCache protoimpl.SizeCache+}++func (x *UserLandResponse) Reset() {+ *x = UserLandResponse{}+ mi := &file_operations_proto_msgTypes[59]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *UserLandResponse) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UserLandResponse) ProtoMessage() {}++func (x *UserLandResponse) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[59]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use UserLandResponse.ProtoReflect.Descriptor instead.+func (*UserLandResponse) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{59}+}++func (x *UserLandResponse) GetBranchUpdate() *OperationBranchUpdate {+ if x != nil {+ return x.BranchUpdate+ }+ return nil+}++func (x *UserLandResponse) GetLandedCommitId() string {+ if x != nil {+ return x.LandedCommitId+ }+ return ""+}++func (x *UserLandResponse) GetRewritten() bool {+ if x != nil {+ return x.Rewritten+ }+ return false+}++func (x *UserLandResponse) GetAttempts() int32 {+ if x != nil {+ return x.Attempts+ }+ return 0+}++func (x *UserLandResponse) GetAlreadyLanded() bool {+ if x != nil {+ return x.AlreadyLanded+ }+ return false+}++func (x *UserLandResponse) GetOldTip() string {+ if x != nil {+ return x.OldTip+ }+ return ""+}++func (x *UserLandResponse) GetResolvedPaths() [][]byte {+ if x != nil {+ return x.ResolvedPaths+ }+ return nil+}++func (x *UserLandResponse) GetResolver() string {+ if x != nil {+ return x.Resolver+ }+ return ""+}++func (x *UserLandResponse) GetBatchSize() int32 {+ if x != nil {+ return x.BatchSize+ }+ return 0+}++func (x *UserLandResponse) GetBatchPosition() int32 {+ if x != nil {+ return x.BatchPosition+ }+ return 0+}+++func (x *UserLandResponse) GetLandedSequence() uint64 {++ if x != nil {++ return x.LandedSequence++ }++ return 0++}++++func (x *UserLandResponse) GetRevertedByCommitId() string {++ if x != nil {++ return x.RevertedByCommitId++ }++ return ""++}++++func (x *UserLandResponse) GetAlreadyLandedDetail() string {++ if x != nil {++ return x.AlreadyLandedDetail++ }++ return ""++}+++// UserLandError is an error returned by the UserLand RPC in some specific+// well defined error cases.+type UserLandError struct {+ state protoimpl.MessageState `protogen:"open.v1"`+ // Types that are valid to be assigned to Error:+ //+ // *UserLandError_MergeConflict+ // *UserLandError_NotAncestor+ // *UserLandError_ReferenceUpdate+ // *UserLandError_CustomHook+ // *UserLandError_AccessCheck+ Error isUserLandError_Error `protobuf_oneof:"error"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache+}++func (x *UserLandError) Reset() {+ *x = UserLandError{}+ mi := &file_operations_proto_msgTypes[60]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+}++func (x *UserLandError) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UserLandError) ProtoMessage() {}++func (x *UserLandError) ProtoReflect() protoreflect.Message {+ mi := &file_operations_proto_msgTypes[60]+ if x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use UserLandError.ProtoReflect.Descriptor instead.+func (*UserLandError) Descriptor() ([]byte, []int) {+ return file_operations_proto_rawDescGZIP(), []int{60}+}++func (x *UserLandError) GetError() isUserLandError_Error {+ if x != nil {+ return x.Error+ }+ return nil+}++func (x *UserLandError) GetMergeConflict() *MergeConflictError {+ if x != nil {+ if x, ok := x.Error.(*UserLandError_MergeConflict); ok {+ return x.MergeConflict+ }+ }+ return nil+}++func (x *UserLandError) GetNotAncestor() *NotAncestorError {+ if x != nil {+ if x, ok := x.Error.(*UserLandError_NotAncestor); ok {+ return x.NotAncestor+ }+ }+ return nil+}++func (x *UserLandError) GetReferenceUpdate() *ReferenceUpdateError {+ if x != nil {+ if x, ok := x.Error.(*UserLandError_ReferenceUpdate); ok {+ return x.ReferenceUpdate+ }+ }+ return nil+}++func (x *UserLandError) GetCustomHook() *CustomHookError {+ if x != nil {+ if x, ok := x.Error.(*UserLandError_CustomHook); ok {+ return x.CustomHook+ }+ }+ return nil+}++func (x *UserLandError) GetAccessCheck() *AccessCheckError {+ if x != nil {+ if x, ok := x.Error.(*UserLandError_AccessCheck); ok {+ return x.AccessCheck+ }+ }+ return nil+}++type isUserLandError_Error interface {+ isUserLandError_Error()+}++type UserLandError_MergeConflict struct {+ // merge_conflict is set if the change does not apply cleanly onto the+ // current branch tip.+ MergeConflict *MergeConflictError `protobuf:"bytes,1,opt,name=merge_conflict,json=mergeConflict,proto3,oneof"`+}++type UserLandError_NotAncestor struct {+ // not_ancestor is set if STRATEGY_FF_ONLY was requested and the branch+ // tip is not an ancestor of commit_id.+ NotAncestor *NotAncestorError `protobuf:"bytes,2,opt,name=not_ancestor,json=notAncestor,proto3,oneof"`}type UserLandError_ReferenceUpdate struct {@@@ -6482,82 -5558,7 +6525,82 @@@ const file_operations_proto_rawDesc = ""\bStrategy\x12\x1f\n" +"\x1bSTRATEGY_REBASE_UNSPECIFIED\x10\x00\x12\x12\n" +"\x0eSTRATEGY_MERGE\x10\x01\x12\x14\n" +- "\x10STRATEGY_FF_ONLY\x10\x02\"\x93\x04\n" ++ "\x10STRATEGY_FF_ONLY\x10\x02\"\xf2\x02\n" ++ "\fLandConflict\x12\x10\n" ++ "\x03tip\x18\x01 \x01(\tR\x03tip\x12\x16\n" ++ "\x06commit\x18\x02 \x01(\tR\x06commit\x12\x1d\n" ++ "\n" ++ "merge_base\x18\x03 \x01(\tR\tmergeBase\x12\x1f\n" ++ "\vtip_message\x18\x04 \x01(\fR\n" ++ "tipMessage\x12%\n" ++ "\x0ecommit_message\x18\x05 \x01(\fR\rcommitMessage\x12-\n" ++ "\x12messages_truncated\x18\x06 \x01(\bR\x11messagesTruncated\x12.\n" ++ "\x05files\x18\a \x03(\v2\x18.gitaly.LandConflictFileR\x05files\x12\x16\n" ++ "\x06reason\x18\b \x01(\tR\x06reason\x127\n" ++ "\bmessages\x18\t \x03(\v2\x1b.gitaly.LandConflictMessageR\bmessages\x12!\n" ++ "\fproposal_ref\x18\n" ++ " \x01(\tR\vproposalRef\"\x8a\x06\n" ++ "\x10LandConflictFile\x12\x12\n" ++ "\x04path\x18\x01 \x01(\fR\x04path\x121\n" ++ "\x04kind\x18\x02 \x01(\x0e2\x1d.gitaly.LandConflictFile.KindR\x04kind\x12,\n" ++ "\x04base\x18\x03 \x01(\v2\x18.gitaly.LandConflictSideR\x04base\x12,\n" ++ "\x04ours\x18\x04 \x01(\v2\x18.gitaly.LandConflictSideR\x04ours\x120\n" ++ "\x06theirs\x18\x05 \x01(\v2\x18.gitaly.LandConflictSideR\x06theirs\x12.\n" ++ "\x05hunks\x18\x06 \x03(\v2\x18.gitaly.LandConflictHunkR\x05hunks\x12:\n" ++ "\aoutcome\x18\a \x01(\x0e2 .gitaly.LandConflictFile.OutcomeR\aoutcome\x12\x16\n" ++ "\x06reason\x18\b \x01(\tR\x06reason\x12)\n" ++ "\x10syntax_unchecked\x18\t \x01(\bR\x0fsyntaxUnchecked\x12#\n" ++ "\rhunks_omitted\x18\n" ++ " \x01(\tR\fhunksOmitted\x128\n" ++ "\bproposal\x18\v \x01(\v2\x1c.gitaly.LandConflictProposalR\bproposal\"g\n" ++ "\x04Kind\x12\x14\n" ++ "\x10KIND_UNSPECIFIED\x10\x00\x12\x10\n" ++ "\fKIND_CONTENT\x10\x01\x12\x16\n" ++ "\x12KIND_MODIFY_DELETE\x10\x02\x12\x10\n" ++ "\fKIND_ADD_ADD\x10\x03\x12\r\n" ++ "\tKIND_MODE\x10\x04\"\xa9\x01\n" ++ "\aOutcome\x12\x17\n" ++ "\x13OUTCOME_UNSPECIFIED\x10\x00\x12\x14\n" ++ "\x10OUTCOME_NOT_SENT\x10\x01\x12\x14\n" ++ "\x10OUTCOME_REJECTED\x10\x02\x12\x12\n" ++ "\x0eOUTCOME_FAILED\x10\x03\x12\x14\n" ++ "\x10OUTCOME_RESOLVED\x10\x04\x12\x19\n" ++ "\x15OUTCOME_NOT_ATTEMPTED\x10\x05\x12\x14\n" ++ "\x10OUTCOME_PROPOSED\x10\x06\"\x92\x01\n" ++ "\x14LandConflictProposal\x12\x16\n" ++ "\x06action\x18\x01 \x01(\tR\x06action\x12\x10\n" ++ "\x03oid\x18\x02 \x01(\tR\x03oid\x12\x12\n" ++ "\x04mode\x18\x03 \x01(\tR\x04mode\x12\x1a\n" ++ "\bresolver\x18\x04 \x01(\tR\bresolver\x12 \n" ++ "\vexplanation\x18\x05 \x01(\tR\vexplanation\"Z\n" ++ "\x10LandConflictSide\x12\x10\n" ++ "\x03oid\x18\x01 \x01(\tR\x03oid\x12\x12\n" ++ "\x04mode\x18\x02 \x01(\tR\x04mode\x12 \n" ++ "\vunavailable\x18\x03 \x01(\tR\vunavailable\"Y\n" ++ "\x13LandConflictMessage\x12\x14\n" ++ "\x05paths\x18\x01 \x03(\fR\x05paths\x12\x12\n" ++ "\x04type\x18\x02 \x01(\tR\x04type\x12\x18\n" ++ "\amessage\x18\x03 \x01(\tR\amessage\"\x8b\x01\n" ++ "\x10LandConflictHunk\x12%\n" ++ "\x04base\x18\x01 \x01(\v2\x11.gitaly.LineRangeR\x04base\x12%\n" ++ "\x04ours\x18\x02 \x01(\v2\x11.gitaly.LineRangeR\x04ours\x12)\n" ++ "\x06theirs\x18\x03 \x01(\v2\x11.gitaly.LineRangeR\x06theirs\"3\n" ++ "\tLineRange\x12\x14\n" ++ "\x05start\x18\x01 \x01(\rR\x05start\x12\x10\n" ++ "\x03end\x18\x02 \x01(\rR\x03end\"j\n" ++ "\x0eLandResolution\x12\x10\n" ++ "\x03tip\x18\x01 \x01(\tR\x03tip\x12\x16\n" ++ "\x06commit\x18\x02 \x01(\tR\x06commit\x12.\n" ++ "\x05files\x18\x03 \x03(\v2\x18.gitaly.LandResolvedFileR\x05files\"\xd4\x01\n" ++ "\x10LandResolvedFile\x12\x12\n" ++ "\x04path\x18\x01 \x01(\fR\x04path\x127\n" ++ "\x06action\x18\x02 \x01(\x0e2\x1f.gitaly.LandResolvedFile.ActionR\x06action\x12\x12\n" ++ "\x04mode\x18\x03 \x01(\tR\x04mode\x12\x18\n" ++ "\acontent\x18\x04 \x01(\fR\acontent\"E\n" ++ "\x06Action\x12\x16\n" ++ "\x12ACTION_UNSPECIFIED\x10\x00\x12\x10\n" ++ "\fACTION_WRITE\x10\x01\x12\x11\n" +- "\rACTION_DELETE\x10\x02\"\x83\x03\n" +++ "\rACTION_DELETE\x10\x02\"\x93\x04\n" +"\x10UserLandResponse\x12B\n" +"\rbranch_update\x18\x01 \x01(\v2\x1d.gitaly.OperationBranchUpdateR\fbranchUpdate\x12(\n" +"\x10landed_commit_id\x18\x02 \x01(\tR\x0elandedCommitId\x12\x1c\n" +diff --cc sdk/land.goindex ab4583e,d949018..6e61220--- a/sdk/land.go+++ b/sdk/land.go@@@ -56,20 -56,10 +56,18 @@@ type LandOptions struct// configured conflict resolver (see doc/graft/RESOLVE.md). A resolved// landing is a merge commit of the branch tip and the change. If the// resolver is disabled, refuses a file or fails, the landing fails with a- // merge conflict as without this option.+ // merge conflict as without this option, and the error carries the+ // conflict package (see LandConflict).ResolveConflicts bool+ // Resolution lands Commit with the caller's resolution of the conflicts of+ // a conflict package (see LandConflict and ResolutionFor), as a merge+ // commit of the branch tip and the change. The server accepts it only when+ // it was made against the current tip and resolves exactly the conflicting+ // paths; otherwise Land fails with a fresh package. The request must fit in+ // MaxLandRequestBytes.+ Resolution *Resolution// RetryUnavailable is how Land retries a call that the server answers- // with Unavailable (see UnavailableRetry). It is on by default for- // LandMerge, LandFastForwardOnly and any land with a Resolution (a merge- // of the tip and the change, safe to retry), and off for LandRebase.+ // with Unavailable (see UnavailableRetry). It is on by default.RetryUnavailable UnavailableRetry}@@@ -157,13 -152,9 +160,13 @@@ func (r UnavailableRetry) backoff(n int}// maxRetries returns the retries of a land with the given strategy.-func (r UnavailableRetry) maxRetries(strategy LandStrategy) int {+//+// A land with a Resolution is always a merge of the tip and the change, whatever its strategy: after a+// lost response Commit is reachable from the tip, so the retry is reported as AlreadyLanded and nothing is- // replayed. It is retried like a merge land.++// replayed. SkipRebaseLands, which protects against the replay of a rebase, does not apply to it.+func (r UnavailableRetry) maxRetries(strategy LandStrategy, resolution bool) int {switch {- case r.Disabled, strategy == LandRebase && !resolution && !r.RebaseLands:- case r.Disabled, strategy == LandRebase && r.SkipRebaseLands:++ case r.Disabled, strategy == LandRebase && !resolution && r.SkipRebaseLands:return 0case r.MaxRetries > 0:return r.MaxRetriesdiff --cc sdk/land_retry_test.goindex 45f4852,5d35e48..ae77b0a--- a/sdk/land_retry_test.go+++ b/sdk/land_retry_test.go@@@ -55,40 -56,6 +56,42 @@@ func TestRepo_Land_RebaseLandsAreRetrie}}+// TestRepo_Land_ARelandWithAResolutionIsRetriedByDefault: a Resolution lands as a merge of the tip and the+// change, so a retry after a lost response finds Commit reachable and nothing is replayed: it is retried- // by default whatever the strategy, the rebase one included, and Disabled still turns the retries off.++// by default whatever the strategy, and SkipRebaseLands, which guards against the replay of a rebase, does++// not apply to it; Disabled still turns the retries off.+func TestRepo_Land_ARelandWithAResolutionIsRetriedByDefault(t *testing.T) {+ t.Parallel()++ for _, tc := range []struct {+ desc string+ strategy sdk.LandStrategy+ retry sdk.UnavailableRetry+ expectedRequests int+ }{+ {desc: "rebase strategy", strategy: sdk.LandRebase, retry: fastRetry, expectedRequests: 6},+ {desc: "merge strategy", strategy: sdk.LandMerge, retry: fastRetry, expectedRequests: 6},++ {desc: "skip rebase lands does not apply to a resolution", strategy: sdk.LandRebase, retry: sdk.UnavailableRetry{SkipRebaseLands: true, Base: time.Millisecond, Cap: 2 * time.Millisecond}, expectedRequests: 6},+ {desc: "disabled", strategy: sdk.LandRebase, retry: sdk.UnavailableRetry{Disabled: true}, expectedRequests: 1},+ } {+ t.Run(tc.desc, func(t *testing.T) {+ t.Parallel()++ fakes := newFakeServices()+ fakes.operations.landErr = status.Error(codes.Unavailable, "still syncing")+ repo := dialFake(t, fakes.register).Repo("repo")++ opts := validLand()+ opts.Strategy = tc.strategy+ opts.Resolution = &sdk.Resolution{Tip: "tip-sha", Commit: "change-sha", Files: []sdk.ResolvedFile{{Path: "a", Mode: "100644", Content: []byte("x\n")}}}+ opts.RetryUnavailable = tc.retry+ _, err := repo.Land(t.Context(), opts)+ require.Equal(t, codes.Unavailable, sdk.Code(err))+ require.Len(t, fakes.operations.landRequests, tc.expectedRequests)+ })+ }+}+func TestRepo_Land_RetriesUnavailable(t *testing.T) {t.Parallel()