Conversation
rohankmr414
pushed a commit
to rohankmr414/go-git
that referenced
this pull request
Dec 18, 2022
…lones Revert "git: Add support for deepening shallow clones (go-git#311)"
blitzy Bot
pushed a commit
to blitzy-research/go-git
that referenced
this pull request
Jul 21, 2026
…handling Address all 13 code-review findings for the mainline working-tree merge capability (worktree_merge.go CREATE, worktree_commit.go UPDATE). worktree_merge.go — complete plan-then-apply rewrite (findings #1-go-git#11): - #1 Path safety: validate every planned path with existing validPath before any worktree/index mutation. - #2 Mode/symlink/CRLF: materialise blobs via mode/symlink-aware checkoutFile after a symlink-safe RemoveAll; write computed content with the resolved Git mode (no more blanket 0644 text writes). - go-git#3 Unrelated histories: diff against a canonical empty tree materialised in the object store, not a zero-value tree. - go-git#4 File-vs-directory: complete base/ours/theirs state matrix; one-sided file<->directory transitions apply cleanly (matching git), only genuine two-sided divergence conflicts. treeNode now resolves a path blocked by a non-directory ancestor to "absent" (disambiguating the legitimate ErrObjectNotFound from genuine missing-object corruption, which is still surfaced) via a component-by-component walk. - go-git#5 Add-add: an absent ancestor makes equal hashes the only clean case; every unequal addition (including empty-vs-non-empty) is forced into a stage-2/stage-3 conflict with both versions in markers. - go-git#6 Conflict markers: exact tokens; each marker always begins on its own line even when a side lacks a terminal newline. - go-git#7 Line merge: pure zero-width insertions at a gap are resolved before ranged regions so adjacent, non-overlapping edits no longer falsely conflict. - go-git#8 Atomicity: plan and validate the whole merge before mutating; write .git/MERGE_HEAD before rewriting the index. - go-git#9 Submodules: classified as their own leaf kind (never a directory); hashes/modes preserved through conflict/stage recording. - go-git#10 Identity fallback: fill only the identity fields configuration did not supply, preserving a configured committer/author. - go-git#11 Performance: filter the index in a single pass using conflict/ subtree-prefix maps. worktree_commit.go — MERGE_HEAD read (finding #1): - Guard the MERGE_HEAD read with a portable Stat(.git)+IsDir() check so an ordinary commit in a linked worktree (whose .git is a pointer file) is never mistaken for a failed merge-state read (fixes the ENOTDIR regression reproduced by x/plumbing/worktree.TestWorktreeIsolation). Parents remain exactly [HEAD, MERGE_HEAD] built on a local options copy; MERGE_HEAD is removed only after the commit is durable and HEAD advances. New sentinels ErrMergeConflicts and ErrUncommittedChanges are additive; no public symbols removed/renamed. go.mod/go.sum unchanged.
blitzy Bot
pushed a commit
to blitzy-research/go-git
that referenced
this pull request
Jul 21, 2026
Production fixes: - #1 worktree_commit.go: distinguish genuine .git Stat errors (permission/IO) from not-exist and linked-worktree (.git is a file) so MERGE_HEAD access failures are surfaced instead of silently degrading to a single-parent commit; build merge parents [HEAD, MERGE_HEAD] on a local opts copy to avoid retry corruption. - #2 worktree_merge.go: add mergeMode() to resolve filemode independently of content in the clean text-merge path, preserving an independent executable-bit change from the other side. - go-git#3 worktree_merge.go: gitlink-aware planning/apply (wtMkdirSubmodule, wtRemoveAll, idxDirectStage0, idxDirectRemove) so submodule take/update/delete and file<->submodule / dir<->submodule transitions use direct index rows and explicit worktree ops instead of blob/Tree.File APIs; remove stale children before creating a submodule dir. - go-git#4 worktree_merge.go: write .git/MERGE_HEAD as a preflight at the start of applyMergePlan (before any destructive worktree/index mutation) so a state-file write failure leaves the worktree and index untouched (no untracked half-merge). Test fidelity (worktree_merge_test.go): - go-git#5 replace lossy mergeTestStages with raw-entry assertions (exact row count/stage/hash/mode, no stage-0 on conflict, exactly one stage-0 on clean). - go-git#6 add Add-resolution coverage: content-conflict resolve to ancestor/ours/theirs and sparse stage sets {1,2}/{1,3}/{2,3}, including the changed doAddFile Worktree=Unmodified branch, each asserting a single stage-0 row with the resolved blob hash and mode. - go-git#7 fast-forward/up-to-date/dirty tests snapshot and compare every artifact (HEAD, object inventory, index, worktree, MERGE_HEAD-absence). - go-git#8 content-conflict test asserts HEAD stays at ours plus exact stage hashes/modes, marker block and MERGE_HEAD text. - go-git#9 rename TestThreeWayMerge -> TestWorktreeMergeThreeWayHelper so it is discovered by 'go test -run ^TestWorktreeMerge'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original created by @nulab at src-d/go-git#1153