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

Re: [PATCH 2/2] mergetool: run prompt only if guessed tool

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 22, 2014, 17:19 UTC
Message-ID
<xmqqbnvt703s.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140422045951.GA60610@gmail.com>
David Aguilar <davvid@gmail.com> writes:
Show 17 quoted lines
> [Cc:ing Charles in case he has an opinion, this behavior dates back to the original MT]
>
> On Sun, Apr 20, 2014 at 07:17:34PM -0500, Felipe Contreras wrote:
>> It's annoying to see the prompt:
>> 
>>   Hit return to start merge resolution tool (foo):
>> 
>> Every time the user does 'git mergetool' even if the user already
>> configured 'foo' as the wanted tool.
>> 
>> Display this prompt only when the user hasn't explicitly configured a
>> tool.
>
> I agree this is probably helpful.
> Most users I've met end up configuring mergetool.prompt=false.
>
> Thanks
OK, is it an Ack?

Thanks for CC'ing Charles, by the way. I think his point about mentioning the change of default somewhere in the documentation has some merits, and it can be done in a follow-up patch on top.

Show 51 quoted lines
>> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
>> ---
>>  git-mergetool.sh | 14 +++++++++++---
>>  1 file changed, 11 insertions(+), 3 deletions(-)
>> 
>> diff --git a/git-mergetool.sh b/git-mergetool.sh
>> index 332528f..d08dc92 100755
>> --- a/git-mergetool.sh
>> +++ b/git-mergetool.sh
>> @@ -277,7 +277,7 @@ merge_file () {
>>  	echo "Normal merge conflict for '$MERGED':"
>>  	describe_file "$local_mode" "local" "$LOCAL"
>>  	describe_file "$remote_mode" "remote" "$REMOTE"
>> -	if "$prompt" = true
>> +	if test "$guessed_merge_tool" = true || test "$prompt" = true
>>  	then
>>  		printf "Hit return to start merge resolution tool (%s): " "$merge_tool"
>>  		read ans || return 1
>> @@ -315,7 +315,8 @@ merge_file () {
>>  	return 0
>>  }
>>  
>> -prompt=$(git config --bool mergetool.prompt || echo true)
>> +prompt=$(git config --bool mergetool.prompt)
>> +guessed_merge_tool=false
>>  
>>  while test $# != 0
>>  do
>> @@ -373,7 +374,14 @@ prompt_after_failed_merge () {
>>  
>>  if test -z "$merge_tool"
>>  then
>> -	merge_tool=$(get_merge_tool "$merge_tool") || exit
>> +	# Check if a merge tool has been configured
>> +	merge_tool=$(get_configured_merge_tool)
>> +	# Try to guess an appropriate merge tool if no tool has been set.
>> +	if test -z "$merge_tool"
>> +	then
>> +		merge_tool=$(guess_merge_tool) || exit
>> +		guessed_merge_tool=true
>> +	fi
>>  fi
>>  merge_keep_backup="$(git config --bool mergetool.keepBackup || echo true)"
>>  merge_keep_temporaries="$(git config --bool mergetool.keepTemporaries || echo false)"
>> -- 
>> 1.9.2+fc1.1.g5c924db
>> 
>> --
>> To unsubscribe from this list: send the line "unsubscribe git" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Junio C HamanoNext: David Aguilar
Message 15 of 19 in “Simple default fixes for v2.0”
  1. 0/2 Simple default fixes for v2.0Felipe Contreras, Apr 21, 2014
  2. 1/2 merge: enable defaulttoupstream by defaultFelipe Contreras, Apr 21, 2014
  3. Junio C HamanoApr 22, 2014
  4. 2/2 mergetool: run prompt only if guessed toolFelipe Contreras, Apr 21, 2014
  5. David AguilarApr 22, 2014
  6. Charles BaileyApr 22, 2014
  7. Felipe ContrerasApr 22, 2014
  8. Charles BaileyApr 22, 2014
  9. Felipe ContrerasApr 22, 2014
  10. Charles BaileyApr 22, 2014
  11. Felipe ContrerasApr 22, 2014
  12. Charles BaileyApr 23, 2014
  13. Junio C HamanoApr 23, 2014
  14. Junio C HamanoApr 24, 2014
  15. Junio C HamanoApr 22, 2014
  16. David AguilarApr 23, 2014
  17. Junio C HamanoApr 23, 2014
  18. Junio C HamanoApr 22, 2014
  19. Junio C HamanoApr 22, 2014

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.