All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "sunlin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, sunlin <sunlin7@yahoo.com>,
	Lin Sun <lin.sun@zoom.us>
Subject: Re: [PATCH v16] Support auto-merge for meld to follow the vim-diff behavior
Date: Sun, 12 Jul 2020 22:14:46 -0700	[thread overview]
Message-ID: <xmqq5zasov21.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <xmqqzh84pq3l.fsf@gitster.c.googlers.com> (Junio C. Hamano's message of "Sun, 12 Jul 2020 11:04:14 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> ...
> Now that the --bool-or-string would be silent, you have to give an
> error message yourself here, no?  Have you hand-tested the result of
> applying your patch to see if all the cases we care about (i.e.
> various scenarios we raised and thought together how the code should
> react to the situation during the review discussion so far)?
>
> We are not in a hurry, and we will not be paying too much attention
> on topics that are not yet in 'next' until the upcoming release is
> done anyway, so take your time to try polishing before sending
> anything out.

Just for fun, I've queued the following on top of v16 and merged the
result to 'seen'.

As this adds a new feature to "git config", it also needs updates to
Documentation/git-config.txt and tests for the feature, and it
probably makes sense to make it a two-patch series.  Everything
related to the "git config" enhancement as 1/2, and change to
mergetools/meld as 2/2.

 builtin/config.c | 16 +++++++---------
 config.c         | 14 --------------
 config.h         |  7 -------
 mergetools/meld  | 16 ++++++++++------
 4 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/builtin/config.c b/builtin/config.c
index 6f2ddadc80..7891e070a4 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -65,7 +65,7 @@ static int show_scope;
 #define TYPE_PATH		4
 #define TYPE_EXPIRY_DATE	5
 #define TYPE_COLOR		6
-#define TYPE_BOOL_OR_STR        7
+#define TYPE_BOOL_OR_STR	7
 
 #define OPT_CALLBACK_VALUE(s, l, v, h, i) \
 	{ OPTION_CALLBACK, (s), (l), (v), NULL, (h), PARSE_OPT_NOARG | \
@@ -255,12 +255,11 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value
 			else
 				strbuf_addf(buf, "%d", v);
 		} else if (type == TYPE_BOOL_OR_STR) {
-			int is_bool, v;
-			v = git_config_bool_or_str(NULL, key_, value_, &is_bool);
-			if (is_bool)
-				strbuf_addstr(buf, v ? "true" : "false");
-			else
+			int v = git_parse_maybe_bool(value_);
+			if (v < 0)
 				strbuf_addstr(buf, value_);
+			else
+				strbuf_addstr(buf, v ? "true" : "false");
 		} else if (type == TYPE_PATH) {
 			const char *v;
 			if (git_config_pathname(&v, key_, value_) < 0)
@@ -423,9 +422,8 @@ static char *normalize_value(const char *key, const char *value)
 			return xstrdup(v ? "true" : "false");
 	}
 	if (type == TYPE_BOOL_OR_STR) {
-		int is_bool, v;
-		v = git_config_bool_or_str(NULL, key, value, &is_bool);
-		if (!is_bool)
+		int v = git_parse_maybe_bool(value);
+		if (v < 0)
 			return xstrdup(value);
 		else
 			return xstrdup(v ? "true" : "false");
diff --git a/config.c b/config.c
index 4c6c06d10b..8db9c77098 100644
--- a/config.c
+++ b/config.c
@@ -1100,20 +1100,6 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
 	return git_config_int(name, value);
 }
 
-int git_config_bool_or_str(const char **dest, const char *name, const char *value, int *is_bool)
-{
-	int v = git_parse_maybe_bool_text(value);
-	if (0 <= v) {
-		*is_bool = 1;
-		return v;
-	}
-	*is_bool = 0;
-	if (dest != NULL)
-	  return git_config_string(dest, name, value);
-	else
-	  return 0;
-}
-
 int git_config_bool(const char *name, const char *value)
 {
 	int discard;
diff --git a/config.h b/config.h
index 175b88d9c5..060874488f 100644
--- a/config.h
+++ b/config.h
@@ -217,13 +217,6 @@ ssize_t git_config_ssize_t(const char *, const char *);
  */
 int git_config_bool_or_int(const char *, const char *, int *);
 
-/**
- * Same as `git_config_bool`, except that `is_bool` flag is unset, then if
- * `dest` parameter is non-NULL, it allocates and copies the value string
- * into the `dest`, if `dest` is NULL and `is_bool` flag is unset it return 0.
- */
-int git_config_bool_or_str(const char **, const char *, const char *, int *);
-
 /**
  * Parse a string into a boolean value, respecting keywords like "true" and
  * "false". Integer values are converted into true/false values (when they
diff --git a/mergetools/meld b/mergetools/meld
index bc2ea894d7..aab4ebb935 100644
--- a/mergetools/meld
+++ b/mergetools/meld
@@ -36,7 +36,7 @@ check_meld_for_features () {
 	then
 		meld_has_output_option=$(git config --bool mergetool.meld.hasOutput)
 		case "$meld_has_output_option" in
-		true|false)
+		true | false)
 			: use configured value
 			;;
 		*)
@@ -44,7 +44,7 @@ check_meld_for_features () {
 			init_meld_help_msg
 
 			case "$meld_help_msg" in
-			*"--output="*|*'[OPTION...]'*)
+			*"--output="* | *'[OPTION...]'*)
 				# All version that has [OPTION...] supports --output
 				meld_has_output_option=true
 				;;
@@ -59,9 +59,10 @@ check_meld_for_features () {
 	if test -z "$meld_use_auto_merge_option"
 	then
 		meld_use_auto_merge_option=$(
-			git config --bool-or-str mergetool.meld.useAutoMerge)
+			git config --bool-or-str mergetool.meld.useAutoMerge
+		)
 		case "$meld_use_auto_merge_option" in
-		true|false)
+		true | false)
 			: use well formatted boolean value
 			;;
 		auto)
@@ -69,7 +70,7 @@ check_meld_for_features () {
 			init_meld_help_msg
 
 			case "$meld_help_msg" in
-			*"--auto-merge"*|*'[OPTION...]'*)
+			*"--auto-merge"* | *'[OPTION...]'*)
 				meld_use_auto_merge_option=true
 				;;
 			*)
@@ -77,9 +78,12 @@ check_meld_for_features () {
 				;;
 			esac
 			;;
-		*)
+		"")
 			meld_use_auto_merge_option=false
 			;;
+		*)
+			die "unknown mergetool.meld.useAutoMerge: $meld_use_auto_merge_option"
+			;;
 		esac
 	fi
 }
-- 
2.28.0-rc0


  parent reply	other threads:[~2020-07-13  5:14 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08  1:25 [PATCH] Enable auto-merge for meld to follow the vim-diff beharior sunlin via GitGitGadget
2020-06-08  9:49 ` Pratyush Yadav
2020-06-09  3:19 ` [PATCH v2] " sunlin via GitGitGadget
2020-06-29  7:07   ` [PATCH v3] " sunlin via GitGitGadget
2020-06-29 12:32     ` Fwd: " Git Gadget
2020-06-30  0:06     ` Junio C Hamano
2020-06-30  7:42       ` David Aguilar
2020-06-30 11:25         ` lin.sun
2020-06-30 11:37         ` lin.sun
2020-06-30 15:51         ` Junio C Hamano
2020-06-30 11:26     ` [PATCH v4] " sunlin via GitGitGadget
2020-06-30 16:23       ` Đoàn Trần Công Danh
2020-06-30 23:01         ` Đoàn Trần Công Danh
2020-07-01  7:06       ` [PATCH v5] " sunlin via GitGitGadget
2020-07-01  7:23         ` lin.sun
2020-07-01 18:19           ` David Aguilar
2020-07-01 14:17         ` Đoàn Trần Công Danh
2020-07-01 15:32           ` lin.sun
2020-07-01 22:02             ` lin.sun
2020-07-01 23:06               ` Đoàn Trần Công Danh
2020-07-01 19:51           ` Junio C Hamano
2020-07-02  0:20             ` lin.sun
2020-07-02  0:44         ` [PATCH v6] Support auto-merge for meld to follow the vim-diff behavior sunlin via GitGitGadget
2020-07-02  2:35           ` lin.sun
2020-07-03  1:50           ` Junio C Hamano
2020-07-03  3:53             ` lin.sun
2020-07-03 15:58             ` Đoàn Trần Công Danh
2020-07-06  6:23               ` Junio C Hamano
2020-07-03  3:26           ` [PATCH v7] " sunlin via GitGitGadget
2020-07-03  4:50             ` Junio C Hamano
2020-07-04  1:18               ` lin.sun
2020-07-06  2:36                 ` lin.sun
2020-07-04  1:16             ` [PATCH v8] " sunlin via GitGitGadget
2020-07-06  2:27               ` [PATCH v9] " sunlin via GitGitGadget
2020-07-06 22:31                 ` Junio C Hamano
2020-07-07  6:34                   ` lin.sun
2020-07-07 16:43                     ` Junio C Hamano
2020-07-08  1:20                       ` lin.sun
2020-07-08  1:51                         ` Junio C Hamano
2020-07-07  6:17                 ` [PATCH v10] " sunlin via GitGitGadget
2020-07-07  6:25                   ` Junio C Hamano
2020-07-07  6:38                     ` lin.sun
2020-07-07  6:44                       ` lin.sun
2020-07-07  7:13                   ` [PATCH v11] " sunlin via GitGitGadget
2020-07-07 15:31                     ` Đoàn Trần Công Danh
2020-07-08  0:57                       ` lin.sun
2020-07-08  3:25                     ` [PATCH v12] " sunlin via GitGitGadget
2020-07-08  3:31                       ` lin.sun
2020-07-08 15:42                       ` Đoàn Trần Công Danh
2020-07-08 15:47                         ` lin.sun
2020-07-09  0:35                       ` [PATCH v13] " sunlin via GitGitGadget
2020-07-09  0:39                         ` lin.sun
2020-07-09  2:42                         ` Junio C Hamano
2020-07-09  2:56                         ` Junio C Hamano
2020-07-09  3:24                           ` lin.sun
2020-07-09  4:49                             ` Junio C Hamano
2020-07-09  5:31                               ` Junio C Hamano
2020-07-12 14:07                             ` lin.sun
2020-07-12 23:38                               ` lin.sun
2020-07-09  4:28                         ` [PATCH v14] " sunlin via GitGitGadget
2020-07-12  8:39                           ` [PATCH v15] " sunlin via GitGitGadget
2020-07-12  9:08                             ` [PATCH v16] " sunlin via GitGitGadget
2020-07-12 18:04                               ` Junio C Hamano
2020-07-12 23:26                                 ` lin.sun
2020-07-13  5:14                                 ` Junio C Hamano [this message]
2020-07-13  6:58                                   ` lin.sun
2020-07-12 23:32                               ` [PATCH v17] " sunlin via GitGitGadget
2020-07-24  0:58                                 ` Junio C Hamano
2020-09-03 21:48                                   ` Junio C Hamano
     [not found]                                     ` <C35AC799-B4F6-4A5E-92FA-21065310B379@hxcore.ol>
2020-09-09  1:31                                       ` Lin Sun
2020-09-09 20:43                                         ` Junio C Hamano
2020-09-12  7:21                                 ` [PATCH v18] " sunlin via GitGitGadget
2020-09-14 20:07                                   ` Junio C Hamano
2020-09-15  0:55                                     ` Lin Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq5zasov21.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=lin.sun@zoom.us \
    --cc=sunlin7@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.