Objective
Fix two related bugs in actions/setup/js/push_signed_commits.cjs related to diff parsing.
Context
Reported in issue #26156. The push_signed_commits.cjs file has incorrect handling of file status parsing from git diff --name-status.
Bugs to Fix
1. Copy entries treated as renames (line 125-129)
Currently, when a file status starts with C (copy), the old file is added to deletions. This is wrong — a copy keeps the original file. Only renames (R) should delete the old path.
// WRONG: deletes old file for copies too
} else if (status.startsWith("R") || status.startsWith("C")) {
deletions.push({ path: parts[1] }); // ← should not happen for copies
Fix: Only add the old path to deletions when status starts with R, not C.
2. C-quoted (double-quoted) filenames not handled (lines 113-134)
git diff may C-quote filenames containing special characters (spaces, unicode, etc.) by surrounding them with double-quotes and escaping special characters. The code doesn't handle this.
Fix: Switch from git diff to git diff-tree (more stable, not affected by user git config), and add a helper to unescape C-quoted filenames (strip surrounding ", unescape \\n, \\t, \\\\, \\", octal sequences, etc.).
Files to Modify
actions/setup/js/push_signed_commits.cjs
Approach
- Replace
git diff --name-status ${sha}^ ${sha} with git diff-tree --no-commit-id -r --name-status ${sha}
- Add a
unquoteCPath(s) helper function to unescape C-quoted paths (strip leading/trailing ", unescape standard C escape sequences and octal codes)
- Apply
unquoteCPath to all filename parts before using them
- Change the copy/rename branch to only push to
deletions when status.startsWith("R")
Acceptance Criteria
Generated by Plan Command for issue #26156 · ● 383.5K · ◷
Objective
Fix two related bugs in
actions/setup/js/push_signed_commits.cjsrelated to diff parsing.Context
Reported in issue #26156. The
push_signed_commits.cjsfile has incorrect handling of file status parsing fromgit diff --name-status.Bugs to Fix
1. Copy entries treated as renames (line 125-129)
Currently, when a file status starts with
C(copy), the old file is added todeletions. This is wrong — a copy keeps the original file. Only renames (R) should delete the old path.Fix: Only add the old path to
deletionswhen status starts withR, notC.2. C-quoted (double-quoted) filenames not handled (lines 113-134)
git diffmay C-quote filenames containing special characters (spaces, unicode, etc.) by surrounding them with double-quotes and escaping special characters. The code doesn't handle this.Fix: Switch from
git difftogit diff-tree(more stable, not affected by user git config), and add a helper to unescape C-quoted filenames (strip surrounding", unescape\\n,\\t,\\\\,\\", octal sequences, etc.).Files to Modify
actions/setup/js/push_signed_commits.cjsApproach
git diff --name-status ${sha}^ ${sha}withgit diff-tree --no-commit-id -r --name-status ${sha}unquoteCPath(s)helper function to unescape C-quoted paths (strip leading/trailing", unescape standard C escape sequences and octal codes)unquoteCPathto all filename parts before using themdeletionswhenstatus.startsWith("R")Acceptance Criteria
git diff-treeis used instead ofgit diffRelated to bug: multiple critical issues in push_signed_commits #26156