Repository navigation
fix(server): refuse unresolved UTF-16 merge commits #36817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
juliusmarminge
merged 6 commits into
pingdotgg:main
from
StiensWout:t3/reject-utf16-merge-markers
Nov 14, 2026
+119
−20
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
13fd274
fix(server): Commit refuses UTF-16 files that still have conflict mar…
StiensWout dfcf0fd
refactor(server): trim UTF-16 conflict refusal test and comment
StiensWout cdbd303
fix(server): allow resolved large encoded merge files
StiensWout c7fa686
chore(server): clarify conflict guard comments and test names
StiensWout a2fd930
Merge remote-tracking branch 'origin/main' into t3/reject-utf16-merge…
juliusmarminge 6a9fc2d
test(server): drop conflict-marker-size row unrelated to encoding
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
52 changes: 52 additions & 0 deletions
52
scripts/scenarios/utf16-merge-conflict-blocks-commit.e2e.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import { expect } from "e2e"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as FileSystem from "effect/FileSystem"; | ||
|
|
||
| import { run } from "./shell.ts"; | ||
| import { runPromise, test, WEB } from "./t3.ts"; | ||
|
|
||
| const utf16 = (text: string) => Buffer.from(`\ufeff${text}`, "utf16le"); | ||
|
|
||
| test( | ||
| "The commit dialog refuses a merge whose UTF-16 file still has conflict markers", | ||
| WEB, | ||
| async ({ t3, app, screen }) => { | ||
| const project = await t3.project("demo", { | ||
| ".gitattributes": "README.md text working-tree-encoding=UTF-16\n", | ||
| "README.md": utf16("base\n"), | ||
| }); | ||
| const git = (args: ReadonlyArray<string>, allowExit: ReadonlyArray<number> = [0]) => | ||
| runPromise( | ||
| run( | ||
| "git", | ||
| ["-c", "user.name=Scenario", "-c", "user.email=scenario@example.invalid", ...args], | ||
| { cwd: project, allowExit }, | ||
| ), | ||
| ); | ||
| const commitReadme = async (text: string) => { | ||
| await runPromise( | ||
| Effect.flatMap(FileSystem.FileSystem, (fs) => | ||
| fs.writeFile(`${project}/README.md`, utf16(text)), | ||
| ), | ||
| ); | ||
| await git(["commit", "--quiet", "--all", "--message", text.trim()]); | ||
| }; | ||
| await git(["checkout", "--quiet", "-b", "feature"]); | ||
| await commitReadme("feature version\n"); | ||
| await git(["checkout", "--quiet", "main"]); | ||
| await commitReadme("main version\n"); | ||
| await git(["merge", "--quiet", "feature"], [1]); | ||
| const thread = await t3.thread({ project, title: "Merge", messages: ["merge"] }); | ||
|
|
||
| await t3.open(thread); | ||
| await screen.getByRole("button", "Git action options").tap(); | ||
| await screen.getByRole("menuitem", "Commit").tap(); | ||
| await screen.getByPlaceholder("Leave empty to auto-generate").fill("Finish merge"); | ||
| await screen.getByRole("button", "Commit", { exact: true }).tap(); | ||
| // On a failed assertion e2e captures the committed merge itself. | ||
| await expect( | ||
| screen.getByText("unresolved merge conflicts in README.md", { exact: false }), | ||
| ).toBeVisible(); | ||
| await app.screenshot("refused"); | ||
| }, | ||
| ); | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove repository-location variables from the scenario's Git environment.
The scenario
githelper inherits the parent environment.runpasses noenvhere, and nothing inscripts/removesGIT_DIRorGIT_WORK_TREEbefore spawning Git. If these variables are set, for example by a Git hook that exportsGIT_DIR,cwd: projectdoes not limit the commands. The checkout, commit, and merge steps can then change another repository.Strip these variables from the environment passed to the helper, and keep the rest of
process.env:Suggested fix
const utf16 = (text: string) => Buffer.from(`\ufeff${text}`, "utf16le"); +const REPOSITORY_ENV = new Set(["GIT_DIR", "GIT_WORK_TREE", "GIT_INDEX_FILE", "GIT_OBJECT_DIRECTORY", "GIT_COMMON_DIR"]);const git = (args: ReadonlyArray<string>, allowExit: ReadonlyArray<number> = [0]) => runPromise( run( "git", ["-c", "user.name=Scenario", "-c", "user.email=scenario@example.invalid", ...args], - { cwd: project, allowExit }, + { + cwd: project, + allowExit, + env: Object.fromEntries( + Object.entries(process.env).filter(([key]) => !REPOSITORY_ENV.has(key)), + ), + }, ), );Source: Learnings