[PATCH] Open external merge tool with original file extensions in all three files

Subsystems: the rest

DORMANTno replies

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH] Open external merge tool with original file extensions in all three files

From: Pini Reznik <hidden>
Date: 2016-06-15 22:43:55

This required to be able to use syntax highlighting in meld during conflicts resolution.
Before this change, two merged versions of file with a conflict were open with temporal extensions .LOCAL.$$ and REMOTE.$$
This way they were not recognized as a code files.

Signed-off-by: Pini Reznik <redacted>
---
 git-mergetool.sh |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 5587c5e..4c15d22 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -152,10 +152,11 @@ merge_file () {
 	exit 1
     fi
 
-    BACKUP="$path.BACKUP.$$"
-    LOCAL="$path.LOCAL.$$"
-    REMOTE="$path.REMOTE.$$"
-    BASE="$path.BASE.$$"
+    extension=`echo $path | awk -F \. '{print $NF}'`
+    BACKUP="$path.BACKUP.$$.${extension}"
+    LOCAL="$path.LOCAL.$$.${extension}"
+    REMOTE="$path.REMOTE.$$.${extension}"
+    BASE="$path.BASE.$$.${extension}"
 
     mv -- "$path" "$BACKUP"
     cp -- "$BACKUP" "$path"
-- 
1.5.3.5

Re: [PATCH] Open external merge tool with original file extensions in all three files

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:43:55

Pini Reznik [off-list ref] writes:
This required to be able to use syntax highlighting in meld during
conflicts resolution....
+    extension=`echo $path | awk -F \. '{print $NF}'`
+    BACKUP="$path.BACKUP.$$.${extension}"
+    LOCAL="$path.LOCAL.$$.${extension}"
+    REMOTE="$path.REMOTE.$$.${extension}"
+    BASE="$path.BASE.$$.${extension}"
I had to wonder what would happen in these cases:

 * path = "a/b/c/d"
 * path = "a/b.c/d"

I also think spawning awk for this is way overkill.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help