Re: [PATCH 1/2] mergetool: Accept -g/--[no-]gui as arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 24, 2018 at 02:10:14PM +0900, Junio C Hamano wrote:
> Denton Liu <liu.denton@xxxxxxxxx> writes:
> 
> > Subject: Re: [PATCH 1/2] mergetool: Accept -g/--[no-]gui as arguments
> 
> Other people may point it out, but s/Accept/accept/.
> 
> > In line with how difftool accepts a -g/--[no-]gui option, make mergetool
> > accept the same option in order to use the `merge.guitool` variable to
> > find the default mergetool instead of `merge.tool`.
> > ...
> > diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> > index 9a8b97a2a..e317ae003 100644
> > --- a/git-mergetool--lib.sh
> > +++ b/git-mergetool--lib.sh
> > @@ -350,17 +350,23 @@ guess_merge_tool () {
> >  }
> >  
> >  get_configured_merge_tool () {
> > -	# Diff mode first tries diff.tool and falls back to merge.tool.
> > -	# Merge mode only checks merge.tool
> > +	# If first argument is true, find the guitool instead
> > +	if [ "$1" = true ]
> 
> Don't use [] in our shell script (see Documentation/CodingGuidelines);
> say
> 
> 	if "$1" = true
> 
> instead.

Perhaps a small typo dropped "test" -- I think it should be

	if test "$1" = true


> > +	# Diff mode first tries diff.(gui)tool and falls back to merge.(gui)tool.
> > +	# Merge mode only checks merge.(gui)tool
> >  	if diff_mode
> >  	then
> > -		merge_tool=$(git config diff.tool || git config merge.tool)
> > +		merge_tool=$(git config diff.${gui_prefix}tool || git config merge.${gui_prefix}tool)
> >  	else
> > -		merge_tool=$(git config merge.tool)
> > +		merge_tool=$(git config merge.${gui_prefix}tool)
> >  	fi
> 
> In mode_ok shell function, we seem to be prepared to deal with a
> case where neither diff_mode nor merge_mode is true.  Should this
> codepath also be prepared to?  
> 
> This is not a comment to point out an issue with this patch.  It is
> a genuine question on the code after (or before for that matter)
> this patch is applied.
> 
> Thanks.


I think the code is okay.  mode_ok is setup that way to allow filtering
for the other mode's tools, but this code path is only concerned with
getting the default merge tool, which should only ever happen in one of
the two modes.

The bit about difftool falling back to mergetool's config is a
convenience so it does make sense to keep that for guitool as well.

The code after this part should handle merge_tool being empty just fine,
so once the `[ ... ]` vs `test` bit is updated, please feel free to add:

Acked-by: David Aguilar <davvid@xxxxxxxxx>


cheers,
-- 
David



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux