The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 23, 04:15 UTC
fix(shared): keep quoted Git file names intact (#19371)
Co-authored-by: Simone <185146821+Lucenx9@users.noreply.github.com>
Simone committed
Oct 18, 2026 at 21:15 UTC
51dcb43062e9582ddcd5f1ac77e524832d4f9dfa
3 files changed
+24
-1
packages/shared/src/gitPatchPath.test.ts
+8
@@ -34,6 +34,7 @@ describe("a name written into a header and read back out", () => {
34
"with space.txt",
35
"café/résumé.ts",
36
"🚀.ts",
37
+ "\uFEFFtab\tfile.txt",
38
"tab\tfile.txt",
39
"line\nfile.txt",
40
"carriage\rfile.txt",
@@ -62,6 +63,13 @@ describe("a name written into a header and read back out", () => {
63
});
64
65
describe("unquoteGitPatchPath", () => {
66
+ it.each(['"\\357\\273\\277note.txt"', "\\357\\273\\277note.txt"])(
67
+ "preserves an escaped U+FEFF at the start of a filename: %j",
68
+ (token) => {
69
+ expect(unquoteGitPatchPath(token)).toBe("\uFEFFnote.txt");
70
+ },
71
+ );
72
+
73
it("leaves a token git saw no need to quote alone", () => {
74
expect(unquoteGitPatchPath("src/app.ts")).toBe("src/app.ts");
75
expect(unquoteGitPatchPath("with space.txt")).toBe("with space.txt");
packages/shared/src/gitPatchPath.ts
+2
-1
@@ -28,7 +28,8 @@ const LOWEST_PRINTABLE = 0x20;
28
const BACKSLASH = 0x5c;
29
30
const utf8 = new TextEncoder();
31
-const fromUtf8 = new TextDecoder();
31
+// A leading U+FEFF is part of the filename, not an encoding marker.
32
+const fromUtf8 = new TextDecoder("utf-8", { ignoreBOM: true });
33
34
/**
35
* A header side's `a/` or `b/` belongs inside the quoting, so pass it in along with the name:
packages/source-control-core/src/server/diffFileRevisions.test.ts
+14
@@ -72,6 +72,20 @@ describe("parseDiffFileRevisions", () => {
72
assert.deepStrictEqual([...revisions], [["new.ts", "2222222"]]);
73
});
74
75
+ it("keeps a leading U+FEFF in a quoted rename's revision key", () => {
76
+ const revisions = parseDiffFileRevisions(
77
+ patchOf(
78
+ 'diff --git a/old.txt "b/\\357\\273\\277note.txt"',
79
+ "similarity index 100%",
80
+ "rename from old.txt",
81
+ 'rename to "\\357\\273\\277note.txt"',
82
+ "index 2222222..2222222 100644",
83
+ ),
84
+ );
85
+
86
+ assert.deepStrictEqual([...revisions], [["\uFEFFnote.txt", "2222222"]]);
87
+ });
88
+
89
it("leaves out a file Bitbucket excluded, which it gives no index line for", () => {
90
const revisions = parseDiffFileRevisions(
91
patchOf(