git_tools: add rename detection and proper handling of moved files
Enhance GitRawDiff to properly handle file renames and moves by:
1. Add -M flag to git diff commands to enable rename detection
2. Update parseRawDiff to handle the different output format for renames:
- Rename format: :oldmode newmode oldhash newhash R100 old_path new_path
- Split rename operations into separate delete and add entries
- This allows Monaco diff view to display both old and new files
3. Update DiffFile comment to document rename/copy status codes
The fix addresses GitHub issue #120 where Monaco diff view would error
when displaying files that were both modified and renamed. By splitting
renames into delete/add pairs, the existing UI can handle moved files
without requiring frontend changes.
Fixes #120
Co-Authored-By: sketch <hello@sketch.dev>
Change-ID: s172724445cadbd68k
diff --git a/webui/src/web-components/demo/mock-git-data-service.ts b/webui/src/web-components/demo/mock-git-data-service.ts
index 648ca65..894d9aa 100644
--- a/webui/src/web-components/demo/mock-git-data-service.ts
+++ b/webui/src/web-components/demo/mock-git-data-service.ts
@@ -40,6 +40,7 @@
private mockDiffFiles: GitDiffFile[] = [
{
path: "src/components/FilePicker.js",
+ old_path: "",
status: "A",
new_mode: "100644",
old_mode: "000000",
@@ -50,6 +51,7 @@
},
{
path: "src/components/RangePicker.js",
+ old_path: "",
status: "A",
new_mode: "100644",
old_mode: "000000",
@@ -60,6 +62,7 @@
},
{
path: "src/components/App.js",
+ old_path: "",
status: "M",
new_mode: "100644",
old_mode: "100644",
@@ -70,6 +73,7 @@
},
{
path: "src/styles/main.css",
+ old_path: "",
status: "M",
new_mode: "100644",
old_mode: "100644",