git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] mergetools: implemented new mergetool file for ExamDiff

From
David Aguilar <davvid@gmail.com>
Date
Mar 24, 2016, 07:44 UTC
Message-ID
<20160324074404.GA30574@gmail.com>
In-Reply-To
<1458773745-783-2-git-send-email-jacob.nisnevich@gmail.com>
On Wed, Mar 23, 2016 at 03:55:45PM -0700, Jacob Nisnevich wrote:
> Signed-off-by: Jacob Nisnevich <jacob.nisnevich@gmail.com>
> ---

Please write commit message in an imperative tone. e.g. "mergetools: add support for ExamDiff" might be a good summary.

Show 6 quoted lines
>  mergetools/examdiff           | 20 ++++++++++++++++++++
>  mergetools/mergetools_helpers | 24 ++++++++++++++++++++++++
>  mergetools/winmerge           | 23 +++--------------------
>  3 files changed, 47 insertions(+), 20 deletions(-)
>  create mode 100644 mergetools/examdiff
>  create mode 100644 mergetools/mergetools_helpers

This patch is doing two things. It's probably worth breaking this patch up into two parts.

Patch 1 can add add the new helper function and update winmerge to use it.

Patch 2 can add the new examdiff helper.
Show 31 quoted lines
> diff --git a/mergetools/examdiff b/mergetools/examdiff
> new file mode 100644
> index 0000000..c5edd0e
> --- /dev/null
> +++ b/mergetools/examdiff
> @@ -0,0 +1,20 @@
> +. "$MERGE_TOOLS_DIR/mergetools_helpers"
> +
> +diff_cmd () {
> +	"$merge_tool_path" "$LOCAL" "$REMOTE" -nh
> +}
> +
> +merge_cmd () {
> +	touch "$BACKUP"
> +	if $base_present
> +	then
> +		"$merge_tool_path" -merge "$LOCAL" "$BASE" "$REMOTE" -o:"$MERGED" -nh
> +	else
> +		"$merge_tool_path" -merge "$LOCAL" "$REMOTE" -o:"$MERGED" -nh
> +	fi
> +	check_unchanged
> +}
> +
> +translate_merge_tool_path() {
> +	mergetool_find_win32_cmd "ExamDiff.com" "ExamDiff Pro"
> +}
> diff --git a/mergetools/mergetools_helpers b/mergetools/mergetools_helpers
> new file mode 100644
> index 0000000..46ae2d8
> --- /dev/null
> +++ b/mergetools/mergetools_helpers

We can probably do this without introducing a new file. One possible home for this is with the rest of the "default" definitions of the functions in git-mergetool--lib.sh's setup_tool() function.

But, that hints that we expect tools to override it.

A better place would be as a normal function inside git-mergetool--lib.sh, which more strongly hints that we do not expect tools to override mergetool_find_win32_cmd().

Show 9 quoted lines
> @@ -0,0 +1,24 @@
> +mergetool_find_win32_cmd () {
> +	executable=$1
> +	folder=$2
> +
> +	# Use executable.com if it exists in $PATH
> +	if type -p $executable >/dev/null 2>&1
> +	then
> +		printf $executable
It might nut hurt to write this as,
		printf '%s' "$executable"
For consistency and future-proofing.
Show 23 quoted lines
> +		return
> +	fi
> +
> +	# Look for executable in the typical locations
> +	for directory in $(env | grep -Ei '^PROGRAM(FILES(\(X86\))?|W6432)=' |
> +		cut -d '=' -f 2- | sort -u)
> +	do
> +		if test -n "$directory" && test -x "$directory/$folder/$executable"
> +		then
> +			printf '%s' "$directory/$folder/$executable"
> +			return
> +		fi
> +	done
> +
> +	printf $executable
> +}
> diff --git a/mergetools/winmerge b/mergetools/winmerge
> index 74a66d4..c785be8 100644
> --- a/mergetools/winmerge
> +++ b/mergetools/winmerge
> @@ -1,3 +1,5 @@
> +. "$MERGE_TOOLS_DIR/mergetools_helpers"
> +

If we move the definition into mergetool--lib then we do not need to dot-include any files here -- it'll simply be present and available.

Show 32 quoted lines
>  diff_cmd () {
>  	"$merge_tool_path" -u -e "$LOCAL" "$REMOTE"
>  	return 0
> @@ -13,24 +15,5 @@ merge_cmd () {
>  }
>  
>  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
> +	mergetool_find_win32_cmd "WinMergeU.exe" "WinMerge"
>  }
> -- 
> 1.9.1
> 
-- 
David
Previous: Jacob NisnevichNext: Junio C Hamano
Message 10 of 20 in “mergetools: created new mergetool file for ExamDiff”
  1. mergetools: created new mergetool file for ExamDiffJacob Nisnevich, Mar 20, 2016
  2. Junio C HamanoMar 21, 2016
  3. David AguilarMar 21, 2016
  4. 0/2 Helper function for ExamDiff and Winmerge mergetoolsJacob Nisnevich, Mar 23, 2016
  5. 1/2 mergetools: created new mergetool file for ExamDiffJacob Nisnevich, Mar 23, 2016
  6. 2/2 created helper function for both winmerge and examdiff mergetoolsJacob Nisnevich, Mar 23, 2016
  7. Junio C HamanoMar 23, 2016
  8. mergetools: implemented new mergetool file for ExamDiffJacob Nisnevich, Mar 23, 2016
  9. mergetools: implemented new mergetool file for ExamDiffJacob Nisnevich, Mar 23, 2016
  10. David AguilarMar 24, 2016
  11. Junio C HamanoMar 24, 2016
  12. 0/2 add support for ExamDiffJacob Nisnevich, Mar 25, 2016
  13. 1/2 mergetools: create mergetool_find_win32_cmd() helper function for winmergeJacob Nisnevich, Mar 25, 2016
  14. Junio C HamanoMar 25, 2016
  15. 0/2 mergetools: add support for ExamDiffJacob Nisnevich, Mar 25, 2016
  16. 1/2 mergetools: create mergetool_find_win32_cmd() helper function for winmergeJacob Nisnevich, Mar 25, 2016
  17. 2/2 mergetools: add support for ExamDiffJacob Nisnevich, Mar 25, 2016
  18. Junio C HamanoApr 1, 2016
  19. David AguilarApr 2, 2016
  20. 2/2 mergetools: add support for ExamDiffJacob Nisnevich, Mar 25, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.