All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v6 1/2] mergetool--lib: set IFS for difftool and mergetool
@ 2015-05-20  9:07 David Aguilar
  2015-05-20  9:07 ` [PATCH v6 2/2] mergetools: add winmerge as a builtin tool David Aguilar
  0 siblings, 1 reply; 11+ messages in thread
From: David Aguilar @ 2015-05-20  9:07 UTC (permalink / raw)
  To: Phil Susi, git
  Cc: Junio C Hamano, Philip Oakley, Johannes Schindelin,
	Sebastian Schuberth, SZEDER Gábor

git-sh-setup sets IFS but it is not used by git-difftool--helper.
Set IFS in git-mergetool--lib so that the mergetool scriptlets,
difftool, and mergetool do not need to do so.

Signed-off-by: David Aguilar <davvid@gmail.com>
---
Changes since v5: fixed "diftool" typo in commit message

 git-mergetool--lib.sh | 3 +++
 git-mergetool.sh      | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index fe61e89..14b039d 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -2,6 +2,9 @@
 
 : ${MERGE_TOOLS_DIR=$(git --exec-path)/mergetools}
 
+IFS='
+'
+
 mode_ok () {
 	if diff_mode
 	then
diff --git a/git-mergetool.sh b/git-mergetool.sh
index d20581c..9f77e3a 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -451,8 +451,6 @@ fi
 printf "Merging:\n"
 printf "%s\n" "$files"
 
-IFS='
-'
 rc=0
 for i in $files
 do
-- 
2.4.1.218.gc09a0e5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20  9:07 [PATCH v6 1/2] mergetool--lib: set IFS for difftool and mergetool David Aguilar
@ 2015-05-20  9:07 ` David Aguilar
  2015-05-20 11:09   ` SZEDER Gábor
  2015-05-20 20:13   ` Junio C Hamano
  0 siblings, 2 replies; 11+ messages in thread
From: David Aguilar @ 2015-05-20  9:07 UTC (permalink / raw)
  To: Phil Susi, git
  Cc: Junio C Hamano, Philip Oakley, Johannes Schindelin,
	Sebastian Schuberth, SZEDER Gábor

Add a winmerge scriptlet with the commands described in [1] so
that users can use winmerge without needing to perform any
additional configuration.

[1] http://thread.gmane.org/gmane.comp.version-control.git/268631

Helped-by: Philip Oakley <philipoakley@iee.org>
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Helped-by: Sebastian Schuberth <sschuberth@gmail.com>
Helped-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: David Aguilar <davvid@gmail.com>
---
Unchanged since v5.
Changes since v4: IFS is left as-is since it's done in 1/2

 mergetools/winmerge | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 mergetools/winmerge

diff --git a/mergetools/winmerge b/mergetools/winmerge
new file mode 100644
index 0000000..74a66d4
--- /dev/null
+++ b/mergetools/winmerge
@@ -0,0 +1,36 @@
+diff_cmd () {
+	"$merge_tool_path" -u -e "$LOCAL" "$REMOTE"
+	return 0
+}
+
+merge_cmd () {
+	# mergetool.winmerge.trustExitCode is implicitly false.
+	# touch $BACKUP so that we can check_unchanged.
+	touch "$BACKUP"
+	"$merge_tool_path" -u -e -dl Local -dr Remote \
+		"$LOCAL" "$REMOTE" "$MERGED"
+	check_unchanged
+}
+
+translate_merge_tool_path() {
+	# Use WinMergeU.exe if it exists in $PATH
+	if type -p WinMergeU.exe >/dev/null 2>&1
+	then
+		printf WinMergeU.exe
+		return
+	fi
+
+	# Look for WinMergeU.exe in the typical locations
+	winmerge_exe="WinMerge/WinMergeU.exe"
+	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
+		cut -d '=' -f 2- | sort -u)
+	do
+		if test -n "$directory" && test -x "$directory/$winmerge_exe"
+		then
+			printf '%s' "$directory/$winmerge_exe"
+			return
+		fi
+	done
+
+	printf WinMergeU.exe
+}
-- 
2.4.1.218.gc09a0e5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20  9:07 ` [PATCH v6 2/2] mergetools: add winmerge as a builtin tool David Aguilar
@ 2015-05-20 11:09   ` SZEDER Gábor
  2015-05-22 19:58     ` David Aguilar
  2015-05-20 20:13   ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: SZEDER Gábor @ 2015-05-20 11:09 UTC (permalink / raw)
  To: David Aguilar
  Cc: Phil Susi, git, Junio C Hamano, Philip Oakley,
	Johannes Schindelin, Sebastian Schuberth


Quoting David Aguilar <davvid@gmail.com>:

> +translate_merge_tool_path() {
> +	# Use WinMergeU.exe if it exists in $PATH
> +	if type -p WinMergeU.exe >/dev/null 2>&1
> +	then
> +		printf WinMergeU.exe
> +		return
> +	fi
> +
> +	# Look for WinMergeU.exe in the typical locations
> +	winmerge_exe="WinMerge/WinMergeU.exe"

This variable is not used elsewhere, right?  Then you might want to  
mark it as local to make this clear.

> +	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
> +		cut -d '=' -f 2- | sort -u)
> +	do
> +		if test -n "$directory" && test -x "$directory/$winmerge_exe"
> +		then
> +			printf '%s' "$directory/$winmerge_exe"
> +			return
> +		fi
> +	done
> +
> +	printf WinMergeU.exe

Please pardon my ignorance and curiosity, but what is the purpose of  
this last printf?
It outputs the same as in the case when winmerge is in $PATH at the  
beginning of the function.  However, if we reach this printf, then  
winmerge is not in $PATH, so what will be executed?


Gábor

> +}
> --
> 2.4.1.218.gc09a0e5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20  9:07 ` [PATCH v6 2/2] mergetools: add winmerge as a builtin tool David Aguilar
  2015-05-20 11:09   ` SZEDER Gábor
@ 2015-05-20 20:13   ` Junio C Hamano
  2015-05-20 20:20     ` Sebastian Schuberth
  1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2015-05-20 20:13 UTC (permalink / raw)
  To: David Aguilar
  Cc: Phil Susi, git, Philip Oakley, Johannes Schindelin,
	Sebastian Schuberth, SZEDER Gábor

David Aguilar <davvid@gmail.com> writes:

> +	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
> +		cut -d '=' -f 2- | sort -u)

Is the final "sort" really desired?  I am wondering if there are
fixed precedence/preference order among variants of %PROGRAMFILES% 
environment variables that the users on the platform are expected
to stick to, but the "sort" is sorting by the absolute pathnames of
where these things are, which may not reflect that order.

Not that I personally care too deeply, as I would expect that it is
likely any one of them found would just work fine ;-)

> +	do
> +		if test -n "$directory" && test -x "$directory/$winmerge_exe"
> +		then
> +			printf '%s' "$directory/$winmerge_exe"
> +			return
> +		fi
> +	done
> +
> +	printf WinMergeU.exe
> +}

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20 20:13   ` Junio C Hamano
@ 2015-05-20 20:20     ` Sebastian Schuberth
  2015-05-20 21:00       ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Sebastian Schuberth @ 2015-05-20 20:20 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: David Aguilar, Phil Susi, Git Mailing List, Philip Oakley,
	Johannes Schindelin, SZEDER Gábor

On Wed, May 20, 2015 at 10:13 PM, Junio C Hamano <gitster@pobox.com> wrote:

> David Aguilar <davvid@gmail.com> writes:
>
>> +     for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
>> +             cut -d '=' -f 2- | sort -u)
>
> Is the final "sort" really desired?  I am wondering if there are
> fixed precedence/preference order among variants of %PROGRAMFILES%
> environment variables that the users on the platform are expected
> to stick to, but the "sort" is sorting by the absolute pathnames of
> where these things are, which may not reflect that order.

I did add the sort (and -u) by intention, to ensure that "C:\Program
Files" (which is what %PROGRAMFILES% expands to by default) comes
before "C:\Program Files (x86)" (which is what %PROGRAMFILES(X86)%
expands to by default), so that programs of the OS-native bitness are
preferred.

-- 
Sebastian Schuberth

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20 20:20     ` Sebastian Schuberth
@ 2015-05-20 21:00       ` Junio C Hamano
  2015-05-20 21:20         ` Sebastian Schuberth
  2015-05-21 10:06         ` Johannes Schindelin
  0 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2015-05-20 21:00 UTC (permalink / raw)
  To: Sebastian Schuberth
  Cc: David Aguilar, Phil Susi, Git Mailing List, Philip Oakley,
	Johannes Schindelin, SZEDER Gábor

Sebastian Schuberth <sschuberth@gmail.com> writes:

> On Wed, May 20, 2015 at 10:13 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
>> David Aguilar <davvid@gmail.com> writes:
>>
>>> +     for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
>>> +             cut -d '=' -f 2- | sort -u)
>>
>> Is the final "sort" really desired?  I am wondering if there are
>> fixed precedence/preference order among variants of %PROGRAMFILES%
>> environment variables that the users on the platform are expected
>> to stick to, but the "sort" is sorting by the absolute pathnames of
>> where these things are, which may not reflect that order.
>
> I did add the sort (and -u) by intention, to ensure that "C:\Program
> Files" (which is what %PROGRAMFILES% expands to by default) comes
> before "C:\Program Files (x86)" (which is what %PROGRAMFILES(X86)%
> expands to by default), so that programs of the OS-native bitness are
> preferred.

Yuck.  So even though %PROGRAMFILES% and %PROGRAMFILES(X86)% look as
if they are variables that can point at arbitrary places, they in
reality don't?  Otherwise %PROGRAMFILES% may point at D:\Program
while %PROGRAMFILES(X86)% may piont at C:\X86 and the latter would
sort before the former, which would defeat that "logic".

But of course if I view this not as a "logic" but as a "heuristics"
that happens to do the right thing in common environments, it is
perfectly OK ;-).

I've queued the patches as-is.

Thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20 21:00       ` Junio C Hamano
@ 2015-05-20 21:20         ` Sebastian Schuberth
  2015-05-21 10:06         ` Johannes Schindelin
  1 sibling, 0 replies; 11+ messages in thread
