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

3 messages from 2007-12-03 to 2007-12-03. Participants: Pini Reznik, Junio C Hamano.
Thread: https://gitlist.dev/t/11122

## Pini Reznik, 2007-12-03 15:31

Subject: [PATCH] Open external merge tool with original file extensions in all three files
Message-ID: <1196695874-22567-1-git-send-email-pinir@expand.com>
URL: https://gitlist.dev/e/1196695874-22567-1-git-send-email-pinir%40expand.com

```
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 <pinir@expand.com>
---
 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

```

## Junio C Hamano, 2007-12-03 18:17

Subject: Re: [PATCH] Open external merge tool with original file extensions in all three files
Message-ID: <7v63zfiqx8.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v63zfiqx8.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1196695874-22567-1-git-send-email-pinir@expand.com>

```
Pini Reznik <pinir@expand.com> 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.

```

## Junio C Hamano, 2007-12-03 21:28

Subject: Re: [PATCH] Open external merge tool with original file extensions in all three files
Message-ID: <7vlk8bh3iw.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vlk8bh3iw.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <7v63zfiqx8.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano <gitster@pobox.com> writes:

> Pini Reznik <pinir@expand.com> 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.

IOW, I would probably write the above like this:

	ext="$$$(expr "$path" : '.*\(\.[^/]*\)$')"
        BACKUP="$path.BACKUP.$ext"
        LOCAL="$path.LOCAL.$ext"
        REMOTE="$path.REMOTE.$ext"
        BASE="$path.BASE.$ext"

```
