Re: [PATCH v6] Support auto-merge for meld to follow the vim-diff behavior

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

 



Đoàn Trần Công Danh  <congdanhqx@xxxxxxxxx> writes:

>>     if o=$(git config --bool 2>/dev/null mergetool.meld.useautomerge)
>>     then
>>     	meld_use_auto_merge_option=$o
>>     elif test auto = "$(git config mergetool.meld.useautomerge)"
>>     then
>> 	... auto detect ...
>>     else
>> 	meld_use_auto_merge_option=false
>>     fi
>
> Something like this should work if we don't write anything to stderr,
> except the complain from git-config:

I did say "Maybe somebody else has a clever idea to reduce the two
calls into one without breaking correctness" but the stress is on
the "without breaking correctness" part, not on "clever" part.  Two
"git config" call may be more expensive than one call, but at least
the resulting code is readable.

If we really wanted to, I think the way to go would actually be to
teach "git config" new options that allows us scripters to express
what we can already say internally like "maybe bool", "bool or int",
etc.  IOW, "git config --bool-or-string" that does something like

int git_config_bool_or_str(const char **dest,
			   const char *name, const char *value);
{
	int v = git_parse_maybe_bool_text(value);
	if (0 <= v)
        	*dest = v ? "true" : "false";
	else                
        	*dest = value;
	return 0;
}

may help normalizing various ways to spell boolean plus non-boolean
strings into canonical form, so that you can say

	if o=$(git config --bool-or-string mergetool.meld.useautomerge)"
	then
		case "$o" in
		true | false)
		        meld_use_auto_merge_option=$o # as specified
			;;
		auto)
			... auto detect ...
			;;
		esac
	else
		meld_use_auto_merge_option=false
	fi
	
But I think two calls to config is good enough and it certainly is
not worth making the script ugly with hackeries and/or manually
enumerating all the possible shapes of trues and falses.

Thanks.




[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