{"thread":{"id":"61022","subject":"Allow setting diff.worddiff=color via gitconfig","startedAt":"2024-02-28T09:01:45Z","lastAt":"2024-03-25T21:53:57Z","messageCount":17,"participants":["Olliver Schinagl","Karthik Nayak","Eric Sunshine","Junio C Hamano","Jean-Noël AVILA","Kristoffer Haugsbakk","Chris Torek","Dragan Simic"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"489594","messageId":"a7be415d-5005-4fa7-9b2e-1974b7439a81@schinagl.nl","threadId":"61022","inReplyTo":null,"subject":"Allow setting diff.worddiff=color via gitconfig","fromName":"Olliver Schinagl","fromEmail":"oliver@schinagl.nl","sentAt":"2024-02-28T08:54:19Z","receivedAt":"2024-02-28T09:01:45Z","isPatch":false,"sender":{"key":"oliver@schinagl.nl","avatar":"https://gravatar.com/avatar/abb8ef5f9b23563b7703a4114da6f9bd6e7f6d7e8e0296677547b20ff7740c56?d=mp&s=160"},"body":"Currently, the only way to set `word-diff=color` is through alias. It \nwould be much nicer of course if we could do\n\n\n[diff]\n     worddiff=color\n\n\nin git-config of course.\n\n\nThank you,\n\nOlliver\n\n"},{"id":"489763","messageId":"20240302095751.123138-1-karthik.188@gmail.com","threadId":"61022","inReplyTo":"a7be415d-5005-4fa7-9b2e-1974b7439a81@schinagl.nl","subject":"[PATCH 0/2] Support diff.wordDiff config","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-03-02T09:57:49Z","receivedAt":"2024-03-02T09:57:57Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"This patch series adds the diff.wordDiff config option. This mimics the\n'--word-diff' option of `git-diff(1)`.\n\nThe first patch is more of a preparatory patch, which makes it easier to\nadd tests when the actual config is added in patch 2.\n\nKarthik Nayak (2):\n  t4034: extract out `diff_with_opts`\n  diff: add 'diff.wordDiff' config option\n\n Documentation/config/diff.txt |  4 +++\n diff.c                        | 50 +++++++++++++++++++++------\n t/t4034-diff-words.sh         | 63 ++++++++++++++++++++---------------\n 3 files changed, 80 insertions(+), 37 deletions(-)\n\n-- \n2.43.GIT\n\n"},{"id":"489764","messageId":"20240302095751.123138-2-karthik.188@gmail.com","threadId":"61022","inReplyTo":"20240302095751.123138-1-karthik.188@gmail.com","subject":"[PATCH 1/2] t4034: extract out `diff_with_opts`","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-03-02T09:57:50Z","receivedAt":"2024-03-02T09:57:58Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The current `word_diff` function in t4034 uses the arguments provided to\nobtain the diff and compare them.\n\nLet's rename this to `diff_with_opts` and add a new function `word_diff`\nwhich is specific to the `--word-diff=` option. This function will act\nas a wrapper around `diff_with_opts`.\n\nIn the following commit, when we introduce a config option for\n`--word-diff`, we'd want to test the existing tests also with the config\noption and at this point we can expand `word_diff` to test both config\nand command line options.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n t/t4034-diff-words.sh | 54 +++++++++++++++++++++++--------------------\n 1 file changed, 29 insertions(+), 25 deletions(-)\n\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex 74586f3813..4f70aa6e9f 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -51,7 +51,7 @@ cat >expect.non-whitespace-is-word <<-EOF\n \t<GREEN>aeff = aeff * ( aaa )<RESET>\n EOF\n \n-word_diff () {\n+diff_with_opts () {\n \tpre=$(git rev-parse --short $(git hash-object pre)) &&\n \tpost=$(git rev-parse --short $(git hash-object post)) &&\n \ttest_must_fail git diff --no-index \"$@\" pre post >output &&\n@@ -60,6 +60,10 @@ word_diff () {\n \ttest_cmp expected output.decrypted\n }\n \n+word_diff () {\n+\tdiff_with_opts \"--word-diff=$1\" $(echo \"$@\" | cut -d' ' -s -f 2-)\n+}\n+\n test_language_driver () {\n \tlang=$1\n \ttest_expect_success \"diff driver '$lang'\" '\n@@ -67,11 +71,11 @@ test_language_driver () {\n \t\t\t\"$TEST_DIRECTORY/t4034/'\"$lang\"'/post\" \\\n \t\t\t\"$TEST_DIRECTORY/t4034/'\"$lang\"'/expect\" . &&\n \t\techo \"* diff='\"$lang\"'\" >.gitattributes &&\n-\t\tword_diff --color-words\n+\t\tdiff_with_opts --color-words\n \t'\n \ttest_expect_success \"diff driver '$lang' in Islandic\" '\n \t\tLANG=is_IS.UTF-8 LANGUAGE=is LC_ALL=\"$is_IS_locale\" \\\n-\t\tword_diff --color-words\n+\t\tdiff_with_opts --color-words\n \t'\n }\n \n@@ -81,7 +85,7 @@ test_expect_success setup '\n \tgit config diff.color.func magenta\n '\n \n-test_expect_success 'set up pre and post with runs of whitespace' '\n+test_expect_success 'setup pre and post with runs of whitespace' '\n \tcp pre.simple pre &&\n \tcp post.simple post\n '\n@@ -101,9 +105,9 @@ test_expect_success 'word diff with runs of whitespace' '\n \n \t\t<GREEN>aeff = aeff * ( aaa )<RESET>\n \tEOF\n-\tword_diff --color-words &&\n-\tword_diff --word-diff=color &&\n-\tword_diff --color --word-diff=color\n+\tdiff_with_opts --color-words &&\n+\tword_diff color &&\n+\tdiff_with_opts --color --word-diff=color\n '\n \n test_expect_success '--word-diff=porcelain' '\n@@ -127,7 +131,7 @@ test_expect_success '--word-diff=porcelain' '\n \t\t+aeff = aeff * ( aaa )\n \t\t~\n \tEOF\n-\tword_diff --word-diff=porcelain\n+\tword_diff porcelain\n '\n \n test_expect_success '--word-diff=plain' '\n@@ -145,8 +149,8 @@ test_expect_success '--word-diff=plain' '\n \n \t\t{+aeff = aeff * ( aaa )+}\n \tEOF\n-\tword_diff --word-diff=plain &&\n-\tword_diff --word-diff=plain --no-color\n+\tdiff_with_opts --word-diff=plain &&\n+\tword_diff plain --no-color\n '\n \n test_expect_success '--word-diff=plain --color' '\n@@ -164,7 +168,7 @@ test_expect_success '--word-diff=plain --color' '\n \n \t\t<GREEN>{+aeff = aeff * ( aaa )+}<RESET>\n \tEOF\n-\tword_diff --word-diff=plain --color\n+\tword_diff plain --color\n '\n \n test_expect_success 'word diff without context' '\n@@ -181,17 +185,17 @@ test_expect_success 'word diff without context' '\n \n \t\t<GREEN>aeff = aeff * ( aaa )<RESET>\n \tEOF\n-\tword_diff --color-words --unified=0\n+\tdiff_with_opts --color-words --unified=0\n '\n \n test_expect_success 'word diff with a regular expression' '\n \tcp expect.letter-runs-are-words expect &&\n-\tword_diff --color-words=\"[a-z]+\"\n+\tdiff_with_opts --color-words=\"[a-z]+\"\n '\n \n test_expect_success 'word diff with zero length matches' '\n \tcp expect.letter-runs-are-words expect &&\n-\tword_diff --color-words=\"[a-z${LF}]*\"\n+\tdiff_with_opts --color-words=\"[a-z${LF}]*\"\n '\n \n test_expect_success 'set up a diff driver' '\n@@ -204,12 +208,12 @@ test_expect_success 'set up a diff driver' '\n \n test_expect_success 'option overrides .gitattributes' '\n \tcp expect.letter-runs-are-words expect &&\n-\tword_diff --color-words=\"[a-z]+\"\n+\tdiff_with_opts --color-words=\"[a-z]+\"\n '\n \n test_expect_success 'use regex supplied by driver' '\n \tcp expect.non-whitespace-is-word expect &&\n-\tword_diff --color-words\n+\tdiff_with_opts --color-words\n '\n \n test_expect_success 'set up diff.wordRegex option' '\n@@ -218,7 +222,7 @@ test_expect_success 'set up diff.wordRegex option' '\n \n test_expect_success 'command-line overrides config' '\n \tcp expect.letter-runs-are-words expect &&\n-\tword_diff --color-words=\"[a-z]+\"\n+\tdiff_with_opts --color-words=\"[a-z]+\"\n '\n \n test_expect_success 'command-line overrides config: --word-diff-regex' '\n@@ -236,12 +240,12 @@ test_expect_success 'command-line overrides config: --word-diff-regex' '\n \n \t\t<GREEN>{+aeff = aeff * ( aaa+}<RESET> )\n \tEOF\n-\tword_diff --color --word-diff-regex=\"[a-z]+\"\n+\tdiff_with_opts --color --word-diff-regex=\"[a-z]+\"\n '\n \n test_expect_success '.gitattributes override config' '\n \tcp expect.non-whitespace-is-word expect &&\n-\tword_diff --color-words\n+\tdiff_with_opts --color-words\n '\n \n test_expect_success 'setup: remove diff driver regex' '\n@@ -263,7 +267,7 @@ test_expect_success 'use configured regex' '\n \n \t\t<GREEN>aeff = aeff * ( aaa<RESET> )\n \tEOF\n-\tword_diff --color-words\n+\tdiff_with_opts --color-words\n '\n \n test_expect_success 'test parsing words for newline' '\n@@ -279,7 +283,7 @@ test_expect_success 'test parsing words for newline' '\n \t\t<CYAN>@@ -1 +1 @@<RESET>\n \t\taaa (aaa) <GREEN>aaa<RESET>\n \tEOF\n-\tword_diff --color-words=\"a+\"\n+\tdiff_with_opts --color-words=\"a+\"\n '\n \n test_expect_success 'test when words are only removed at the end' '\n@@ -295,7 +299,7 @@ test_expect_success 'test when words are only removed at the end' '\n \t\t<CYAN>@@ -1 +1 @@<RESET>\n \t\t(<RED>:<RESET>\n \tEOF\n-\tword_diff --color-words=.\n+\tdiff_with_opts --color-words=.\n '\n \n test_expect_success '--word-diff=none' '\n@@ -312,7 +316,7 @@ test_expect_success '--word-diff=none' '\n \t\t-(:\n \t\t+(\n \tEOF\n-\tword_diff --word-diff=plain --word-diff=none\n+\tword_diff plain --word-diff=none\n '\n \n test_expect_success 'unset default driver' '\n@@ -363,7 +367,7 @@ test_expect_success 'word-diff with diff.sbe' '\n \t[-b-]{+c+}\n \tEOF\n \ttest_config diff.suppress-blank-empty true &&\n-\tword_diff --word-diff=plain\n+\tword_diff plain\n '\n \n test_expect_success 'word-diff with no newline at EOF' '\n@@ -379,7 +383,7 @@ test_expect_success 'word-diff with no newline at EOF' '\n \t@@ -1 +1 @@\n \ta a [-a-]{+ab+} a a\n \tEOF\n-\tword_diff --word-diff=plain\n+\tword_diff plain\n '\n \n test_expect_success 'setup history with two files' '\n-- \n2.43.GIT\n\n"},{"id":"489765","messageId":"20240302095751.123138-3-karthik.188@gmail.com","threadId":"61022","inReplyTo":"20240302095751.123138-1-karthik.188@gmail.com","subject":"[PATCH 2/2] diff: add 'diff.wordDiff' config option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-03-02T09:57:51Z","receivedAt":"2024-03-02T09:58:00Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"The git-diff(1) command supports the `--word-diff` which allows the\nusers to specify how to delimit word diffs. Provide this option also as\na config param 'diff.wordDiff'.\n\nSigned-off-by: Karthik Nayak <karthik.188@gmail.com>\n---\n Documentation/config/diff.txt |  4 +++\n diff.c                        | 50 +++++++++++++++++++++++++++--------\n t/t4034-diff-words.sh         | 11 ++++++--\n 3 files changed, 52 insertions(+), 13 deletions(-)\n\ndiff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt\nindex bd5ae0c337..00459beee2 100644\n--- a/Documentation/config/diff.txt\n+++ b/Documentation/config/diff.txt\n@@ -225,3 +225,7 @@ diff.colorMovedWS::\n \tWhen moved lines are colored using e.g. the `diff.colorMoved` setting,\n \tthis option controls the `<mode>` how spaces are treated\n \tfor details of valid modes see '--color-moved-ws' in linkgit:git-diff[1].\n+\n+diff.wordDiff::\n+\tShow a word diff, using the `<mode>` to delimit changed words.\n+\tFor details of valid modes see '--word-diff' in linkgit:git-diff[1].\ndiff --git a/diff.c b/diff.c\nindex e50def4538..050d83ef85 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -69,6 +69,7 @@ static int diff_dirstat_permille_default = 30;\n static struct diff_options default_diff_options;\n static long diff_algorithm;\n static unsigned ws_error_highlight_default = WSEH_NEW;\n+static int diff_word_diff_default;\n \n static char diff_colors[][COLOR_MAXLEN] = {\n \tGIT_COLOR_RESET,\n@@ -209,6 +210,23 @@ int git_config_rename(const char *var, const char *value)\n \treturn git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;\n }\n \n+static int parse_word_diff_value(const char *value)\n+{\n+\tif (!value)\n+\t\treturn -1;\n+\telse if (!strcmp(value, \"plain\"))\n+\t\treturn DIFF_WORDS_PLAIN;\n+\telse if (!strcmp(value, \"color\")) {\n+\t\treturn DIFF_WORDS_COLOR;\n+\t}\n+\telse if (!strcmp(value, \"porcelain\"))\n+\t\treturn DIFF_WORDS_PORCELAIN;\n+\telse if (!strcmp(value, \"none\"))\n+\t\treturn DIFF_WORDS_NONE;\n+\n+\treturn -1;\n+}\n+\n long parse_algorithm_value(const char *value)\n {\n \tif (!value)\n@@ -452,6 +470,18 @@ int git_diff_ui_config(const char *var, const char *value,\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"diff.worddiff\")) {\n+\t\tif (!value)\n+\t\t\treturn config_error_nonbool(var);\n+\t\tdiff_word_diff_default = parse_word_diff_value(value);\n+\t\tif (diff_word_diff_default < 0)\n+\t\t\treturn error(_(\"unknown value for config '%s': %s\"),\n+\t\t\t\t     var, value);\n+\t\tif (diff_word_diff_default == DIFF_WORDS_COLOR)\n+\t\t\tdiff_use_color_default = 1;\n+\t\treturn 0;\n+\t}\n+\n \tif (git_color_config(var, value, cb) < 0)\n \t\treturn -1;\n \n@@ -4724,6 +4754,7 @@ void repo_diff_setup(struct repository *r, struct diff_options *options)\n \toptions->use_color = diff_use_color_default;\n \toptions->detect_rename = diff_detect_rename_default;\n \toptions->xdl_opts |= diff_algorithm;\n+\toptions->word_diff |= diff_word_diff_default;\n \tif (diff_indent_heuristic)\n \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n \n@@ -5504,21 +5535,18 @@ static int diff_opt_word_diff(const struct option *opt,\n \t\t\t      const char *arg, int unset)\n {\n \tstruct diff_options *options = opt->value;\n+\tint value;\n \n \tBUG_ON_OPT_NEG(unset);\n+\n \tif (arg) {\n-\t\tif (!strcmp(arg, \"plain\"))\n-\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n-\t\telse if (!strcmp(arg, \"color\")) {\n-\t\t\toptions->use_color = 1;\n-\t\t\toptions->word_diff = DIFF_WORDS_COLOR;\n-\t\t}\n-\t\telse if (!strcmp(arg, \"porcelain\"))\n-\t\t\toptions->word_diff = DIFF_WORDS_PORCELAIN;\n-\t\telse if (!strcmp(arg, \"none\"))\n-\t\t\toptions->word_diff = DIFF_WORDS_NONE;\n-\t\telse\n+\t\tvalue = parse_word_diff_value(arg);\n+\t\tif (value < 0)\n \t\t\treturn error(_(\"bad --word-diff argument: %s\"), arg);\n+\t\tif (value == DIFF_WORDS_COLOR)\n+\t\t\toptions->use_color = 1;\n+\n+\t\toptions->word_diff = value;\n \t} else {\n \t\tif (options->word_diff == DIFF_WORDS_NONE)\n \t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex 4f70aa6e9f..2cc391c339 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -56,12 +56,19 @@ diff_with_opts () {\n \tpost=$(git rev-parse --short $(git hash-object post)) &&\n \ttest_must_fail git diff --no-index \"$@\" pre post >output &&\n \ttest_decode_color <output >output.decrypted &&\n-\tsed -e \"2s/index [^ ]*/index $pre..$post/\" expect >expected\n+\tsed -e \"2s/index [^ ]*/index $pre..$post/\" expect >expected &&\n \ttest_cmp expected output.decrypted\n }\n \n word_diff () {\n-\tdiff_with_opts \"--word-diff=$1\" $(echo \"$@\" | cut -d' ' -s -f 2-)\n+\t# Capture the rest of the arguments to passthrough.\n+\trest=$(echo \"$@\" | cut -d' ' -s -f 2-) &&\n+\t# Test via the config route.\n+\tgit config diff.wordDiff $1 &&\n+\tdiff_with_opts $rest &&\n+\tgit config --unset diff.wordDiff &&\n+\t# Test via the command option route.\n+\tdiff_with_opts \"--word-diff=$1\" $rest\n }\n \n test_language_driver () {\n-- \n2.43.GIT\n\n"},{"id":"489766","messageId":"CAPig+cRXtk0f=gMSkRka8mCFfT2=PKSBXMQGGhA3J_t=O_rpAA@mail.gmail.com","threadId":"61022","inReplyTo":"20240302095751.123138-3-karthik.188@gmail.com","subject":"Re: [PATCH 2/2] diff: add 'diff.wordDiff' config option","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2024-03-02T10:25:26Z","receivedAt":"2024-03-02T10:25:38Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sat, Mar 2, 2024 at 4:58 AM Karthik Nayak <karthik.188@gmail.com> wrote:\n> The git-diff(1) command supports the `--word-diff` which allows the\n> users to specify how to delimit word diffs. Provide this option also as\n> a config param 'diff.wordDiff'.\n>\n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n> diff --git a/diff.c b/diff.c\n> @@ -209,6 +210,23 @@ int git_config_rename(const char *var, const char *value)\n> +static int parse_word_diff_value(const char *value)\n> +{\n> +       if (!value)\n> +               return -1;\n> +       else if (!strcmp(value, \"plain\"))\n> +               return DIFF_WORDS_PLAIN;\n> +       else if (!strcmp(value, \"color\")) {\n> +               return DIFF_WORDS_COLOR;\n> +       }\n> +       else if (!strcmp(value, \"porcelain\"))\n> +               return DIFF_WORDS_PORCELAIN;\n> +       else if (!strcmp(value, \"none\"))\n> +               return DIFF_WORDS_NONE;\n> +\n> +       return -1;\n> +}\n\nWhy is one arm surrounded by curly braces when none of the others are?\n"},{"id":"489781","messageId":"xmqqedcszhty.fsf@gitster.g","threadId":"61022","inReplyTo":"20240302095751.123138-1-karthik.188@gmail.com","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-02T17:03:53Z","receivedAt":"2024-03-02T17:03:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> This patch series adds the diff.wordDiff config option. This mimics the\n> '--word-diff' option of `git-diff(1)`.\n\nIs it even be sensible to introduce this configuration variable in\nthe first place?  What would this do to users who set this variable\nand use third-party or their own scripts that run \"git diff\" under\nthe hood?\n\nThe usual answer is \"these tools should be using the low-level\nplumbing commands like diff-files, diff-index, and diff-tree\", so I\nam not worried about it too much myself, and the above is purely the\ndevil's advocate comment.\n\nHaving said that, running\n\n\t$ git grep -e 'git diff '\n\nin the collection of scripts I use [*] to work on this project, I am\nreminded that I may have to be a bit more conservative than I\ncurrently am about the risk of breaking scripts with the changes\nlike the one being proposed.\n\nThe proposed feature also may break those who use the git-prompt and\ndiff-highlight available in conrib/, even though I am not sure how\nbadly they would break, because I only looked at the lines given by\nthis command:\n\n\t$ git grep -e 'git diff ' -- \\*.sh ':!t/'\n\nand didn't check how the output from 'git diff' is used.\n\n\n[Footnote]\n\n * They can be seen in the 'todo' branch, if anybody is interested.\n"},{"id":"489784","messageId":"CAOLa=ZR6tN8eQhByaUobj3kS9wwYegsOQNT8cjZYA-YATJJt7w@mail.gmail.com","threadId":"61022","inReplyTo":"xmqqedcszhty.fsf@gitster.g","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-03-02T18:02:03Z","receivedAt":"2024-03-02T18:02:30Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Sat, Mar 2, 2024 at 6:03 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n> > This patch series adds the diff.wordDiff config option. This mimics the\n> > '--word-diff' option of `git-diff(1)`.\n>\n> Is it even be sensible to introduce this configuration variable in\n> the first place?  What would this do to users who set this variable\n> and use third-party or their own scripts that run \"git diff\" under\n> the hood?\n\nThis is definitely a good question to ask. I'm primarily not a user of this\noption, and this patch series was more of to start this discussion, based\non the request. I'm comfortable dropping the patch series too if it doesn't\nmake much sense.\n\n>\n> The usual answer is \"these tools should be using the low-level\n> plumbing commands like diff-files, diff-index, and diff-tree\", so I\n> am not worried about it too much myself, and the above is purely the\n> devil's advocate comment.\n>\n> Having said that, running\n>\n>         $ git grep -e 'git diff '\n>\n> in the collection of scripts I use [*] to work on this project, I am\n> reminded that I may have to be a bit more conservative than I\n> currently am about the risk of breaking scripts with the changes\n> like the one being proposed.\n>\n> The proposed feature also may break those who use the git-prompt and\n> diff-highlight available in conrib/, even though I am not sure how\n> badly they would break, because I only looked at the lines given by\n> this command:\n>\n>         $ git grep -e 'git diff ' -- \\*.sh ':!t/'\n>\n> and didn't check how the output from 'git diff' is used.\n>\n>\n> [Footnote]\n>\n>  * They can be seen in the 'todo' branch, if anybody is interested.\n\nHaving said that, wouldn't this cause a problem only if the config is set up?\nMeaning the user must explicitly set `diff.wordDiff` for their scripts\nto potentially\nbreak. In that sense, is it a breaking feature?\n"},{"id":"489785","messageId":"CAOLa=ZRsCaqT34JsAzaDrqF+gVQ1ZsLRQb3AbyU=qPgYAGO3WQ@mail.gmail.com","threadId":"61022","inReplyTo":"CAPig+cRXtk0f=gMSkRka8mCFfT2=PKSBXMQGGhA3J_t=O_rpAA@mail.gmail.com","subject":"Re: [PATCH 2/2] diff: add 'diff.wordDiff' config option","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2024-03-02T18:02:55Z","receivedAt":"2024-03-02T18:03:22Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Sat, Mar 2, 2024 at 11:25 AM Eric Sunshine <sunshine@sunshineco.com> wrote:\n>\n> On Sat, Mar 2, 2024 at 4:58 AM Karthik Nayak <karthik.188@gmail.com> wrote:\n> > The git-diff(1) command supports the `--word-diff` which allows the\n> > users to specify how to delimit word diffs. Provide this option also as\n> > a config param 'diff.wordDiff'.\n> >\n> > Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> > ---\n> > diff --git a/diff.c b/diff.c\n> > @@ -209,6 +210,23 @@ int git_config_rename(const char *var, const char *value)\n> > +static int parse_word_diff_value(const char *value)\n> > +{\n> > +       if (!value)\n> > +               return -1;\n> > +       else if (!strcmp(value, \"plain\"))\n> > +               return DIFF_WORDS_PLAIN;\n> > +       else if (!strcmp(value, \"color\")) {\n> > +               return DIFF_WORDS_COLOR;\n> > +       }\n> > +       else if (!strcmp(value, \"porcelain\"))\n> > +               return DIFF_WORDS_PORCELAIN;\n> > +       else if (!strcmp(value, \"none\"))\n> > +               return DIFF_WORDS_NONE;\n> > +\n> > +       return -1;\n> > +}\n>\n> Why is one arm surrounded by curly braces when none of the others are?\n\nSeems like I missed that one, if the patch series is being taken\nforward, I will fix\nit. Thanks\n"},{"id":"489792","messageId":"4884140.GXAFRqVoOG@cayenne","threadId":"61022","inReplyTo":"20240302095751.123138-3-karthik.188@gmail.com","subject":"Re: [PATCH 2/2] diff: add 'diff.wordDiff' config option","fromName":"Jean-Noël AVILA","fromEmail":"jn.avila@free.fr","sentAt":"2024-03-02T19:57:48Z","receivedAt":"2024-03-02T19:57:53Z","isPatch":true,"sender":{"key":"jn.avila@free.fr","avatar":"https://avatars.githubusercontent.com/u/156172?v=4"},"body":"Hello,\n\nOn Saturday, 2 March 2024 10:57:51 CET Karthik Nayak wrote:\n> The git-diff(1) command supports the `--word-diff` which allows the\n> users to specify how to delimit word diffs. Provide this option also as\n> a config param 'diff.wordDiff'.\n> \n> Signed-off-by: Karthik Nayak <karthik.188@gmail.com>\n> ---\n>  Documentation/config/diff.txt |  4 +++\n>  diff.c                        | 50 +++++++++++++++++++++++++++--------\n>  t/t4034-diff-words.sh         | 11 ++++++--\n>  3 files changed, 52 insertions(+), 13 deletions(-)\n> \n> diff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt\n> index bd5ae0c337..00459beee2 100644\n> --- a/Documentation/config/diff.txt\n> +++ b/Documentation/config/diff.txt\n> @@ -225,3 +225,7 @@ diff.colorMovedWS::\n>  \tWhen moved lines are colored using e.g. the `diff.colorMoved` \nsetting,\n>  \tthis option controls the `<mode>` how spaces are treated\n>  \tfor details of valid modes see '--color-moved-ws' in linkgit:git-\ndiff[1].\n> +\n> +diff.wordDiff::\n> +\tShow a word diff, using the `<mode>` to delimit changed words.\n> +\tFor details of valid modes see '--word-diff' in linkgit:git-diff[1].\n\nLet's enforce the new formatting rules: placeholders are _emphasized_  and \noptions are `verbatim`\n\n+\n +diff.wordDiff::\n +\tShow a word diff, using the _<mode>_ to delimit changed words.\n +\tFor details of valid modes see `--word-diff` in linkgit:git-diff[1].\n\n\n> diff --git a/diff.c b/diff.c\n> index e50def4538..050d83ef85 100644\n> --- a/diff.c\n> +++ b/diff.c\n> @@ -69,6 +69,7 @@ static int diff_dirstat_permille_default = 30;\n>  static struct diff_options default_diff_options;\n>  static long diff_algorithm;\n>  static unsigned ws_error_highlight_default = WSEH_NEW;\n> +static int diff_word_diff_default;\n>  \n>  static char diff_colors[][COLOR_MAXLEN] = {\n>  \tGIT_COLOR_RESET,\n> @@ -209,6 +210,23 @@ int git_config_rename(const char *var, const char \n*value)\n>  \treturn git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;\n>  }\n>  \n> +static int parse_word_diff_value(const char *value)\n> +{\n> +\tif (!value)\n> +\t\treturn -1;\n> +\telse if (!strcmp(value, \"plain\"))\n> +\t\treturn DIFF_WORDS_PLAIN;\n> +\telse if (!strcmp(value, \"color\")) {\n> +\t\treturn DIFF_WORDS_COLOR;\n> +\t}\n> +\telse if (!strcmp(value, \"porcelain\"))\n> +\t\treturn DIFF_WORDS_PORCELAIN;\n> +\telse if (!strcmp(value, \"none\"))\n> +\t\treturn DIFF_WORDS_NONE;\n> +\n> +\treturn -1;\n> +}\n> +\n>  long parse_algorithm_value(const char *value)\n>  {\n>  \tif (!value)\n> @@ -452,6 +470,18 @@ int git_diff_ui_config(const char *var, const char \n*value,\n>  \t\treturn 0;\n>  \t}\n>  \n> +\tif (!strcmp(var, \"diff.worddiff\")) {\n> +\t\tif (!value)\n> +\t\t\treturn config_error_nonbool(var);\n> +\t\tdiff_word_diff_default = parse_word_diff_value(value);\n> +\t\tif (diff_word_diff_default < 0)\n> +\t\t\treturn error(_(\"unknown value for config '%s': \n%s\"),\n\nThanks for reusing already an already existing translatable string.\n\n> +\t\t\t\t     var, value);\n> +\t\tif (diff_word_diff_default == DIFF_WORDS_COLOR)\n> +\t\t\tdiff_use_color_default = 1;\n> +\t\treturn 0;\n> +\t}\n> +\n>  \tif (git_color_config(var, value, cb) < 0)\n>  \t\treturn -1;\n>  \n> @@ -4724,6 +4754,7 @@ void repo_diff_setup(struct repository *r, struct \ndiff_options *options)\n>  \toptions->use_color = diff_use_color_default;\n>  \toptions->detect_rename = diff_detect_rename_default;\n>  \toptions->xdl_opts |= diff_algorithm;\n> +\toptions->word_diff |= diff_word_diff_default;\n>  \tif (diff_indent_heuristic)\n>  \t\tDIFF_XDL_SET(options, INDENT_HEURISTIC);\n>  \n> @@ -5504,21 +5535,18 @@ static int diff_opt_word_diff(const struct option \n*opt,\n>  \t\t\t      const char *arg, int unset)\n>  {\n>  \tstruct diff_options *options = opt->value;\n> +\tint value;\n>  \n>  \tBUG_ON_OPT_NEG(unset);\n> +\n>  \tif (arg) {\n> -\t\tif (!strcmp(arg, \"plain\"))\n> -\t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n> -\t\telse if (!strcmp(arg, \"color\")) {\n> -\t\t\toptions->use_color = 1;\n> -\t\t\toptions->word_diff = DIFF_WORDS_COLOR;\n> -\t\t}\n> -\t\telse if (!strcmp(arg, \"porcelain\"))\n> -\t\t\toptions->word_diff = DIFF_WORDS_PORCELAIN;\n> -\t\telse if (!strcmp(arg, \"none\"))\n> -\t\t\toptions->word_diff = DIFF_WORDS_NONE;\n> -\t\telse\n> +\t\tvalue = parse_word_diff_value(arg);\n> +\t\tif (value < 0)\n>  \t\t\treturn error(_(\"bad --word-diff argument: \n%s\"), arg);\n> +\t\tif (value == DIFF_WORDS_COLOR)\n> +\t\t\toptions->use_color = 1;\n> +\n> +\t\toptions->word_diff = value;\n>  \t} else {\n>  \t\tif (options->word_diff == DIFF_WORDS_NONE)\n>  \t\t\toptions->word_diff = DIFF_WORDS_PLAIN;\n> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\n> index 4f70aa6e9f..2cc391c339 100755\n> --- a/t/t4034-diff-words.sh\n> +++ b/t/t4034-diff-words.sh\n> @@ -56,12 +56,19 @@ diff_with_opts () {\n>  \tpost=$(git rev-parse --short $(git hash-object post)) &&\n>  \ttest_must_fail git diff --no-index \"$@\" pre post >output &&\n>  \ttest_decode_color <output >output.decrypted &&\n> -\tsed -e \"2s/index [^ ]*/index $pre..$post/\" expect >expected\n> +\tsed -e \"2s/index [^ ]*/index $pre..$post/\" expect >expected &&\n>  \ttest_cmp expected output.decrypted\n>  }\n>  \n>  word_diff () {\n> -\tdiff_with_opts \"--word-diff=$1\" $(echo \"$@\" | cut -d' ' -s -f 2-)\n> +\t# Capture the rest of the arguments to passthrough.\n> +\trest=$(echo \"$@\" | cut -d' ' -s -f 2-) &&\n> +\t# Test via the config route.\n> +\tgit config diff.wordDiff $1 &&\n> +\tdiff_with_opts $rest &&\n> +\tgit config --unset diff.wordDiff &&\n> +\t# Test via the command option route.\n> +\tdiff_with_opts \"--word-diff=$1\" $rest\n>  }\n>  \n>  test_language_driver () {\n> \n\nThanks\n\n\n"},{"id":"489793","messageId":"34bb249d-4a4d-4cc7-b737-bb18398341d0@app.fastmail.com","threadId":"61022","inReplyTo":"CAOLa=ZR6tN8eQhByaUobj3kS9wwYegsOQNT8cjZYA-YATJJt7w@mail.gmail.com","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Kristoffer Haugsbakk","fromEmail":"code@khaugsbakk.name","sentAt":"2024-03-02T19:57:38Z","receivedAt":"2024-03-02T19:58:11Z","isPatch":true,"sender":{"key":"code@khaugsbakk.name","avatar":"https://avatars.githubusercontent.com/u/2229597?v=4"},"body":"Hi\n\nOn Sat, Mar 2, 2024, at 19:02, Karthik Nayak wrote:\n> On Sat, Mar 2, 2024 at 6:03 PM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Karthik Nayak <karthik.188@gmail.com> writes:\n>>\n>> > This patch series adds the diff.wordDiff config option. This mimics the\n>> > '--word-diff' option of `git-diff(1)`.\n>>\n>> Is it even be sensible to introduce this configuration variable in\n>> the first place?  What would this do to users who set this variable\n>> and use third-party or their own scripts that run \"git diff\" under\n>> the hood?\n>\n> This is definitely a good question to ask. I'm primarily not a user of this\n> option, and this patch series was more of to start this discussion, based\n> on the request. I'm comfortable dropping the patch series too if it doesn't\n> make much sense.\n\nThis looks similar to the discussion from a [stash] topic:\n\n• Proposed introducing config variables which change how `git stash\n  push` and `git stash save` behave (what they save)\n• Concern about how that could break third-party scripts\n\nLike here it would be opt-in. But the user might have no idea what kind\nof scripts/programs that they use that happen to use git-stash(1).\n\n(That’s at least how I read the thread)\n\nI guess the concern might be worse for git-stash(1) since it seems very\nnatural to use that command in scripts in order to deal with a working\ntree that might be in a who-knows condition: just get these things out\nof the way so I can do what I want.\n\n🔗 [stash]: https://lore.kernel.org/git/xmqq34tnyhhf.fsf@gitster.g/\n\n-- \nKristoffer Haugsbakk\n"},{"id":"489802","messageId":"CAPx1GveaNR9ooWqE1VkAuFg5NO4Lwzx7bj-W1mWeHRg-rcg6+w@mail.gmail.com","threadId":"61022","inReplyTo":"34bb249d-4a4d-4cc7-b737-bb18398341d0@app.fastmail.com","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Chris Torek","fromEmail":"chris.torek@gmail.com","sentAt":"2024-03-03T07:23:03Z","receivedAt":"2024-03-03T07:23:17Z","isPatch":true,"sender":{"key":"chris.torek@gmail.com","avatar":"https://avatars.githubusercontent.com/u/16826774?v=4"},"body":"Continuing the digression a bit:\n\nOn Sat, Mar 2, 2024 at 11:58 AM Kristoffer Haugsbakk\n<code@khaugsbakk.name> wrote:\n> This looks similar to the discussion from a [stash] topic:\n>\n> • Proposed introducing config variables which change how `git stash\n>   push` and `git stash save` behave (what they save)\n> • Concern about how that could break third-party scripts\n[snippage]\n> 🔗 [stash]: https://lore.kernel.org/git/xmqq34tnyhhf.fsf@gitster.g/\n\nAs I see it, the general issue here is the tension between Git\ncommands that are used for scripting -- which ideally should\nalways be plumbing commands -- and those used by end-users.\n\nThis tension is relieved somewhat when there *are* separate\nplumbing commands, such as `git diff-index` and `git diff-tree`\nand so on, or `git rev-list` vs `git log`. Unfortunately there\nare some commands, including `git log` itself, that have options\nthat are missing from the roughly-equivalent plumbing command,\nand there are commands (such as `git stash` and `git status`)\nthat either do not have, or at one time lacked, plumbing command\nequivalents or options.\n\nThe `git status` command shows one way out of this problem:\nwe can *add* `--porcelain` options.  Perhaps every command (or\nevery non-plumbing-only one) should have `--porcelain[=<version>]`.\n\nThis doesn't fix the situation today, but provides an obvious\nfuture-proofing path.\n\nChris\n"},{"id":"489817","messageId":"xmqqle6zw6om.fsf@gitster.g","threadId":"61022","inReplyTo":"CAPx1GveaNR9ooWqE1VkAuFg5NO4Lwzx7bj-W1mWeHRg-rcg6+w@mail.gmail.com","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-03-03T17:45:13Z","receivedAt":"2024-03-03T17:45:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Torek <chris.torek@gmail.com> writes:\n\n> This tension is relieved somewhat when there *are* separate\n> plumbing commands, such as `git diff-index` and `git diff-tree`\n> and so on, or `git rev-list` vs `git log`. Unfortunately there\n> are some commands, including `git log` itself, that have options\n> that are missing from the roughly-equivalent plumbing command,\n> and there are commands (such as `git stash` and `git status`)\n> that either do not have, or at one time lacked, plumbing command\n> equivalents or options.\n\nYup.  It is my pet peeve that more and more contributors got lazy\nand tweaked only Porcelain commands, without bothering to improve\nplumbing commands to match, while adding more features during the\nlast decade.  Unfortunately there is no easy remedy after such sins\nhave been committed.  Once people start using `git log` in their\nscripts, it is way too late to tell them to update their scripts to\nuse `git log --porcelain`.  The fact that you need to tell them is\nan admission that you already broke their scripts.\n\n"},{"id":"491260","messageId":"3925ac99-bc05-4f8e-9a52-c22c13f6a4b5@schinagl.nl","threadId":"61022","inReplyTo":"xmqqedcszhty.fsf@gitster.g","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Olliver Schinagl","fromEmail":"oliver@schinagl.nl","sentAt":"2024-03-22T21:57:36Z","receivedAt":"2024-03-22T21:57:39Z","isPatch":true,"sender":{"key":"oliver@schinagl.nl","avatar":"https://gravatar.com/avatar/abb8ef5f9b23563b7703a4114da6f9bd6e7f6d7e8e0296677547b20ff7740c56?d=mp&s=160"},"body":"Hey list,\n\nOn 02-03-2024 18:03, Junio C Hamano wrote:\n> Karthik Nayak <karthik.188@gmail.com> writes:\n> \n>> This patch series adds the diff.wordDiff config option. This mimics the\n>> '--word-diff' option of `git-diff(1)`.\n> \n> Is it even be sensible to introduce this configuration variable in\n> the first place?\n\nOf course it is :p as a human, I crave it :p\n\nOn a slightly more serious note though, I always have to use an alias, \nor the command line option I cannot use `git diff` with this as default. \n From a human UX point of view, this is odd, and we have tons of \nconfiguration options to do exactly what is desired, without aliases.\n\nI suppose the deeper discussion would be, do we distinct between user \n(human) facing options and arguments, and machine facing options and \nargument (in theory, yes we do; in practice things get abused).\n\nGit is often blamed due to its horrible UX. I think the problem comes \nfrom the deeper issue mentioned above. Because things get abused, they \ncan no longer be touched, not even to improve UX for the human.\n\n> What would this do to users who set this variable\n> and use third-party or their own scripts that run \"git diff\" under\n> the hood?\n> \n> The usual answer is \"these tools should be using the low-level\n> plumbing commands like diff-files, diff-index, and diff-tree\", so I\n> am not worried about it too much myself, and the above is purely the\n> devil's advocate comment.\n> \n> Having said that, running\n> \n> \t$ git grep -e 'git diff '\n> \n> in the collection of scripts I use [*] to work on this project, I am\n> reminded that I may have to be a bit more conservative than I\n> currently am about the risk of breaking scripts with the changes\n> like the one being proposed.\n> \n> The proposed feature also may break those who use the git-prompt and\n> diff-highlight available in conrib/, even though I am not sure how\n> badly they would break, because I only looked at the lines given by\n> this command:\n> \n> \t$ git grep -e 'git diff ' -- \\*.sh ':!t/'\n> \n> and didn't check how the output from 'git diff' is used.\n> \n> \n> [Footnote]\n> \n>   * They can be seen in the 'todo' branch, if anybody is interested.\n"},{"id":"491261","messageId":"71f2d0e3-d3e5-4d6a-96d5-863a47b3ffc4@schinagl.nl","threadId":"61022","inReplyTo":"CAOLa=ZR6tN8eQhByaUobj3kS9wwYegsOQNT8cjZYA-YATJJt7w@mail.gmail.com","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Olliver Schinagl","fromEmail":"oliver@schinagl.nl","sentAt":"2024-03-22T21:59:09Z","receivedAt":"2024-03-22T21:59:10Z","isPatch":true,"sender":{"key":"oliver@schinagl.nl","avatar":"https://gravatar.com/avatar/abb8ef5f9b23563b7703a4114da6f9bd6e7f6d7e8e0296677547b20ff7740c56?d=mp&s=160"},"body":"On 02-03-2024 19:02, Karthik Nayak wrote:\n> On Sat, Mar 2, 2024 at 6:03 PM Junio C Hamano <gitster@pobox.com> wrote:\n>>\n>> Karthik Nayak <karthik.188@gmail.com> writes:\n>>\n>>> This patch series adds the diff.wordDiff config option. This mimics the\n>>> '--word-diff' option of `git-diff(1)`.\n>>\n>> Is it even be sensible to introduce this configuration variable in\n>> the first place?  What would this do to users who set this variable\n>> and use third-party or their own scripts that run \"git diff\" under\n>> the hood?\n> \n> This is definitely a good question to ask. I'm primarily not a user of this\n> option, and this patch series was more of to start this discussion, based\n> on the request. I'm comfortable dropping the patch series too if it doesn't\n> make much sense.\n\nAs a human user, I would very much like to see this feature :) It helps \nmuch to visually distinct things, but `git diff` sits way to deep in my \nmuscle memory to remember my alias. Also, we have a configuration system \nto set configuration options for many things.\n\nI wonder though, how many other configuration options we already have, \nthat potentially break 'random scripts' because the user has set it ...\n\n> \n>>\n>> The usual answer is \"these tools should be using the low-level\n>> plumbing commands like diff-files, diff-index, and diff-tree\", so I\n>> am not worried about it too much myself, and the above is purely the\n>> devil's advocate comment.\n>>\n>> Having said that, running\n>>\n>>          $ git grep -e 'git diff '\n>>\n>> in the collection of scripts I use [*] to work on this project, I am\n>> reminded that I may have to be a bit more conservative than I\n>> currently am about the risk of breaking scripts with the changes\n>> like the one being proposed.\n>>\n>> The proposed feature also may break those who use the git-prompt and\n>> diff-highlight available in conrib/, even though I am not sure how\n>> badly they would break, because I only looked at the lines given by\n>> this command:\n>>\n>>          $ git grep -e 'git diff ' -- \\*.sh ':!t/'\n>>\n>> and didn't check how the output from 'git diff' is used.\n>>\n>>\n>> [Footnote]\n>>\n>>   * They can be seen in the 'todo' branch, if anybody is interested.\n> \n> Having said that, wouldn't this cause a problem only if the config is set up?\n> Meaning the user must explicitly set `diff.wordDiff` for their scripts\n> to potentially\n> break. In that sense, is it a breaking feature?\n"},{"id":"491264","messageId":"0c8f5b5b-ed25-483e-901c-cd0850640697@schinagl.nl","threadId":"61022","inReplyTo":"CAPx1GveaNR9ooWqE1VkAuFg5NO4Lwzx7bj-W1mWeHRg-rcg6+w@mail.gmail.com","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Olliver Schinagl","fromEmail":"oliver@schinagl.nl","sentAt":"2024-03-22T22:05:48Z","receivedAt":"2024-03-22T22:05:50Z","isPatch":true,"sender":{"key":"oliver@schinagl.nl","avatar":"https://gravatar.com/avatar/abb8ef5f9b23563b7703a4114da6f9bd6e7f6d7e8e0296677547b20ff7740c56?d=mp&s=160"},"body":"On 03-03-2024 08:23, Chris Torek wrote:\n> Continuing the digression a bit:\n> \n> On Sat, Mar 2, 2024 at 11:58 AM Kristoffer Haugsbakk\n> <code@khaugsbakk.name> wrote:\n>> This looks similar to the discussion from a [stash] topic:\n>>\n>> • Proposed introducing config variables which change how `git stash\n>>    push` and `git stash save` behave (what they save)\n>> • Concern about how that could break third-party scripts\n> [snippage]\n>> 🔗 [stash]: https://lore.kernel.org/git/xmqq34tnyhhf.fsf@gitster.g/\n> \n> As I see it, the general issue here is the tension between Git\n> commands that are used for scripting -- which ideally should\n> always be plumbing commands -- and those used by end-users.\n> \n> This tension is relieved somewhat when there *are* separate\n> plumbing commands, such as `git diff-index` and `git diff-tree`\n> and so on, or `git rev-list` vs `git log`. Unfortunately there\n> are some commands, including `git log` itself, that have options\n> that are missing from the roughly-equivalent plumbing command,\n> and there are commands (such as `git stash` and `git status`)\n> that either do not have, or at one time lacked, plumbing command\n> equivalents or options.\n\nI think you are spot on; and as I mentioned earlier, who is git for? \nWhich commands are for whom. Human or machine. I suppose you can never \navoid commands being abused, but should we favor machine abuse for very \npoor UX for the human? I would say 'absolutly not' but up until now, \nthis has always been the case.\n\nMaybe it comes from Linus's strict 'never break userspace'. But I think \nthe situation is different. We want to enrich the user experience, we \nare constantly degrading it in favor of machines. Even though the \nmanuals and interwebs are full of 'don't use these commands in scripts, \nthey may break'. In that light, I would say 'lets break it in favor of UX :p\n\n> \n> The `git status` command shows one way out of this problem:\n> we can *add* `--porcelain` options.  Perhaps every command (or\n> every non-plumbing-only one) should have `--porcelain[=<version>]`.\n\nThat's a fair argument, and makes it clear, however, there's tons of \nscripts that probably don't do this right now.\n\n> \n> This doesn't fix the situation today, but provides an obvious\n> future-proofing path.\n> \n> Chris\n"},{"id":"491266","messageId":"6e035003-0c08-4e44-811c-27d2cebe9fa8@schinagl.nl","threadId":"61022","inReplyTo":"xmqqle6zw6om.fsf@gitster.g","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Olliver Schinagl","fromEmail":"oliver@schinagl.nl","sentAt":"2024-03-22T22:08:52Z","receivedAt":"2024-03-22T22:08:54Z","isPatch":true,"sender":{"key":"oliver@schinagl.nl","avatar":"https://gravatar.com/avatar/abb8ef5f9b23563b7703a4114da6f9bd6e7f6d7e8e0296677547b20ff7740c56?d=mp&s=160"},"body":"On 03-03-2024 18:45, Junio C Hamano wrote:\n> Chris Torek <chris.torek@gmail.com> writes:\n> \n>> This tension is relieved somewhat when there *are* separate\n>> plumbing commands, such as `git diff-index` and `git diff-tree`\n>> and so on, or `git rev-list` vs `git log`. Unfortunately there\n>> are some commands, including `git log` itself, that have options\n>> that are missing from the roughly-equivalent plumbing command,\n>> and there are commands (such as `git stash` and `git status`)\n>> that either do not have, or at one time lacked, plumbing command\n>> equivalents or options.\n> \n> Yup.  It is my pet peeve that more and more contributors got lazy\n> and tweaked only Porcelain commands, without bothering to improve\n> plumbing commands to match, while adding more features during the\n> last decade.  Unfortunately there is no easy remedy after such sins\n> have been committed.  Once people start using `git log` in their\n> scripts, it is way too late to tell them to update their scripts to\n> use `git log --porcelain`.  The fact that you need to tell them is\n> an admission that you already broke their scripts.\n> \nTo avoid this request from dieing quietly, I will ask (complain) again. \nWho's the client for. How important is the human UX?\n\nEven introducing a new cli, 'git-cli-for-humans' it will be abused again \nfor sure. So what's a good way forward? Personally, as I mentioned \nbefore, it's in the docs to not script around non-plumbing commands, \nwhich gives an opening to the admission. And why is admitting things a \nbad thing, when it improves things for the human? Even if it hurts.\n\nOne could argue 'git3 will break things! Human and machine control is \nsplit. Use --porcelain (or plumbing commands) in your scripts or expect \nbreakage from time to time. You have been warned!'\n\nWe do in the end want progress, do we not? :)\n\nOlliver\n"},{"id":"491531","messageId":"91f0848b917a15873a7b75b380619126@manjaro.org","threadId":"61022","inReplyTo":"6e035003-0c08-4e44-811c-27d2cebe9fa8@schinagl.nl","subject":"Re: [PATCH 0/2] Support diff.wordDiff config","fromName":"Dragan Simic","fromEmail":"dsimic@manjaro.org","sentAt":"2024-03-25T21:53:55Z","receivedAt":"2024-03-25T21:53:57Z","isPatch":true,"sender":{"key":"dsimic@manjaro.org","avatar":null},"body":"On 2024-03-22 23:08, Olliver Schinagl wrote:\n> On 03-03-2024 18:45, Junio C Hamano wrote:\n>> Chris Torek <chris.torek@gmail.com> writes:\n>> \n>>> This tension is relieved somewhat when there *are* separate\n>>> plumbing commands, such as `git diff-index` and `git diff-tree`\n>>> and so on, or `git rev-list` vs `git log`. Unfortunately there\n>>> are some commands, including `git log` itself, that have options\n>>> that are missing from the roughly-equivalent plumbing command,\n>>> and there are commands (such as `git stash` and `git status`)\n>>> that either do not have, or at one time lacked, plumbing command\n>>> equivalents or options.\n>> \n>> Yup.  It is my pet peeve that more and more contributors got lazy\n>> and tweaked only Porcelain commands, without bothering to improve\n>> plumbing commands to match, while adding more features during the\n>> last decade.  Unfortunately there is no easy remedy after such sins\n>> have been committed.  Once people start using `git log` in their\n>> scripts, it is way too late to tell them to update their scripts to\n>> use `git log --porcelain`.  The fact that you need to tell them is\n>> an admission that you already broke their scripts.\n>> \n> To avoid this request from dieing quietly, I will ask (complain)\n> again. Who's the client for. How important is the human UX?\n> \n> Even introducing a new cli, 'git-cli-for-humans' it will be abused\n> again for sure. So what's a good way forward? Personally, as I\n> mentioned before, it's in the docs to not script around non-plumbing\n> commands, which gives an opening to the admission. And why is\n> admitting things a bad thing, when it improves things for the human?\n> Even if it hurts.\n> \n> One could argue 'git3 will break things! Human and machine control is\n> split. Use --porcelain (or plumbing commands) in your scripts or\n> expect breakage from time to time. You have been warned!'\n> \n> We do in the end want progress, do we not? :)\n\nMaybe, but just maybe, a possible solution for introducing such new\nconfiguration options could be introduce a new category of configuration\noptions, which could be set in the user's git configuration only?\n\nThat way, a repository enabling some troublesome configuration option\nwouldn't cause the user's scripts to break.\n"}]}