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

[PATCH v4 0/6] difftool and mergetool improvements

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 25, 2019, 09:54 UTC
Message-ID
<cover.1556185345.git.liu.denton@gmail.com>
In-Reply-To
<cover.1556142510.git.liu.denton@gmail.com>
Thanks for another review, Junio.

This should basically be the same as v3 except I've moved the IFS assignment into a subshell so its value does not leak out.

I'd like the change in 4/6 to be reviewed carefully. t7610 and t7800 run properly with dash on My Machineة, but I couldn't find a reference on whether my usage is POSIX legal or not.

We do have precedent for using fors within a subshell, though, from a quick git grep:

	t/t3202-show-branch-octopus.sh: git show-branch $(for i in $numbers; do echo branch$i; done) > out &&
Thanks,
Denton
---
Changes since v3:
* Move nested for into a subshell so that IFS does not leak out of
  function
Changes since v2:
* Unsuppress output in t7610
* Make `get_merge_tool` return 1 on guessed so we don't have to deal
  with parsing '$guessed:$merge_tool'
Changes since v1:
* Introduce get_merge_tool_guessed function instead of changing
  get_merge_tool
* Remove unnecessary if-tower in mutual exclusivity logic
Denton Liu (6):
  t7610: unsuppress output
  t7610: add mergetool --gui tests
  mergetool: use get_merge_tool function
  mergetool: fallback to tool when guitool unavailable
  difftool: make --gui, --tool and --extcmd mutually exclusive
  difftool: fallback on merge.guitool
 Documentation/git-difftool.txt       |   4 +-
 Documentation/git-mergetool--lib.txt |   4 +-
 Documentation/git-mergetool.txt      |   4 +-
 builtin/difftool.c                   |  13 +--
 git-difftool--helper.sh              |   2 +-
 git-mergetool--lib.sh                |  37 ++++--
 git-mergetool.sh                     |  12 +-
 t/t7610-mergetool.sh                 | 163 +++++++++++++++++----------
 t/t7800-difftool.sh                  |  24 ++++
 9 files changed, 172 insertions(+), 91 deletions(-)
Range-diff against v3:
1:  9f9922cab3 = 1:  9f9922cab3 t7610: unsuppress output
2:  0f632ca6bf = 2:  0f632ca6bf t7610: add mergetool --gui tests
3:  ff83d25ff2 = 3:  ff83d25ff2 mergetool: use get_merge_tool function
4:  e975fe4a8b ! 4:  c799e871e2 mergetool: fallback to tool when guitool unavailable
    @@ -6,14 +6,18 @@
         not set, it falls back to `diff.tool`. Make git-mergetool also fallback
         from `merge.guitool` to `merge.tool` if the former is undefined.
     
    -    If git-difftool were to use `get_configured_mergetool`, it would also
    -    get the fallback behaviour in the following precedence:
    +    If git-difftool, when called with `--gui`, were to use
    +    `get_configured_mergetool` in a future patch, it would also get the
    +    fallback behavior in the following precedence:
     
         1. diff.guitool
         2. merge.guitool
         3. diff.tool
         4. merge.tool
     
    +    Note that the behavior for when difftool or mergetool are called without
    +    `--gui` should be identical with or without this patch.
    +
         Signed-off-by: Denton Liu <liu.denton@gmail.com>
     
      diff --git a/Documentation/git-mergetool.txt b/Documentation/git-mergetool.txt
    @@ -61,14 +65,19 @@
     +		keys="guitool $keys"
      	fi
     +
    -+	IFS=' '
    -+	for key in $keys
    -+	do
    -+		for section in $sections
    ++	merge_tool=$(
    ++		IFS=' '
    ++		for key in $keys
     +		do
    -+			merge_tool=$(git config $section.$key) && break 2
    -+		done
    -+	done
    ++			for section in $sections
    ++			do
    ++				if selected=$(git config $section.$key)
    ++				then
    ++					echo "$selected"
    ++					return
    ++				fi
    ++			done
    ++		done)
     +
      	if test -n "$merge_tool" && ! valid_tool "$merge_tool"
      	then
5:  bc3e229171 = 5:  7d7c936cd3 difftool: make --gui, --tool and --extcmd mutually exclusive
6:  f39b15efbd = 6:  b642ed3b1e difftool: fallback on merge.guitool
-- 
2.21.0.1000.g11cd861522
Previous: Junio C HamanoNext: Denton Liu
Message 32 of 48 in “difftool and mergetool improvements”
  1. 0/5 difftool and mergetool improvementsDenton Liu, Apr 22, 2019
  2. 1/5 t7610: add mergetool --gui testsDenton Liu, Apr 22, 2019
  3. 2/5 mergetool: use get_merge_tool functionDenton Liu, Apr 22, 2019
  4. Eric SunshineApr 22, 2019
  5. Denton LiuApr 22, 2019
  6. 3/5 mergetool: fallback to tool when guitool unavailableDenton Liu, Apr 22, 2019
  7. 4/5 difftool: make --gui, --tool and --extcmd exclusiveDenton Liu, Apr 22, 2019
  8. Eric SunshineApr 22, 2019
  9. 5/5 difftool: fallback on merge.guitoolDenton Liu, Apr 22, 2019
  10. Jeff HostetlerApr 22, 2019
  11. Denton LiuApr 22, 2019
  12. 0/5 difftool and mergetool improvementsDenton Liu, Apr 23, 2019
  13. 1/5 t7610: add mergetool --gui testsDenton Liu, Apr 23, 2019
  14. Junio C HamanoApr 24, 2019
  15. 2/5 mergetool: use get_merge_tool_guessed functionDenton Liu, Apr 23, 2019
  16. Junio C HamanoApr 24, 2019
  17. 3/5 mergetool: fallback to tool when guitool unavailableDenton Liu, Apr 23, 2019
  18. 4/5 difftool: make --gui, --tool and --extcmd mutually exclusiveDenton Liu, Apr 23, 2019
  19. 5/5 difftool: fallback on merge.guitoolDenton Liu, Apr 23, 2019
  20. 0/6 difftool and mergetool improvementsDenton Liu, Apr 24, 2019
  21. 1/6 t7610: unsuppress outputDenton Liu, Apr 24, 2019
  22. Junio C HamanoApr 25, 2019
  23. 2/6 t7610: add mergetool --gui testsDenton Liu, Apr 24, 2019
  24. 3/6 mergetool: use get_merge_tool functionDenton Liu, Apr 24, 2019
  25. Junio C HamanoApr 25, 2019
  26. 4/6 mergetool: fallback to tool when guitool unavailableDenton Liu, Apr 24, 2019
  27. Junio C HamanoApr 25, 2019
  28. Denton LiuApr 25, 2019
  29. 5/6 difftool: make --gui, --tool and --extcmd mutually exclusiveDenton Liu, Apr 24, 2019
  30. 6/6 difftool: fallback on merge.guitoolDenton Liu, Apr 24, 2019
  31. Junio C HamanoApr 25, 2019
  32. 0/6 difftool and mergetool improvementsDenton Liu, Apr 25, 2019
  33. 1/6 t7610: unsuppress outputDenton Liu, Apr 25, 2019
  34. 2/6 t7610: add mergetool --gui testsDenton Liu, Apr 25, 2019
  35. 3/6 mergetool: use get_merge_tool functionDenton Liu, Apr 25, 2019
  36. David AguilarApr 28, 2019
  37. 4/6 mergetool: fallback to tool when guitool unavailableDenton Liu, Apr 25, 2019
  38. David AguilarApr 28, 2019
  39. 5/6 difftool: make --gui, --tool and --extcmd mutually exclusiveDenton Liu, Apr 25, 2019
  40. 6/6 difftool: fallback on merge.guitoolDenton Liu, Apr 25, 2019
  41. 0/7 difftool and mergetool improvementsDenton Liu, Apr 29, 2019
  42. 1/7 t7610: unsuppress outputDenton Liu, Apr 29, 2019
  43. 2/7 t7610: add mergetool --gui testsDenton Liu, Apr 29, 2019
  44. 3/7 mergetool: use get_merge_tool functionDenton Liu, Apr 29, 2019
  45. 4/7 mergetool--lib: create gui_mode functionDenton Liu, Apr 29, 2019
  46. 5/7 mergetool: fallback to tool when guitool unavailableDenton Liu, Apr 29, 2019
  47. 6/7 difftool: make --gui, --tool and --extcmd mutually exclusiveDenton Liu, Apr 29, 2019
  48. 7/7 difftool: fallback on merge.guitoolDenton Liu, Apr 29, 2019

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.