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

Re: [PATCH v3 4/6] mergetool: fallback to tool when guitool unavailable

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 25, 2019, 05:16 UTC
Message-ID
<20190425051620.GA32457@archbookpro.localdomain>
In-Reply-To
<xmqq7ebizt1c.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Thu, Apr 25, 2019 at 12:02:23PM +0900, Junio C Hamano wrote:
Show 14 quoted lines
> Denton Liu <liu.denton@gmail.com> writes:
> 
> > In git-difftool, if the tool is called with --gui but `diff.guitool` is
> > 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
> 
> I agree that the precedence order below makes sense, but I am a bit
> confused by "were to use" here.  Do you mean you'll make the change
> to make difftool to look at mergetool configuraiton in a later step
> in the series?  Or is there a way for the user to say "I want my
> difftool to also pay attention to the mergetool configurations" (and
> another "I do not want that" option)?  I'll come back to this later.
Correct, it means it'll be done in a future patch (i.e. 6/6).

I guess I wasn't fully clear in the message. I meant something like, "If `git difftool --gui` were to use..." because difftool currently already uses this function in the non-gui case.

[snip]
Show 19 quoted lines
> 
> > +	IFS=' '
> > +	for key in $keys
> > +	do
> > +		for section in $sections
> > +		do
> > +			merge_tool=$(git config $section.$key) && break 2
> > +		done
> > +	done
> 
> And you do up to four iterations to cover the combination in the
> precedence order.  Which makes sense.
> 
> I am not sure about the wisdom of setting IFS here, though.
> 
> As far as I can see, both $keys and $sections do not take any
> arbitrary values, but just the two (for each) values you know that
> do not have any funny characters, so I am not sure what you are
> trying to achieve by that (i.e. benefit is unclear).

The reason why IFS is being set is because at the top of mergetool--lib, we set IFS to '\n'. As a result, without setting IFS, the strings won't parse properly into the for loop.

Show 7 quoted lines
> 
> As long as the get_configured_merge_tool function is called always
> for string_emitted_to_stdout=$(that function), the updated setting
> will not leak to the outside world so there is no risk to break its
> callers, but it is not immediately obvious if helper functions
> called in the remainder of this function are OK with the modified
> value of IFS (i.e. safety is not obvious).

When I was writing this, I didn't realise that the value of IFS bleeds out of this function. I'll reroll this to use a helper function just in case.

Show 32 quoted lines
> 
> Now for the promised "come back to this later", I think you meant
> "the get_configured_merge_tool function is already prepared to be
> used from difftool in this step and when difftool starts to call it
> here is what happens".  But I wonder if it makes the evolution of
> the topic easier to follow if you defer it to a later step when you
> actually make difftool to start calling it?  In other words, in this
> step, your get_configured_merge_tool would look like
> 
> 	sections=merge
> 
> 	case "$1" in
> 	true)
> 		keys="guitool tool" ;;
> 	*)
> 		keys="tool" ;;
> 	esac
> 
> 	for key in $keys
> 	do
> 		for section in $sections
> 		do
> 			merge_tool=$(git config ...) && break 2
> 		done
> 	done
> 	...
> 
> and then in a later step (6/6?), the unconditional setting of
> sections to 'merge' would be updated so that in diff_mode, you'll
> iterate over two sections.
> 
> I dunno.

As stated above, difftool currently uses this function in the non-gui case. I think that clarifying the log message on my part should make it easier to understand the evolution of this topic.

Thanks for the careful review,
Denton
Previous: Junio C HamanoNext: Denton Liu
Message 28 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.