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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 13, 2020, 05:14 UTC
Message-ID
<xmqq5zasov21.fsf@gitster.c.googlers.com>
In-Reply-To
<xmqqzh84pq3l.fsf@gitster.c.googlers.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> ...
> 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
Previous: lin.sun@zoom.usNext: lin.sun@zoom.us
Message 65 of 74 in “Enable auto-merge for meld to follow the vim-diff beharior”
  1. Enable auto-merge for meld to follow the vim-diff behariorsunlin via GitGitGadget, May 8, 2020
  2. Pratyush YadavJun 8, 2020
  3. Enable auto-merge for meld to follow the vim-diff behariorsunlin via GitGitGadget, Jun 9, 2020
  4. Enable auto-merge for meld to follow the vim-diff behariorsunlin via GitGitGadget, Jun 29, 2020
  5. Fwd: [PATCH v3] Enable auto-merge for meld to follow the vim-diff behariorGit Gadget, Jun 29, 2020
  6. Junio C HamanoJun 30, 2020
  7. David AguilarJun 30, 2020
  8. lin.sun@zoom.usJun 30, 2020
  9. Enable auto-merge for meld to follow the vim-diff behariorlin.sun@zoom.us, Jun 30, 2020
  10. Junio C HamanoJun 30, 2020
  11. Enable auto-merge for meld to follow the vim-diff behariorsunlin via GitGitGadget, Jun 30, 2020
  12. Đoàn Trần Công DanhJun 30, 2020
  13. Đoàn Trần Công DanhJun 30, 2020
  14. Enable auto-merge for meld to follow the vim-diff behariorsunlin via GitGitGadget, Jul 1, 2020
  15. lin.sun@zoom.usJul 1, 2020
  16. David AguilarJul 1, 2020
  17. Đoàn Trần Công DanhJul 1, 2020
  18. lin.sun@zoom.usJul 1, 2020
  19. lin.sun@zoom.usJul 1, 2020
  20. Đoàn Trần Công DanhJul 1, 2020
  21. Junio C HamanoJul 1, 2020
  22. lin.sun@zoom.usJul 2, 2020
  23. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 2, 2020
  24. lin.sun@zoom.usJul 2, 2020
  25. Junio C HamanoJul 3, 2020
  26. lin.sun@zoom.usJul 3, 2020
  27. Đoàn Trần Công DanhJul 3, 2020
  28. Junio C HamanoJul 6, 2020
  29. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 3, 2020
  30. Junio C HamanoJul 3, 2020
  31. lin.sun@zoom.usJul 4, 2020
  32. lin.sun@zoom.usJul 6, 2020
  33. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 4, 2020
  34. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 6, 2020
  35. Junio C HamanoJul 6, 2020
  36. lin.sun@zoom.usJul 7, 2020
  37. Junio C HamanoJul 7, 2020
  38. lin.sun@zoom.usJul 8, 2020
  39. Junio C HamanoJul 8, 2020
  40. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 7, 2020
  41. Junio C HamanoJul 7, 2020
  42. lin.sun@zoom.usJul 7, 2020
  43. lin.sun@zoom.usJul 7, 2020
  44. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 7, 2020
  45. Đoàn Trần Công DanhJul 7, 2020
  46. lin.sun@zoom.usJul 8, 2020
  47. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 8, 2020
  48. lin.sun@zoom.usJul 8, 2020
  49. Đoàn Trần Công DanhJul 8, 2020
  50. lin.sun@zoom.usJul 8, 2020
  51. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 9, 2020
  52. Support auto-merge for meld to follow the vim-diff behaviorlin.sun@zoom.us, Jul 9, 2020
  53. Junio C HamanoJul 9, 2020
  54. Junio C HamanoJul 9, 2020
  55. lin.sun@zoom.usJul 9, 2020
  56. Junio C HamanoJul 9, 2020
  57. Junio C HamanoJul 9, 2020
  58. lin.sun@zoom.usJul 12, 2020
  59. lin.sun@zoom.usJul 12, 2020
  60. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 9, 2020
  61. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 12, 2020
  62. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 12, 2020
  63. Junio C HamanoJul 12, 2020
  64. lin.sun@zoom.usJul 12, 2020
  65. Junio C HamanoJul 13, 2020
  66. lin.sun@zoom.usJul 13, 2020
  67. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Jul 12, 2020
  68. Junio C HamanoJul 24, 2020
  69. Junio C HamanoSep 3, 2020
  70. Support auto-merge for meld to follow the vim-diff behaviorsunlin via GitGitGadget, Sep 12, 2020
  71. Junio C HamanoSep 14, 2020
  72. Lin SunSep 15, 2020
  73. Lin SunSep 9, 2020
  74. Junio C HamanoSep 9, 2020

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.