From: Sebastian Schuberth @ 2015-05-20 21:20 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: David Aguilar, Phil Susi, Git Mailing List, Philip Oakley,
	Johannes Schindelin, SZEDER Gábor

On Wed, May 20, 2015 at 11:00 PM, Junio C Hamano <gitster@pobox.com> wrote:

> Yuck.  So even though %PROGRAMFILES% and %PROGRAMFILES(X86)% look as
> if they are variables that can point at arbitrary places, they in
> reality don't?  Otherwise %PROGRAMFILES% may point at D:\Program

Correct. In the vast majority of  WIndows installations these
variables contain the default values.

> But of course if I view this not as a "logic" but as a "heuristics"
> that happens to do the right thing in common environments, it is
> perfectly OK ;-).

Exactly a heuristic is what it's supposed to be :-)

-- 
Sebastian Schuberth

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20 21:00       ` Junio C Hamano
  2015-05-20 21:20         ` Sebastian Schuberth
@ 2015-05-21 10:06         ` Johannes Schindelin
  1 sibling, 0 replies; 11+ messages in thread
From: Johannes Schindelin @ 2015-05-21 10:06 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Sebastian Schuberth, David Aguilar, Phil Susi, Git Mailing List,
	Philip Oakley, SZEDER Gábor

Hi Junio,

On 2015-05-20 23:00, Junio C Hamano wrote:
> Sebastian Schuberth <sschuberth@gmail.com> writes:
> 
>> On Wed, May 20, 2015 at 10:13 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>
>>> David Aguilar <davvid@gmail.com> writes:
>>>
>>>> +     for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
>>>> +             cut -d '=' -f 2- | sort -u)
>>>
>>> Is the final "sort" really desired?  I am wondering if there are
>>> fixed precedence/preference order among variants of %PROGRAMFILES%
>>> environment variables that the users on the platform are expected
>>> to stick to, but the "sort" is sorting by the absolute pathnames of
>>> where these things are, which may not reflect that order.
>>
>> I did add the sort (and -u) by intention, to ensure that "C:\Program
>> Files" (which is what %PROGRAMFILES% expands to by default) comes
>> before "C:\Program Files (x86)" (which is what %PROGRAMFILES(X86)%
>> expands to by default), so that programs of the OS-native bitness are
>> preferred.
> 
> Yuck.  So even though %PROGRAMFILES% and %PROGRAMFILES(X86)% look as
> if they are variables that can point at arbitrary places, they in
> reality don't?  Otherwise %PROGRAMFILES% may point at D:\Program
> while %PROGRAMFILES(X86)% may piont at C:\X86 and the latter would
> sort before the former, which would defeat that "logic".

Well, you are correct, theoretically an administrator could set the registry values (which are the source of the environment variables in question) of the `ProgramFilesDir` key in both

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion

and

HKEY_LOCAL_MACHINE\Software\WOW64\Microsoft\Windows\CurrentVersion

to wildly different locations as you outlined. However, it is not supported by Microsoft to change those locations via the registry:

https://support.microsoft.com/en-us/kb/933700

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-20 11:09   ` SZEDER Gábor
@ 2015-05-22 19:58     ` David Aguilar
  2015-05-22 20:05       ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: David Aguilar @ 2015-05-22 19:58 UTC (permalink / raw)
  To: SZEDER Gábor
  Cc: Phil Susi, git, Junio C Hamano, Philip Oakley,
	Johannes Schindelin, Sebastian Schuberth


[just wrapping up the unaswered questions in this thread]

On Wed, May 20, 2015 at 01:09:29PM +0200, SZEDER Gábor wrote:
> 
> Quoting David Aguilar <davvid@gmail.com>:
> 
> >+translate_merge_tool_path() {
> >+	# Use WinMergeU.exe if it exists in $PATH
> >+	if type -p WinMergeU.exe >/dev/null 2>&1
> >+	then
> >+		printf WinMergeU.exe
> >+		return
> >+	fi
> >+
> >+	# Look for WinMergeU.exe in the typical locations
> >+	winmerge_exe="WinMerge/WinMergeU.exe"
> 
> This variable is not used elsewhere, right?  Then you might want to
> mark it as local to make this clear.


"local" is a bash-ism, otherwise that'd be a good idea.


> >+	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
> >+		cut -d '=' -f 2- | sort -u)
> >+	do
> >+		if test -n "$directory" && test -x "$directory/$winmerge_exe"
> >+		then
> >+			printf '%s' "$directory/$winmerge_exe"
> >+			return
> >+		fi
> >+	done
> >+
> >+	printf WinMergeU.exe
> 
> Please pardon my ignorance and curiosity, but what is the purpose of
> this last printf?
> It outputs the same as in the case when winmerge is in $PATH at the
> beginning of the function.  However, if we reach this printf, then
> winmerge is not in $PATH, so what will be executed?


This function maps what we call the tool (winmerge) to the actual executable.
That last printf provides the following behavior:

	$ git difftool -t winmerge HEAD~
	
	Viewing (1/1): 'mergetools/winmerge'
	Launch 'winmerge' [Y/n]:
	The diff tool winmerge is not available as 'WinMergeU.exe'
	fatal: external diff died, stopping at mergetools/winmerge

It ensures that the user sees 'WinMergeU.exe' in the error message.
That way the user can resolve the problem by e.g. adjusting their $PATH,
or realizing that they don't have WinMergeU.exe installed.
-- 
David

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-22 19:58     ` David Aguilar
@ 2015-05-22 20:05       ` Junio C Hamano
  2015-05-22 20:16         ` David Aguilar
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2015-05-22 20:05 UTC (permalink / raw)
  To: David Aguilar
  Cc: SZEDER Gábor, Phil Susi, git, Philip Oakley,
	Johannes Schindelin, Sebastian Schuberth

David Aguilar <davvid@gmail.com> writes:

> [just wrapping up the unaswered questions in this thread]
> ...
> On Wed, May 20, 2015 at 01:09:29PM +0200, SZEDER Gábor wrote:

Thanks for clarifications.  I think all is good now?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v6 2/2] mergetools: add winmerge as a builtin tool
  2015-05-22 20:05       ` Junio C Hamano
@ 2015-05-22 20:16         ` David Aguilar
  0 siblings, 0 replies; 11+ messages in thread
From: David Aguilar @ 2015-05-22 20:16 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: SZEDER Gábor, Phil Susi, git, Philip Oakley,
	Johannes Schindelin, Sebastian Schuberth

On Fri, May 22, 2015 at 01:05:28PM -0700, Junio C Hamano wrote:
> David Aguilar <davvid@gmail.com> writes:
> 
> > [just wrapping up the unaswered questions in this thread]
> > ...
> > On Wed, May 20, 2015 at 01:09:29PM +0200, SZEDER Gábor wrote:
> 
> Thanks for clarifications.  I think all is good now?

Yes, I think so.  I just looked at what you have queued in pu
and it looks good.

Thanks all,
-- 
David

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2015-05-22 20:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20  9:07 [PATCH v6 1/2] mergetool--lib: set IFS for difftool and mergetool David Aguilar
2015-05-20  9:07 ` [PATCH v6 2/2] mergetools: add winmerge as a builtin tool David Aguilar
2015-05-20 11:09   ` SZEDER Gábor
2015-05-22 19:58     ` David Aguilar
2015-05-22 20:05       ` Junio C Hamano
2015-05-22 20:16         ` David Aguilar
2015-05-20 20:13   ` Junio C Hamano
2015-05-20 20:20     ` Sebastian Schuberth
2015-05-20 21:00       ` Junio C Hamano
2015-05-20 21:20         ` Sebastian Schuberth
2015-05-21 10:06         ` Johannes Schindelin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.