{"thread":{"id":"57152","subject":"[PATCH] name-rev: deprecate --stdin in favor of --annotate-text","startedAt":"2021-12-26T04:28:36Z","lastAt":"2022-01-18T16:17:30Z","messageCount":43,"participants":["John Cai via GitGitGadget","Junio C Hamano","John Cai","Johannes Schindelin","Philip Oakley","Eric Sunshine","Phillip Wood","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"444963","messageId":"pull.1171.git.git.1640492910432.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":null,"subject":"[PATCH] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-12-26T04:28:30Z","receivedAt":"2021-12-26T04:28:36Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nIntroduce a --annotate-text that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can\nbe a confusing and misleading name, rename it to --annotate-text.\n\nThis change adds a warning to --stdin warning that it will be removed in\nthe future.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n    name-rev: deprecate --stdin in favor of --anotate-text\n    \n    Introduce a --anontate-text that is functionally equivalent of --stdin.\n    --stdin does not behave as --stdin in other subcommands, such as\n    pack-objects whereby it takes one argument per line. Since --stdin can\n    be a confusing and misleading name, the goal is to rename it to\n    --anotate-text.\n    \n    This is the first step in a process of eventually fully deprecating\n    --stdin. This change also adds a warning to --stdin warning that it will\n    be removed in the future.\n    \n    See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for\n    discussion.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v1\nPull-Request: https://github.com/git/git/pull/1171\n\n Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++-\n builtin/name-rev.c             | 17 +++++++++++++----\n 2 files changed, 41 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 5cb0eb0855f..64d59c6ee1a 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -43,10 +43,37 @@ OPTIONS\n \tList all commits reachable from all refs\n \n --stdin::\n+\tThis option is deprecated in favor of 'git name-rev --annotate-text'.\n+\tThey are functionally equivalent.\n+\n+--annotate-text::\n \tTransform stdin by substituting all the 40-character SHA-1\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n-\taltogether.  Intended for the scripter's use.\n+\taltogether.\n+\n+\tFor example:\n++\n+----------\n+$ cat sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --annotate-text < sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n+(master),\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --name-only --annotate-text < sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name is master,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+----------\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 27f60153a6c..73b244a5aac 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = OBJECT_ARRAY_INIT;\n-\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n+\tint all = 0, annotate_text = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n \tstruct option opts[] = {\n \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n@@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n+\t\tOPT_BOOL(0, \"annotate-text\", &annotate_text, N_(\"annotate text text from stdin\")),\n \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n \t\tOPT_BOOL(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n@@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tinit_commit_rev_name(&rev_names);\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n-\tif (all + transform_stdin + !!argc > 1) {\n+\n+\tif (transform_stdin) {\n+\t\twarning(\"--stdin is deprecated. Please use --annotate-text instead, \"\n+\t\t\t\t\t\"which is functionally equivalent.\\n\"\n+\t\t\t\t\t\"This option will be removed in a future release.\");\n+\t\tannotate_text = 1;\n+\t}\n+\n+\tif (all + annotate_text + !!argc > 1) {\n \t\terror(\"Specify either a list, or --all, not both!\");\n \t\tusage_with_options(name_rev_usage, opts);\n \t}\n-\tif (all || transform_stdin)\n+\tif (all || annotate_text)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n@@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tfor_each_ref(name_ref, &data);\n \tname_tips();\n \n-\tif (transform_stdin) {\n+\tif (annotate_text) {\n \t\tchar buffer[2048];\n \n \t\twhile (!feof(stdin)) {\n\nbase-commit: 2ae0a9cb8298185a94e5998086f380a355dd8907\n-- \ngitgitgadget\n"},{"id":"445013","messageId":"xmqqpmphx1yh.fsf@gitster.g","threadId":"57152","inReplyTo":"pull.1171.git.git.1640492910432.gitgitgadget@gmail.com","subject":"Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-12-27T19:49:42Z","receivedAt":"2021-12-27T19:49:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\nAs name-rev is Dscho's brainchild, I think it is benefitial to ask input\nfrom him, so I added an address to the CC: list.\n\n> From: John Cai <johncai86@gmail.com>\n>\n> Introduce a --annotate-text that is functionally equivalent of --stdin.\n> --stdin does not behave as --stdin in other subcommands, such as\n> pack-objects whereby it takes one argument per line. Since --stdin can\n> be a confusing and misleading name, rename it to --annotate-text.\n>\n> This change adds a warning to --stdin warning that it will be removed in\n> the future.\n\nI know I've suggested the name, but 'text' in --annotate-text is a\nlow value word in an option name where every byte is precious.\n\"Annotate\" is very good to convey what is done to the object of the\nverb, but \"text\" stresses the wrong thing (we do not annotate\nbinary,o we annotate text) without saying where the text comes from\n(i.e.  standard input).  Perhaps \"--annotate-stdin\" would be a much\nbetter name.\n\nI agree that letting \"--stdin\" to deviate so much from an emulation\nof \"xargs git name-rev\" was indeed a mistake that caused the\nconfusion that led to the other thread.  If the mode had a better\nname from the day 1, the thread would have been avoided.\n\nWhat I am not sure about is how much this transition would hurt\nexisting users and scripts.\n\n> +\tFor example:\n> ++\n> +----------\n> +$ cat sample.txt\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +$ git name-rev --annotate-text < sample.txt\n\nLose SP between the redirection operator '<' and its file 'sample.txt'.\n\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n> +(master),\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +$ git name-rev --name-only --annotate-text < sample.txt\n\nDitto.\n\n> +\tif (transform_stdin) {\n> +\t\twarning(\"--stdin is deprecated. Please use --annotate-text instead, \"\n> +\t\t\t\t\t\"which is functionally equivalent.\\n\"\n> +\t\t\t\t\t\"This option will be removed in a future release.\");\n> +\t\tannotate_text = 1;\n\nI guess that is sensible.  To squelch the warning, they can switch\nto the new option.\n\n> +\t}\n> +\n> +\tif (all + annotate_text + !!argc > 1) {\n>  \t\terror(\"Specify either a list, or --all, not both!\");\n>  \t\tusage_with_options(name_rev_usage, opts);\n>  \t}\n> -\tif (all || transform_stdin)\n> +\tif (all || annotate_text)\n>  \t\tcutoff = 0;\n>  \n>  \tfor (; argc; argc--, argv++) {\n> @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tfor_each_ref(name_ref, &data);\n>  \tname_tips();\n>  \n> -\tif (transform_stdin) {\n> +\tif (annotate_text) {\n>  \t\tchar buffer[2048];\n>  \n>  \t\twhile (!feof(stdin)) {\n\nNot a suggestion to change anything in this patch, but just an\nobservation.\n\n - If the mode is useful enough for many users, certainly somebody\n   would have rewritten this loop to lift the line-length limit, but\n   nobody noticed and complained about this 2k limit for the past 17\n   years.  I am not sure if that is an indication that nobody uses\n   the option in its current form.\n\n - A low hanging fruit, if we do not go full strbuf_getline(), at\n   least we should narrow the scope of buffer[] array.\n\n"},{"id":"445051","messageId":"028044FB-5CFC-49DF-BCFC-51AF1806619A@gmail.com","threadId":"57152","inReplyTo":"xmqqpmphx1yh.fsf@gitster.g","subject":"Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"John Cai","fromEmail":"johncai86@gmail.com","sentAt":"2021-12-28T05:13:18Z","receivedAt":"2021-12-28T05:13:21Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"\n\n> On Dec 27, 2021, at 11:49 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> \"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n> \n> As name-rev is Dscho's brainchild, I think it is benefitial to ask input\n> from him, so I added an address to the CC: list.\n> \n>> From: John Cai <johncai86@gmail.com>\n>> \n>> Introduce a --annotate-text that is functionally equivalent of --stdin.\n>> --stdin does not behave as --stdin in other subcommands, such as\n>> pack-objects whereby it takes one argument per line. Since --stdin can\n>> be a confusing and misleading name, rename it to --annotate-text.\n>> \n>> This change adds a warning to --stdin warning that it will be removed in\n>> the future.\n> \n> I know I've suggested the name, but 'text' in --annotate-text is a\n> low value word in an option name where every byte is precious.\n> \"Annotate\" is very good to convey what is done to the object of the\n> verb, but \"text\" stresses the wrong thing (we do not annotate\n> binary,o we annotate text) without saying where the text comes from\n> (i.e.  standard input).  Perhaps \"--annotate-stdin\" would be a much\n> better name.\n> \n> I agree that letting \"--stdin\" to deviate so much from an emulation\n> of \"xargs git name-rev\" was indeed a mistake that caused the\n> confusion that led to the other thread.  If the mode had a better\n> name from the day 1, the thread would have been avoided.\n> \n> What I am not sure about is how much this transition would hurt\n> existing users and scripts.\n> \n>> +\tFor example:\n>> ++\n>> +----------\n>> +$ cat sample.txt\n>> +\n>> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n>> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n>> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n>> +\n>> +$ git name-rev --annotate-text < sample.txt\n> \n> Lose SP between the redirection operator '<' and its file 'sample.txt'.\n> \n>> +\n>> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n>> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n>> +(master),\n>> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n>> +\n>> +$ git name-rev --name-only --annotate-text < sample.txt\n> \n> Ditto.\n> \n>> +\tif (transform_stdin) {\n>> +\t\twarning(\"--stdin is deprecated. Please use --annotate-text instead, \"\n>> +\t\t\t\t\t\"which is functionally equivalent.\\n\"\n>> +\t\t\t\t\t\"This option will be removed in a future release.\");\n>> +\t\tannotate_text = 1;\n> \n> I guess that is sensible.  To squelch the warning, they can switch\n> to the new option.\n> \n>> +\t}\n>> +\n>> +\tif (all + annotate_text + !!argc > 1) {\n>> \t\terror(\"Specify either a list, or --all, not both!\");\n>> \t\tusage_with_options(name_rev_usage, opts);\n>> \t}\n>> -\tif (all || transform_stdin)\n>> +\tif (all || annotate_text)\n>> \t\tcutoff = 0;\n>> \n>> \tfor (; argc; argc--, argv++) {\n>> @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>> \tfor_each_ref(name_ref, &data);\n>> \tname_tips();\n>> \n>> -\tif (transform_stdin) {\n>> +\tif (annotate_text) {\n>> \t\tchar buffer[2048];\n>> \n>> \t\twhile (!feof(stdin)) {\n> \n> Not a suggestion to change anything in this patch, but just an\n> observation.\n> \n> - If the mode is useful enough for many users, certainly somebody\n>   would have rewritten this loop to lift the line-length limit, but\n>   nobody noticed and complained about this 2k limit for the past 17\n>   years.  I am not sure if that is an indication that nobody uses\n>   the option in its current form.\n\nWould this also mean that deprecating --stdin wouldn’t be **too** disruptive to existing users and scripts?\n\n> - A low hanging fruit, if we do not go full strbuf_getline(), at\n>   least we should narrow the scope of buffer[] array.\n> \n\n"},{"id":"445165","messageId":"pull.1171.v2.git.git.1640759021.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.git.git.1640492910432.gitgitgadget@gmail.com","subject":"[PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-12-29T06:23:39Z","receivedAt":"2021-12-29T06:23:45Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Introduce a --anontate-text that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can be a\nconfusing and misleading name, the goal is to rename it to --anotate-text.\n\nThis is the first step in a process of eventually fully deprecating --stdin.\nThis change also adds a warning to --stdin warning that it will be removed\nin the future.\n\nSee https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion.\n\nchanges since v1 (thanks to Junio's review):\n\n * s/annotate_text/annotate_stdin\n * add a commit to replace the 2048 size buffer with a strbuf and use\n   strbuf_getwholeline to get lines from stdin\n * fixed formatting bugs in documentation udpates.\n\nJohn Cai (2):\n  name-rev: deprecate --stdin in favor of --annotate-text\n  name-rev.c: use strbuf_getline instead of limited size buffer\n\n Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++-\n builtin/name-rev.c             | 27 +++++++++++++++++----------\n 2 files changed, 45 insertions(+), 11 deletions(-)\n\n\nbase-commit: 55b058a8bbcc54bd93c733035c995abc7967e539\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v2\nPull-Request: https://github.com/git/git/pull/1171\n\nRange-diff vs v1:\n\n 1:  b83d9422d0c ! 1:  e8063284b4d name-rev: deprecate --stdin in favor of --annotate-text\n     @@ Documentation/git-name-rev.txt: OPTIONS\n       \tList all commits reachable from all refs\n       \n       --stdin::\n     -+\tThis option is deprecated in favor of 'git name-rev --annotate-text'.\n     ++\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n      +\tThey are functionally equivalent.\n      +\n     -+--annotate-text::\n     ++--annotate-stdin::\n       \tTransform stdin by substituting all the 40-character SHA-1\n       \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n       \t--name-only, substitute with \"$rev_name\", omitting $hex\n     @@ Documentation/git-name-rev.txt: OPTIONS\n      +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n      +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +\n     -+$ git name-rev --annotate-text < sample.txt\n     ++$ git name-rev --annotate-stdin <sample.txt\n      +\n      +An abbreviated revision 2ae0a9cb82 will not be substituted.\n      +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n      +(master),\n      +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +\n     -+$ git name-rev --name-only --annotate-text < sample.txt\n     ++$ git name-rev --name-only --annotate-stdin <sample.txt\n      +\n      +An abbreviated revision 2ae0a9cb82 will not be substituted.\n      +The full name is master,\n     @@ builtin/name-rev.c: static void name_rev_line(char *p, struct name_ref_data *dat\n       {\n       \tstruct object_array revs = OBJECT_ARRAY_INIT;\n      -\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n     -+\tint all = 0, annotate_text = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n     ++\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n       \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n       \tstruct option opts[] = {\n       \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n     @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr\n       \t\tOPT_GROUP(\"\"),\n       \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n       \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n     -+\t\tOPT_BOOL(0, \"annotate-text\", &annotate_text, N_(\"annotate text text from stdin\")),\n     ++\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n       \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n       \t\tOPT_BOOL(0, \"always\",     &always,\n       \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n     @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr\n      -\tif (all + transform_stdin + !!argc > 1) {\n      +\n      +\tif (transform_stdin) {\n     -+\t\twarning(\"--stdin is deprecated. Please use --annotate-text instead, \"\n     ++\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n      +\t\t\t\t\t\"which is functionally equivalent.\\n\"\n      +\t\t\t\t\t\"This option will be removed in a future release.\");\n     -+\t\tannotate_text = 1;\n     ++\t\tannotate_stdin = 1;\n      +\t}\n      +\n     -+\tif (all + annotate_text + !!argc > 1) {\n     ++\tif (all + annotate_stdin + !!argc > 1) {\n       \t\terror(\"Specify either a list, or --all, not both!\");\n       \t\tusage_with_options(name_rev_usage, opts);\n       \t}\n      -\tif (all || transform_stdin)\n     -+\tif (all || annotate_text)\n     ++\tif (all || annotate_stdin)\n       \t\tcutoff = 0;\n       \n       \tfor (; argc; argc--, argv++) {\n     @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr\n       \tname_tips();\n       \n      -\tif (transform_stdin) {\n     -+\tif (annotate_text) {\n     - \t\tchar buffer[2048];\n     +-\t\tchar buffer[2048];\n     ++\tif (annotate_stdin) {\n     ++\t\tstruct strbuf sb = STRBUF_INIT;\n       \n       \t\twhile (!feof(stdin)) {\n     + \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n -:  ----------- > 2:  4636e27f53e name-rev.c: use strbuf_getline instead of limited size buffer\n\n-- \ngitgitgadget\n"},{"id":"445166","messageId":"e8063284b4d0d410d1ee8337c60f5ce3b48efb11.1640759021.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v2.git.git.1640759021.gitgitgadget@gmail.com","subject":"[PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-12-29T06:23:40Z","receivedAt":"2021-12-29T06:23:47Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nIntroduce a --annotate-text that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can\nbe a confusing and misleading name, rename it to --annotate-text.\n\nThis change adds a warning to --stdin warning that it will be removed in\nthe future.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++-\n builtin/name-rev.c             | 19 ++++++++++++++-----\n 2 files changed, 42 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 5cb0eb0855f..ee11b2ca9e7 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -43,10 +43,37 @@ OPTIONS\n \tList all commits reachable from all refs\n \n --stdin::\n+\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n+\tThey are functionally equivalent.\n+\n+--annotate-stdin::\n \tTransform stdin by substituting all the 40-character SHA-1\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n-\taltogether.  Intended for the scripter's use.\n+\taltogether.\n+\n+\tFor example:\n++\n+----------\n+$ cat sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n+(master),\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --name-only --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name is master,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+----------\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 27f60153a6c..21370afdaf9 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = OBJECT_ARRAY_INIT;\n-\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n+\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n \tstruct option opts[] = {\n \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n@@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n+\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n \t\tOPT_BOOL(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n@@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tinit_commit_rev_name(&rev_names);\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n-\tif (all + transform_stdin + !!argc > 1) {\n+\n+\tif (transform_stdin) {\n+\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n+\t\t\t\t\t\"which is functionally equivalent.\\n\"\n+\t\t\t\t\t\"This option will be removed in a future release.\");\n+\t\tannotate_stdin = 1;\n+\t}\n+\n+\tif (all + annotate_stdin + !!argc > 1) {\n \t\terror(\"Specify either a list, or --all, not both!\");\n \t\tusage_with_options(name_rev_usage, opts);\n \t}\n-\tif (all || transform_stdin)\n+\tif (all || annotate_stdin)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n@@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tfor_each_ref(name_ref, &data);\n \tname_tips();\n \n-\tif (transform_stdin) {\n-\t\tchar buffer[2048];\n+\tif (annotate_stdin) {\n+\t\tstruct strbuf sb = STRBUF_INIT;\n \n \t\twhile (!feof(stdin)) {\n \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n-- \ngitgitgadget\n\n"},{"id":"445167","messageId":"4636e27f53e0e6ac2c11b227d4dac32d975c82f4.1640759021.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v2.git.git.1640759021.gitgitgadget@gmail.com","subject":"[PATCH v2 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2021-12-29T06:23:41Z","receivedAt":"2021-12-29T06:23:50Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nUsing a buffer limited to 2048 is unnecessarily limiting. Switch to\nusing a string buffer to read in stdin for annotation.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n builtin/name-rev.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 21370afdaf9..85993bc2b38 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -625,12 +625,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tif (annotate_stdin) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\twhile (!feof(stdin)) {\n-\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n-\t\t\tif (!p)\n-\t\t\t\tbreak;\n-\t\t\tname_rev_line(p, &data);\n+\t\twhile (strbuf_getwholeline(&sb, stdin, '\\n') != EOF) {\n+\t\t\tname_rev_line(sb.buf, &data);\n \t\t}\n+\t\tstrbuf_release(&sb);\n \t} else if (all) {\n \t\tint i, max;\n \n-- \ngitgitgadget\n"},{"id":"445247","messageId":"xmqqsfu9oh34.fsf@gitster.g","threadId":"57152","inReplyTo":"e8063284b4d0d410d1ee8337c60f5ce3b48efb11.1640759021.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-12-30T22:36:47Z","receivedAt":"2021-12-30T22:36:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: John Cai <johncai86@gmail.com>\n>\n> Introduce a --annotate-text that is functionally equivalent of --stdin.\n> --stdin does not behave as --stdin in other subcommands, such as\n> pack-objects whereby it takes one argument per line. Since --stdin can\n> be a confusing and misleading name, rename it to --annotate-text.\n>\n> This change adds a warning to --stdin warning that it will be removed in\n> the future.\n\nThe above (including the title) uses --annotate-TEXT; the\ndocumentation and the code seems to use --annotate-STDIN.\n\n>\n> Signed-off-by: \"John Cai\" <johncai86@gmail.com>\n> ---\n>  Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++-\n>  builtin/name-rev.c             | 19 ++++++++++++++-----\n>  2 files changed, 42 insertions(+), 6 deletions(-)\n\nWe probably would want to fix existing tests that use --stdin for\nits originally intended purpose to use its new spelling instead, and\na single new test to ensure that use of --stdin gives a warning as\nexpected.\n\n> @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tfor_each_ref(name_ref, &data);\n>  \tname_tips();\n>  \n> -\tif (transform_stdin) {\n> -\t\tchar buffer[2048];\n> +\tif (annotate_stdin) {\n> +\t\tstruct strbuf sb = STRBUF_INIT;\n>  \n>  \t\twhile (!feof(stdin)) {\n>  \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n\nThis block probably would not compile well.\n"},{"id":"445283","messageId":"xmqq8rw1mbo5.fsf@gitster.g","threadId":"57152","inReplyTo":"028044FB-5CFC-49DF-BCFC-51AF1806619A@gmail.com","subject":"Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-12-31T08:16:42Z","receivedAt":"2021-12-31T08:16:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Cai <johncai86@gmail.com> writes:\n\n>> Not a suggestion to change anything in this patch, but just an\n>> observation.\n>> \n>> - If the mode is useful enough for many users, certainly somebody\n>>   would have rewritten this loop to lift the line-length limit, but\n>>   nobody noticed and complained about this 2k limit for the past 17\n>>   years.  I am not sure if that is an indication that nobody uses\n>>   the option in its current form.\n>\n> Would this also mean that deprecating --stdin wouldn’t be **too**\n> disruptive to existing users and scripts?\n\nThat probably is a lot of wishful thinking.  Most likely, it is an\nindication that most text input files that go into the command have\nno overly long lines ;-)  Loss of or change in behaviour of the\ncommand would be disruptive for the users who are content with the\nlimitation that they cannot feed lines wider than 2k.\n\n\n"},{"id":"445321","messageId":"nycvar.QRO.7.76.6.2201012357040.7076@tvgsbejvaqbjf.bet","threadId":"57152","inReplyTo":"xmqqpmphx1yh.fsf@gitster.g","subject":"Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2022-01-01T22:59:04Z","receivedAt":"2022-01-01T22:59:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Junio,\n\nOn Mon, 27 Dec 2021, Junio C Hamano wrote:\n\n> \"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> As name-rev is Dscho's brainchild, I think it is benefitial to ask input\n> from him, so I added an address to the CC: list.\n\nThank you!\n\n> > From: John Cai <johncai86@gmail.com>\n> >\n> > Introduce a --annotate-text that is functionally equivalent of --stdin.\n> > --stdin does not behave as --stdin in other subcommands, such as\n> > pack-objects whereby it takes one argument per line. Since --stdin can\n> > be a confusing and misleading name, rename it to --annotate-text.\n> >\n> > This change adds a warning to --stdin warning that it will be removed in\n> > the future.\n>\n> I know I've suggested the name, but 'text' in --annotate-text is a\n> low value word in an option name where every byte is precious.\n> \"Annotate\" is very good to convey what is done to the object of the\n> verb, but \"text\" stresses the wrong thing (we do not annotate\n> binary,o we annotate text) without saying where the text comes from\n> (i.e.  standard input).  Perhaps \"--annotate-stdin\" would be a much\n> better name.\n\nI agree that `--annotate-stdin` is better, especially since people who\nmight look for a replacement for `--stdin` in the documentation are much\nmore likely to find what they're looking for.\n\nIn addition to this, I also agree with Junio on the deprecation needing to\nbe done carefully.\n\nCiao,\nDscho\n"},{"id":"445352","messageId":"pull.1171.v3.git.git.1641221261.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v2.git.git.1640759021.gitgitgadget@gmail.com","subject":"[PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-03T14:47:39Z","receivedAt":"2022-01-03T14:47:45Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can be a\nconfusing and misleading name, the goal is to rename it to --anotate-stdin.\n\nThis is the first step in a process of eventually fully deprecating --stdin.\nThis change also adds a warning to --stdin warning that it will be removed\nin the future.\n\nSee https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion.\n\nchanges since v2:\n\n * updated title and cover letter with --annotate-stdin\n * s/--stdin/--annotate-stdin in tests that call name-rev\n * added a test to ensure correct warning is shown when --stdin is passed\n\nJohn Cai (2):\n  name-rev: deprecate --stdin in favor of --annotate-text\n  name-rev.c: use strbuf_getline instead of limited size buffer\n\n Documentation/git-name-rev.txt       | 29 +++++++++++++++++++++++++++-\n builtin/name-rev.c                   | 27 ++++++++++++++++----------\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++-------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 70 insertions(+), 30 deletions(-)\n\n\nbase-commit: c8b2ade48c204690119936ada89cd938c476c5c2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v3\nPull-Request: https://github.com/git/git/pull/1171\n\nRange-diff vs v2:\n\n 1:  e8063284b4d ! 1:  55ec2a5fa3e name-rev: deprecate --stdin in favor of --annotate-text\n     @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr\n       \n       \t\twhile (!feof(stdin)) {\n       \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n     +\n     + ## t/t3412-rebase-root.sh ##\n     +@@ t/t3412-rebase-root.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n     + \n     + log_with_names () {\n     + \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n     +-\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n     ++\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n     + }\n     + \n     + \n     +\n     + ## t/t4202-log.sh ##\n     +@@ t/t4202-log.sh: EOF\n     + \n     + test_expect_success 'log --graph with full output' '\n     + \tgit log --graph --date-order --pretty=short |\n     +-\t\tgit name-rev --name-only --stdin |\n     ++\t\tgit name-rev --name-only --annotate-stdin |\n     + \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n     + \ttest_cmp expect actual\n     + '\n     +\n     + ## t/t6007-rev-list-cherry-pick-file.sh ##\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + \n     + test_expect_success '--left-right' '\n     + \tgit rev-list --left-right B...C > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + \n     + test_expect_success '--cherry-pick bar does not come up empty' '\n     + \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     + \n     + test_expect_success 'bar does not come up empty' '\n     + \tgit rev-list --left-right B...C -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + \n     + test_expect_success '--cherry-pick bar does not come up empty (II)' '\n     + \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     + \n     + test_expect_success 'name-rev multiple --refs combine inclusive' '\n     + \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n     + \t\t<actual >actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + test_expect_success 'name-rev --refs excludes non-matched patterns' '\n     + \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n     + \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n     + \t\t<actual >actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + test_expect_success 'name-rev --exclude excludes matched patterns' '\n     + \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n     + \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n     + \t\t<actual >actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     + \n     + test_expect_success 'name-rev --no-refs clears the refs list' '\n     + \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n     + \t\t<expect >actual &&\n     + \ttest_cmp expect actual\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + \n     + test_expect_success '--cherry-mark' '\n     + \tgit rev-list --cherry-mark F...E -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + \n     + test_expect_success '--cherry-mark --left-right' '\n     + \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + \n     + test_expect_success '--cherry-pick --right-only' '\n     + \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     + \n     + test_expect_success '--cherry-pick --left-only' '\n     + \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF\n     + \n     + test_expect_success '--cherry' '\n     + \tgit rev-list --cherry F...E -- bar > actual &&\n     +-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n     ++\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n     + \t\t< actual > actual.named &&\n     + \ttest_cmp expect actual.named\n     + '\n     +\n     + ## t/t6012-rev-list-simplify.sh ##\n     +@@ t/t6012-rev-list-simplify.sh: note () {\n     + }\n     + \n     + unnote () {\n     +-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n     ++\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n     + }\n     + \n     + #\n     +\n     + ## t/t6111-rev-list-treesame.sh ##\n     +@@ t/t6111-rev-list-treesame.sh: note () {\n     + }\n     + \n     + unnote () {\n     +-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n     ++\tgit name-rev --tags --annotate-stdin | \\\n     ++\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n     + }\n     + \n     + test_expect_success setup '\n     +\n     + ## t/t6120-describe.sh ##\n     +@@ t/t6120-describe.sh: test_expect_success 'name-rev --all' '\n     + \ttest_cmp expect actual\n     + '\n     + \n     +-test_expect_success 'name-rev --stdin' '\n     ++test_expect_success 'name-rev --annotate-stdin' '\n     + \t>expect.unsorted &&\n     + \tfor rev in $(git rev-list --all)\n     + \tdo\n     +@@ t/t6120-describe.sh: test_expect_success 'name-rev --stdin' '\n     + \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n     + \tdone &&\n     + \tsort <expect.unsorted >expect &&\n     +-\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n     ++\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n     + \tsort <actual.unsorted >actual &&\n     + \ttest_cmp expect actual\n     + '\n     + \n     ++test_expect_success 'name-rev --stdin deprecated' \"\n     ++\tgit rev-list --all | git name-rev --stdin 2>actual &&\n     ++\tgrep -E 'warning: --stdin is deprecated' actual\n     ++\"\n     ++\n     + test_expect_success 'describe --contains with the exact tags' '\n     + \techo \"A^0\" >expect &&\n     + \ttag_object=$(git rev-parse refs/tags/A) &&\n 2:  4636e27f53e = 2:  e4bd09ccf75 name-rev.c: use strbuf_getline instead of limited size buffer\n\n-- \ngitgitgadget\n"},{"id":"445353","messageId":"55ec2a5fa3e748b7e5f9ef871214563ba2b28adf.1641221261.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v3.git.git.1641221261.gitgitgadget@gmail.com","subject":"[PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-03T14:47:40Z","receivedAt":"2022-01-03T14:47:47Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nIntroduce a --annotate-text that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can\nbe a confusing and misleading name, rename it to --annotate-text.\n\nThis change adds a warning to --stdin warning that it will be removed in\nthe future.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n Documentation/git-name-rev.txt       | 29 +++++++++++++++++++++++++++-\n builtin/name-rev.c                   | 19 +++++++++++++-----\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++-------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 67 insertions(+), 25 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 5cb0eb0855f..ee11b2ca9e7 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -43,10 +43,37 @@ OPTIONS\n \tList all commits reachable from all refs\n \n --stdin::\n+\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n+\tThey are functionally equivalent.\n+\n+--annotate-stdin::\n \tTransform stdin by substituting all the 40-character SHA-1\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n-\taltogether.  Intended for the scripter's use.\n+\taltogether.\n+\n+\tFor example:\n++\n+----------\n+$ cat sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n+(master),\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --name-only --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name is master,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+----------\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 27f60153a6c..21370afdaf9 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = OBJECT_ARRAY_INIT;\n-\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n+\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n \tstruct option opts[] = {\n \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n@@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n+\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n \t\tOPT_BOOL(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n@@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tinit_commit_rev_name(&rev_names);\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n-\tif (all + transform_stdin + !!argc > 1) {\n+\n+\tif (transform_stdin) {\n+\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n+\t\t\t\t\t\"which is functionally equivalent.\\n\"\n+\t\t\t\t\t\"This option will be removed in a future release.\");\n+\t\tannotate_stdin = 1;\n+\t}\n+\n+\tif (all + annotate_stdin + !!argc > 1) {\n \t\terror(\"Specify either a list, or --all, not both!\");\n \t\tusage_with_options(name_rev_usage, opts);\n \t}\n-\tif (all || transform_stdin)\n+\tif (all || annotate_stdin)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n@@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tfor_each_ref(name_ref, &data);\n \tname_tips();\n \n-\tif (transform_stdin) {\n-\t\tchar buffer[2048];\n+\tif (annotate_stdin) {\n+\t\tstruct strbuf sb = STRBUF_INIT;\n \n \t\twhile (!feof(stdin)) {\n \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\ndiff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\nindex 19c6f4acbf6..1e9f7833dd6 100755\n--- a/t/t3412-rebase-root.sh\n+++ b/t/t3412-rebase-root.sh\n@@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n log_with_names () {\n \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n-\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n+\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n }\n \n \ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 50495598619..dc884107de4 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -659,7 +659,7 @@ EOF\n \n test_expect_success 'log --graph with full output' '\n \tgit log --graph --date-order --pretty=short |\n-\t\tgit name-rev --name-only --stdin |\n+\t\tgit name-rev --name-only --annotate-stdin |\n \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex aebe4b69e13..6f3e5439771 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -58,7 +58,7 @@ EOF\n \n test_expect_success '--left-right' '\n \tgit rev-list --left-right B...C > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -78,14 +78,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty' '\n \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'bar does not come up empty' '\n \tgit rev-list --left-right B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -97,14 +97,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty (II)' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev multiple --refs combine inclusive' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -116,7 +116,7 @@ EOF\n test_expect_success 'name-rev --refs excludes non-matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -128,14 +128,14 @@ EOF\n test_expect_success 'name-rev --exclude excludes matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev --no-refs clears the refs list' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n \t\t<expect >actual &&\n \ttest_cmp expect actual\n '\n@@ -149,7 +149,7 @@ EOF\n \n test_expect_success '--cherry-mark' '\n \tgit rev-list --cherry-mark F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -163,7 +163,7 @@ EOF\n \n test_expect_success '--cherry-mark --left-right' '\n \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -174,14 +174,14 @@ EOF\n \n test_expect_success '--cherry-pick --right-only' '\n \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success '--cherry-pick --left-only' '\n \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -193,7 +193,7 @@ EOF\n \n test_expect_success '--cherry' '\n \tgit rev-list --cherry F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\ndiff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\nindex 4f7fa8b6c03..4fedc614fa6 100755\n--- a/t/t6012-rev-list-simplify.sh\n+++ b/t/t6012-rev-list-simplify.sh\n@@ -12,7 +12,7 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n+\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n }\n \n #\ndiff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\nindex e07b6070e0e..90ff1416400 100755\n--- a/t/t6111-rev-list-treesame.sh\n+++ b/t/t6111-rev-list-treesame.sh\n@@ -23,7 +23,8 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n+\tgit name-rev --tags --annotate-stdin | \\\n+\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n }\n \n test_expect_success setup '\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex d8af2bb9d2b..9781b92aedd 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'name-rev --stdin' '\n+test_expect_success 'name-rev --annotate-stdin' '\n \t>expect.unsorted &&\n \tfor rev in $(git rev-list --all)\n \tdo\n@@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n \tdone &&\n \tsort <expect.unsorted >expect &&\n-\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n+\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n \tsort <actual.unsorted >actual &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'name-rev --stdin deprecated' \"\n+\tgit rev-list --all | git name-rev --stdin 2>actual &&\n+\tgrep -E 'warning: --stdin is deprecated' actual\n+\"\n+\n test_expect_success 'describe --contains with the exact tags' '\n \techo \"A^0\" >expect &&\n \ttag_object=$(git rev-parse refs/tags/A) &&\n-- \ngitgitgadget\n\n"},{"id":"445354","messageId":"e4bd09ccf75d48e7c6e8c4901395449bf79aa3c3.1641221261.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v3.git.git.1641221261.gitgitgadget@gmail.com","subject":"[PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-03T14:47:41Z","receivedAt":"2022-01-03T14:47:49Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nUsing a buffer limited to 2048 is unnecessarily limiting. Switch to\nusing a string buffer to read in stdin for annotation.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n builtin/name-rev.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 21370afdaf9..85993bc2b38 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -625,12 +625,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tif (annotate_stdin) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\twhile (!feof(stdin)) {\n-\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n-\t\t\tif (!p)\n-\t\t\t\tbreak;\n-\t\t\tname_rev_line(p, &data);\n+\t\twhile (strbuf_getwholeline(&sb, stdin, '\\n') != EOF) {\n+\t\t\tname_rev_line(sb.buf, &data);\n \t\t}\n+\t\tstrbuf_release(&sb);\n \t} else if (all) {\n \t\tint i, max;\n \n-- \ngitgitgadget\n"},{"id":"445382","messageId":"xmqqr19ofdo5.fsf@gitster.g","threadId":"57152","inReplyTo":"e4bd09ccf75d48e7c6e8c4901395449bf79aa3c3.1641221261.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-04T02:16:42Z","receivedAt":"2022-01-04T02:16:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: John Cai <johncai86@gmail.com>\n>\n> Using a buffer limited to 2048 is unnecessarily limiting. Switch to\n> using a string buffer to read in stdin for annotation.\n>\n> Signed-off-by: \"John Cai\" <johncai86@gmail.com>\n> ---\n>  builtin/name-rev.c | 8 +++-----\n>  1 file changed, 3 insertions(+), 5 deletions(-)\n>\n> diff --git a/builtin/name-rev.c b/builtin/name-rev.c\n> index 21370afdaf9..85993bc2b38 100644\n> --- a/builtin/name-rev.c\n> +++ b/builtin/name-rev.c\n> @@ -625,12 +625,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tif (annotate_stdin) {\n>  \t\tstruct strbuf sb = STRBUF_INIT;\n>  \n> -\t\twhile (!feof(stdin)) {\n> -\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n> -\t\t\tif (!p)\n> -\t\t\t\tbreak;\n> -\t\t\tname_rev_line(p, &data);\n> +\t\twhile (strbuf_getwholeline(&sb, stdin, '\\n') != EOF) {\n\nAs we are reading text, I wonder if it makes more sense to just use\nstrbuf_getline() that is meant to use the definition of \"line\" that\nhonors the platform convention (i.e. on Windows, '\\r\\n' is taken as\nthe EOL marker).\n\n> +\t\t\tname_rev_line(sb.buf, &data);\n>  \t\t}\n> +\t\tstrbuf_release(&sb);\n>  \t} else if (all) {\n>  \t\tint i, max;\n\nOther than that, looking good.\n\nThanks.\n"},{"id":"445385","messageId":"xmqqa6gcfcqp.fsf@gitster.g","threadId":"57152","inReplyTo":"55ec2a5fa3e748b7e5f9ef871214563ba2b28adf.1641221261.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-04T02:36:46Z","receivedAt":"2022-01-04T02:36:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +--annotate-stdin::\n>  \tTransform stdin by substituting all the 40-character SHA-1\n>  \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n>  \t--name-only, substitute with \"$rev_name\", omitting $hex\n> -\taltogether.  Intended for the scripter's use.\n> +\taltogether.\n> +\n> +\tFor example:\n> ++\n\nI wonder if you also need the \"There is no paragraph break,\nconcluding the bulleted item\" marker that is a sole plus sign on a\nline before the \"For example:\" thing.\n\nOther than that, looking good.\n\nThanks.\n"},{"id":"445387","messageId":"xmqq4k6kfaw5.fsf@gitster.g","threadId":"57152","inReplyTo":"55ec2a5fa3e748b7e5f9ef871214563ba2b28adf.1641221261.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-04T03:16:42Z","receivedAt":"2022-01-04T03:16:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: John Cai <johncai86@gmail.com>\n>\n> Introduce a --annotate-text that is functionally equivalent of --stdin.\n\nThis line and the title need to be updated to use \"--annotate-stdin\".\n"},{"id":"445411","messageId":"77e18a78-ddfe-0337-deaf-bb9dfb63a495@iee.email","threadId":"57152","inReplyTo":"55ec2a5fa3e748b7e5f9ef871214563ba2b28adf.1641221261.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.email","sentAt":"2022-01-04T13:25:12Z","receivedAt":"2022-01-04T13:25:17Z","isPatch":true,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"On 03/01/2022 14:47, John Cai via GitGitGadget wrote:\n> From: John Cai <johncai86@gmail.com>\n>\n> Introduce a --annotate-text that is functionally equivalent of --stdin.\n> --stdin does not behave as --stdin in other subcommands, such as\n> pack-objects whereby it takes one argument per line. Since --stdin can\n> be a confusing and misleading name, rename it to --annotate-text.\n>\n> This change adds a warning to --stdin warning that it will be removed in\n> the future.\n>\n> Signed-off-by: \"John Cai\" <johncai86@gmail.com>\n> ---\n>  Documentation/git-name-rev.txt       | 29 +++++++++++++++++++++++++++-\n>  builtin/name-rev.c                   | 19 +++++++++++++-----\n>  t/t3412-rebase-root.sh               |  2 +-\n>  t/t4202-log.sh                       |  2 +-\n>  t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++-------------\n>  t/t6012-rev-list-simplify.sh         |  2 +-\n>  t/t6111-rev-list-treesame.sh         |  3 ++-\n>  t/t6120-describe.sh                  |  9 +++++++--\n>  8 files changed, 67 insertions(+), 25 deletions(-)\n>\n> diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\n> index 5cb0eb0855f..ee11b2ca9e7 100644\n> --- a/Documentation/git-name-rev.txt\n> +++ b/Documentation/git-name-rev.txt\n> @@ -43,10 +43,37 @@ OPTIONS\n>  \tList all commits reachable from all refs\n>  \n>  --stdin::\n> +\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n> +\tThey are functionally equivalent.\n> +\n> +--annotate-stdin::\n>  \tTransform stdin by substituting all the 40-character SHA-1\n>  \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n>  \t--name-only, substitute with \"$rev_name\", omitting $hex\n> -\taltogether.  Intended for the scripter's use.\n> +\taltogether.\n\nIs there a preferred order for the old/new variant documentation?\n\nIt struck me that the docs should offer the new (now 'correct') variant\nfirst.\n\nI didn't see anything about deprecation in the CodingGuidlines or\nSubmittingPatches (only a quick search though)\n\n--\nPhilip\n> +\n> +\tFor example:\n> ++\n> +----------\n> +$ cat sample.txt\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +$ git name-rev --annotate-stdin <sample.txt\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n> +(master),\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +$ git name-rev --name-only --annotate-stdin <sample.txt\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name is master,\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +----------\n>  \n>  --name-only::\n>  \tInstead of printing both the SHA-1 and the name, print only\n> diff --git a/builtin/name-rev.c b/builtin/name-rev.c\n> index 27f60153a6c..21370afdaf9 100644\n> --- a/builtin/name-rev.c\n> +++ b/builtin/name-rev.c\n> @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n>  int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  {\n>  \tstruct object_array revs = OBJECT_ARRAY_INIT;\n> -\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n> +\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n>  \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n>  \tstruct option opts[] = {\n>  \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n> @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \t\tOPT_GROUP(\"\"),\n>  \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n>  \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n> +\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n>  \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n>  \t\tOPT_BOOL(0, \"always\",     &always,\n>  \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n> @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tinit_commit_rev_name(&rev_names);\n>  \tgit_config(git_default_config, NULL);\n>  \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n> -\tif (all + transform_stdin + !!argc > 1) {\n> +\n> +\tif (transform_stdin) {\n> +\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n> +\t\t\t\t\t\"which is functionally equivalent.\\n\"\n> +\t\t\t\t\t\"This option will be removed in a future release.\");\n> +\t\tannotate_stdin = 1;\n> +\t}\n> +\n> +\tif (all + annotate_stdin + !!argc > 1) {\n>  \t\terror(\"Specify either a list, or --all, not both!\");\n>  \t\tusage_with_options(name_rev_usage, opts);\n>  \t}\n> -\tif (all || transform_stdin)\n> +\tif (all || annotate_stdin)\n>  \t\tcutoff = 0;\n>  \n>  \tfor (; argc; argc--, argv++) {\n> @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tfor_each_ref(name_ref, &data);\n>  \tname_tips();\n>  \n> -\tif (transform_stdin) {\n> -\t\tchar buffer[2048];\n> +\tif (annotate_stdin) {\n> +\t\tstruct strbuf sb = STRBUF_INIT;\n>  \n>  \t\twhile (!feof(stdin)) {\n>  \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n> diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\n> index 19c6f4acbf6..1e9f7833dd6 100755\n> --- a/t/t3412-rebase-root.sh\n> +++ b/t/t3412-rebase-root.sh\n> @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n>  \n>  log_with_names () {\n>  \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n> -\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n> +\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n>  }\n>  \n>  \n> diff --git a/t/t4202-log.sh b/t/t4202-log.sh\n> index 50495598619..dc884107de4 100755\n> --- a/t/t4202-log.sh\n> +++ b/t/t4202-log.sh\n> @@ -659,7 +659,7 @@ EOF\n>  \n>  test_expect_success 'log --graph with full output' '\n>  \tgit log --graph --date-order --pretty=short |\n> -\t\tgit name-rev --name-only --stdin |\n> +\t\tgit name-rev --name-only --annotate-stdin |\n>  \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n>  \ttest_cmp expect actual\n>  '\n> diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\n> index aebe4b69e13..6f3e5439771 100755\n> --- a/t/t6007-rev-list-cherry-pick-file.sh\n> +++ b/t/t6007-rev-list-cherry-pick-file.sh\n> @@ -58,7 +58,7 @@ EOF\n>  \n>  test_expect_success '--left-right' '\n>  \tgit rev-list --left-right B...C > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -78,14 +78,14 @@ EOF\n>  \n>  test_expect_success '--cherry-pick bar does not come up empty' '\n>  \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>  \n>  test_expect_success 'bar does not come up empty' '\n>  \tgit rev-list --left-right B...C -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -97,14 +97,14 @@ EOF\n>  \n>  test_expect_success '--cherry-pick bar does not come up empty (II)' '\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>  \n>  test_expect_success 'name-rev multiple --refs combine inclusive' '\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n>  \t\t<actual >actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -116,7 +116,7 @@ EOF\n>  test_expect_success 'name-rev --refs excludes non-matched patterns' '\n>  \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n>  \t\t<actual >actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -128,14 +128,14 @@ EOF\n>  test_expect_success 'name-rev --exclude excludes matched patterns' '\n>  \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n>  \t\t<actual >actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>  \n>  test_expect_success 'name-rev --no-refs clears the refs list' '\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n>  \t\t<expect >actual &&\n>  \ttest_cmp expect actual\n>  '\n> @@ -149,7 +149,7 @@ EOF\n>  \n>  test_expect_success '--cherry-mark' '\n>  \tgit rev-list --cherry-mark F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -163,7 +163,7 @@ EOF\n>  \n>  test_expect_success '--cherry-mark --left-right' '\n>  \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -174,14 +174,14 @@ EOF\n>  \n>  test_expect_success '--cherry-pick --right-only' '\n>  \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>  \n>  test_expect_success '--cherry-pick --left-only' '\n>  \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -193,7 +193,7 @@ EOF\n>  \n>  test_expect_success '--cherry' '\n>  \tgit rev-list --cherry F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\n> index 4f7fa8b6c03..4fedc614fa6 100755\n> --- a/t/t6012-rev-list-simplify.sh\n> +++ b/t/t6012-rev-list-simplify.sh\n> @@ -12,7 +12,7 @@ note () {\n>  }\n>  \n>  unnote () {\n> -\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n> +\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n>  }\n>  \n>  #\n> diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\n> index e07b6070e0e..90ff1416400 100755\n> --- a/t/t6111-rev-list-treesame.sh\n> +++ b/t/t6111-rev-list-treesame.sh\n> @@ -23,7 +23,8 @@ note () {\n>  }\n>  \n>  unnote () {\n> -\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n> +\tgit name-rev --tags --annotate-stdin | \\\n> +\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n>  }\n>  \n>  test_expect_success setup '\n> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\n> index d8af2bb9d2b..9781b92aedd 100755\n> --- a/t/t6120-describe.sh\n> +++ b/t/t6120-describe.sh\n> @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n>  \ttest_cmp expect actual\n>  '\n>  \n> -test_expect_success 'name-rev --stdin' '\n> +test_expect_success 'name-rev --annotate-stdin' '\n>  \t>expect.unsorted &&\n>  \tfor rev in $(git rev-list --all)\n>  \tdo\n> @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n>  \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n>  \tdone &&\n>  \tsort <expect.unsorted >expect &&\n> -\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n> +\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n>  \tsort <actual.unsorted >actual &&\n>  \ttest_cmp expect actual\n>  '\n>  \n> +test_expect_success 'name-rev --stdin deprecated' \"\n> +\tgit rev-list --all | git name-rev --stdin 2>actual &&\n> +\tgrep -E 'warning: --stdin is deprecated' actual\n> +\"\n> +\n>  test_expect_success 'describe --contains with the exact tags' '\n>  \techo \"A^0\" >expect &&\n>  \ttag_object=$(git rev-parse refs/tags/A) &&\n\n"},{"id":"445418","messageId":"pull.1171.v4.git.git.1641307776.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v3.git.git.1641221261.gitgitgadget@gmail.com","subject":"[PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-04T14:49:34Z","receivedAt":"2022-01-04T14:49:40Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can be a\nconfusing and misleading name, the goal is to rename it to --annotate-stdin.\n\nThis is the first step in a process of eventually fully deprecating --stdin.\nThis change also adds a warning to --stdin warning that it will be removed\nin the future.\n\nSee https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion.\n\nchanges since v3:\n\n * use strbuf_getline instead of strbuf_getwholeline (based on Junio's\n   feedback)\n * fixed commit message s/annotate-text/annotate-stdin (based on Junio's\n   feedback)\n * since strbuf_getline does not keep the trailing terminator, add back '\\n'\n   with strbuf_addchr\n * reordered documentation blocks based on (Philip Oakley's feedback)\n * fixed doc typos in example block\n\nJohn Cai (2):\n  name-rev: deprecate --stdin in favor of --annotate-stdin\n  name-rev.c: use strbuf_getline instead of limited size buffer\n\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 28 ++++++++++++++++----------\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 71 insertions(+), 31 deletions(-)\n\n\nbase-commit: c8b2ade48c204690119936ada89cd938c476c5c2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v4\nPull-Request: https://github.com/git/git/pull/1171\n\nRange-diff vs v3:\n\n 1:  55ec2a5fa3e ! 1:  4e9200922a4 name-rev: deprecate --stdin in favor of --annotate-text\n     @@ Metadata\n      Author: John Cai <johncai86@gmail.com>\n      \n       ## Commit message ##\n     -    name-rev: deprecate --stdin in favor of --annotate-text\n     +    name-rev: deprecate --stdin in favor of --annotate-stdin\n      \n     -    Introduce a --annotate-text that is functionally equivalent of --stdin.\n     +    Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n          --stdin does not behave as --stdin in other subcommands, such as\n          pack-objects whereby it takes one argument per line. Since --stdin can\n     -    be a confusing and misleading name, rename it to --annotate-text.\n     +    be a confusing and misleading name, rename it to --annotate-stdin.\n      \n          This change adds a warning to --stdin warning that it will be removed in\n          the future.\n     @@ Commit message\n      \n       ## Documentation/git-name-rev.txt ##\n      @@ Documentation/git-name-rev.txt: OPTIONS\n     + --all::\n       \tList all commits reachable from all refs\n       \n     - --stdin::\n     -+\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n     -+\tThey are functionally equivalent.\n     -+\n     +---stdin::\n      +--annotate-stdin::\n       \tTransform stdin by substituting all the 40-character SHA-1\n       \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n     @@ Documentation/git-name-rev.txt: OPTIONS\n      -\taltogether.  Intended for the scripter's use.\n      +\taltogether.\n      +\n     -+\tFor example:\n     -++\n     ++For example:\n     ++\n      +----------\n      +$ cat sample.txt\n      +\n     @@ Documentation/git-name-rev.txt: OPTIONS\n      +$ git name-rev --annotate-stdin <sample.txt\n      +\n      +An abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907\n     -+(master),\n     ++The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n      +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +\n      +$ git name-rev --name-only --annotate-stdin <sample.txt\n      +\n      +An abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+The full name is master,\n     ++The full name after substitution is master,\n      +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +----------\n     ++\n     ++--stdin::\n     ++\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n     ++\tThey are functionally equivalent.\n       \n       --name-only::\n       \tInstead of printing both the SHA-1 and the name, print only\n 2:  e4bd09ccf75 ! 2:  18f77ab9dde name-rev.c: use strbuf_getline instead of limited size buffer\n     @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr\n      -\t\t\tif (!p)\n      -\t\t\t\tbreak;\n      -\t\t\tname_rev_line(p, &data);\n     -+\t\twhile (strbuf_getwholeline(&sb, stdin, '\\n') != EOF) {\n     ++\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n     ++\t\t\tstrbuf_addch(&sb, '\\n');\n      +\t\t\tname_rev_line(sb.buf, &data);\n       \t\t}\n      +\t\tstrbuf_release(&sb);\n\n-- \ngitgitgadget\n"},{"id":"445419","messageId":"4e9200922a4c2c91e69e3b497fbf4c8702046a27.1641307776.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v4.git.git.1641307776.gitgitgadget@gmail.com","subject":"[PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-04T14:49:35Z","receivedAt":"2022-01-04T14:49:43Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nIntroduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can\nbe a confusing and misleading name, rename it to --annotate-stdin.\n\nThis change adds a warning to --stdin warning that it will be removed in\nthe future.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 19 +++++++++++++-----\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 67 insertions(+), 26 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 5cb0eb0855f..96e8fd5ea47 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -42,11 +42,37 @@ OPTIONS\n --all::\n \tList all commits reachable from all refs\n \n---stdin::\n+--annotate-stdin::\n \tTransform stdin by substituting all the 40-character SHA-1\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n-\taltogether.  Intended for the scripter's use.\n+\taltogether.\n+\n+For example:\n+\n+----------\n+$ cat sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --name-only --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is master,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+----------\n+\n+--stdin::\n+\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n+\tThey are functionally equivalent.\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 27f60153a6c..21370afdaf9 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = OBJECT_ARRAY_INIT;\n-\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n+\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n \tstruct option opts[] = {\n \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n@@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n+\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n \t\tOPT_BOOL(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n@@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tinit_commit_rev_name(&rev_names);\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n-\tif (all + transform_stdin + !!argc > 1) {\n+\n+\tif (transform_stdin) {\n+\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n+\t\t\t\t\t\"which is functionally equivalent.\\n\"\n+\t\t\t\t\t\"This option will be removed in a future release.\");\n+\t\tannotate_stdin = 1;\n+\t}\n+\n+\tif (all + annotate_stdin + !!argc > 1) {\n \t\terror(\"Specify either a list, or --all, not both!\");\n \t\tusage_with_options(name_rev_usage, opts);\n \t}\n-\tif (all || transform_stdin)\n+\tif (all || annotate_stdin)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n@@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tfor_each_ref(name_ref, &data);\n \tname_tips();\n \n-\tif (transform_stdin) {\n-\t\tchar buffer[2048];\n+\tif (annotate_stdin) {\n+\t\tstruct strbuf sb = STRBUF_INIT;\n \n \t\twhile (!feof(stdin)) {\n \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\ndiff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\nindex 19c6f4acbf6..1e9f7833dd6 100755\n--- a/t/t3412-rebase-root.sh\n+++ b/t/t3412-rebase-root.sh\n@@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n log_with_names () {\n \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n-\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n+\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n }\n \n \ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 50495598619..dc884107de4 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -659,7 +659,7 @@ EOF\n \n test_expect_success 'log --graph with full output' '\n \tgit log --graph --date-order --pretty=short |\n-\t\tgit name-rev --name-only --stdin |\n+\t\tgit name-rev --name-only --annotate-stdin |\n \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex aebe4b69e13..6f3e5439771 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -58,7 +58,7 @@ EOF\n \n test_expect_success '--left-right' '\n \tgit rev-list --left-right B...C > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -78,14 +78,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty' '\n \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'bar does not come up empty' '\n \tgit rev-list --left-right B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -97,14 +97,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty (II)' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev multiple --refs combine inclusive' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -116,7 +116,7 @@ EOF\n test_expect_success 'name-rev --refs excludes non-matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -128,14 +128,14 @@ EOF\n test_expect_success 'name-rev --exclude excludes matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev --no-refs clears the refs list' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n \t\t<expect >actual &&\n \ttest_cmp expect actual\n '\n@@ -149,7 +149,7 @@ EOF\n \n test_expect_success '--cherry-mark' '\n \tgit rev-list --cherry-mark F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -163,7 +163,7 @@ EOF\n \n test_expect_success '--cherry-mark --left-right' '\n \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -174,14 +174,14 @@ EOF\n \n test_expect_success '--cherry-pick --right-only' '\n \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success '--cherry-pick --left-only' '\n \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -193,7 +193,7 @@ EOF\n \n test_expect_success '--cherry' '\n \tgit rev-list --cherry F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\ndiff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\nindex 4f7fa8b6c03..4fedc614fa6 100755\n--- a/t/t6012-rev-list-simplify.sh\n+++ b/t/t6012-rev-list-simplify.sh\n@@ -12,7 +12,7 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n+\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n }\n \n #\ndiff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\nindex e07b6070e0e..90ff1416400 100755\n--- a/t/t6111-rev-list-treesame.sh\n+++ b/t/t6111-rev-list-treesame.sh\n@@ -23,7 +23,8 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n+\tgit name-rev --tags --annotate-stdin | \\\n+\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n }\n \n test_expect_success setup '\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex d8af2bb9d2b..9781b92aedd 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'name-rev --stdin' '\n+test_expect_success 'name-rev --annotate-stdin' '\n \t>expect.unsorted &&\n \tfor rev in $(git rev-list --all)\n \tdo\n@@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n \tdone &&\n \tsort <expect.unsorted >expect &&\n-\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n+\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n \tsort <actual.unsorted >actual &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'name-rev --stdin deprecated' \"\n+\tgit rev-list --all | git name-rev --stdin 2>actual &&\n+\tgrep -E 'warning: --stdin is deprecated' actual\n+\"\n+\n test_expect_success 'describe --contains with the exact tags' '\n \techo \"A^0\" >expect &&\n \ttag_object=$(git rev-parse refs/tags/A) &&\n-- \ngitgitgadget\n\n"},{"id":"445420","messageId":"18f77ab9dde121ca16cc52c624322bda10e2d2bd.1641307776.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v4.git.git.1641307776.gitgitgadget@gmail.com","subject":"[PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-04T14:49:36Z","receivedAt":"2022-01-04T14:49:44Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nUsing a buffer limited to 2048 is unnecessarily limiting. Switch to\nusing a string buffer to read in stdin for annotation.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n builtin/name-rev.c | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 21370afdaf9..d16b4ca0b66 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -625,12 +625,11 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tif (annotate_stdin) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\twhile (!feof(stdin)) {\n-\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n-\t\t\tif (!p)\n-\t\t\t\tbreak;\n-\t\t\tname_rev_line(p, &data);\n+\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n+\t\t\tstrbuf_addch(&sb, '\\n');\n+\t\t\tname_rev_line(sb.buf, &data);\n \t\t}\n+\t\tstrbuf_release(&sb);\n \t} else if (all) {\n \t\tint i, max;\n \n-- \ngitgitgadget\n"},{"id":"445421","messageId":"795F5A80-96B5-4963-8F0C-709A49DBF152@gmail.com","threadId":"57152","inReplyTo":"18f77ab9dde121ca16cc52c624322bda10e2d2bd.1641307776.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"John Cai","fromEmail":"johncai86@gmail.com","sentAt":"2022-01-04T14:54:50Z","receivedAt":"2022-01-04T14:55:08Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"\n\n> On Jan 4, 2022, at 9:49 AM, John Cai via GitGitGadget <gitgitgadget@gmail.com> wrote:\n> \n> From: John Cai <johncai86@gmail.com>\n> \n> Using a buffer limited to 2048 is unnecessarily limiting. Switch to\n> using a string buffer to read in stdin for annotation.\n> \n> Signed-off-by: \"John Cai\" <johncai86@gmail.com>\n> ---\n> builtin/name-rev.c | 9 ++++-----\n> 1 file changed, 4 insertions(+), 5 deletions(-)\n> \n> diff --git a/builtin/name-rev.c b/builtin/name-rev.c\n> index 21370afdaf9..d16b4ca0b66 100644\n> --- a/builtin/name-rev.c\n> +++ b/builtin/name-rev.c\n> @@ -625,12 +625,11 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n> \tif (annotate_stdin) {\n> \t\tstruct strbuf sb = STRBUF_INIT;\n> \n> -\t\twhile (!feof(stdin)) {\n> -\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n> -\t\t\tif (!p)\n> -\t\t\t\tbreak;\n> -\t\t\tname_rev_line(p, &data);\n> +\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n> +\t\t\tstrbuf_addch(&sb, '\\n');\n\nI agree strbuf_getline is better since it handles EOF across platforms. However, one trouble I ran\ninto is that it does not retain the line terminator, so I had to add it back in this fashion. It looks\na little ugly, but let me know if you think this is preferable to using strbuf_getwholeline.\n\n> +\t\t\tname_rev_line(sb.buf, &data);\n> \t\t}\n> +\t\tstrbuf_release(&sb);\n> \t} else if (all) {\n> \t\tint i, max;\n> \n> -- \n> gitgitgadget\n\n"},{"id":"445455","messageId":"xmqqo84re36w.fsf@gitster.g","threadId":"57152","inReplyTo":"77e18a78-ddfe-0337-deaf-bb9dfb63a495@iee.email","subject":"Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-04T19:00:39Z","receivedAt":"2022-01-04T19:00:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Philip Oakley <philipoakley@iee.email> writes:\n\n>>  --stdin::\n>> +\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n>> +\tThey are functionally equivalent.\n>> +\n>> +--annotate-stdin::\n>>  \tTransform stdin by substituting all the 40-character SHA-1\n>>  \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n>>  \t--name-only, substitute with \"$rev_name\", omitting $hex\n>> -\taltogether.  Intended for the scripter's use.\n>> +\taltogether.\n>\n> Is there a preferred order for the old/new variant documentation?\n\nIf the surrounding list has a natural order of its own, e.g.  the\nlist is sorted alphabetically to help people locate an item by name,\nit is OK to have old and new in that order and older one may appear\nbefore the newer one.\n\nBut otherwise it may make sense to show the newer one first with the\nmention of the older one as if it were a side note, especially when\nthey can appear next to each other like the one we are looking at, I\nwould think.\n\nI do not think we have written preference.  It probably would help\nto have a short paragraph in the coding guidelines document.\n\nThanks.\n\n\n"},{"id":"445461","messageId":"CAPig+cRUQA_G_sLi4Q_F4ZhHkhEFKT-an4LuOpbTJ9bDuZLjog@mail.gmail.com","threadId":"57152","inReplyTo":"77e18a78-ddfe-0337-deaf-bb9dfb63a495@iee.email","subject":"Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2022-01-04T19:38:46Z","receivedAt":"2022-01-04T19:38:58Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jan 4, 2022 at 10:32 AM Philip Oakley <philipoakley@iee.email> wrote:\n> On 03/01/2022 14:47, John Cai via GitGitGadget wrote:\n> > From: John Cai <johncai86@gmail.com>\n> >  --stdin::\n> > +     This option is deprecated in favor of 'git name-rev --annotate-stdin'.\n> > +     They are functionally equivalent.\n> > +\n> > +--annotate-stdin::\n> >       Transform stdin by substituting all the 40-character SHA-1\n> >       hexes (say $hex) with \"$hex ($rev_name)\".  When used with\n> >       --name-only, substitute with \"$rev_name\", omitting $hex\n> > -     altogether.  Intended for the scripter's use.\n> > +     altogether.\n>\n> Is there a preferred order for the old/new variant documentation?\n>\n> It struck me that the docs should offer the new (now 'correct') variant\n> first.\n>\n> I didn't see anything about deprecation in the CodingGuidlines or\n> SubmittingPatches (only a quick search though)\n\nIn other cases, we've demoted the deprecated option to a tiny blurb at\nthe end of the description of the option which replaces it so that the\ndeprecated option is no longer given a place of prominence but can\nstill be found with a search in case someone runs across it somewhere\nand wants to learn about it.\n\n    --annotate-stdin::\n        Transform stdin by substituting all the 40-character SHA-1\n        hexes (say $hex) with \"$hex ($rev_name)\".  When used with\n        --name-only, substitute with \"$rev_name\", omitting $hex\n        altogether. --stdin is a deprecated synonym.\n"},{"id":"445483","messageId":"xmqqzgob9mmd.fsf@gitster.g","threadId":"57152","inReplyTo":"4e9200922a4c2c91e69e3b497fbf4c8702046a27.1641307776.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-04T22:12:10Z","receivedAt":"2022-01-04T22:12:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +\taltogether.\n> +\n> +For example:\n> +\n> +----------\n> +$ cat sample.txt\n\nBecause this example is a part of description of `--annotate-stdin`,\nnot an example after a list that ends with `--annotate-stdin`, you\nwould want to tweak the above a bit.\n\n\ndiff --git i/Documentation/git-name-rev.txt w/Documentation/git-name-rev.txt\nindex 96e8fd5ea4..0f32d74de0 100644\n--- i/Documentation/git-name-rev.txt\n+++ w/Documentation/git-name-rev.txt\n@@ -47,9 +47,9 @@ OPTIONS\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n \taltogether.\n-\n++\n For example:\n-\n++\n ----------\n $ cat sample.txt\n \n"},{"id":"445502","messageId":"pull.1171.v5.git.git.1641356439.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v4.git.git.1641307776.gitgitgadget@gmail.com","subject":"[PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T04:20:37Z","receivedAt":"2022-01-05T04:20:45Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can be a\nconfusing and misleading name, the goal is to rename it to --annotate-stdin.\n\nThis is the first step in a process of eventually fully deprecating --stdin.\nThis change also adds a warning to --stdin warning that it will be removed\nin the future.\n\nSee https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion.\n\nchanges since v4:\n\n * fixed documentation example indentation\n\nchanges since v3:\n\n * use strbuf_getline instead of strbuf_getwholeline (based on Junio's\n   feedback)\n * fixed commit message s/annotate-text/annotate-stdin (based on Junio's\n   feedback)\n * since strbuf_getline does not keep the trailing terminator, add back '\\n'\n   with strbuf_addchr\n * reordered documentation blocks based on (Philip Oakley's feedback)\n * fixed doc typos in example block\n\nJohn Cai (2):\n  name-rev: deprecate --stdin in favor of --annotate-stdin\n  name-rev.c: use strbuf_getline instead of limited size buffer\n\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 28 ++++++++++++++++----------\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 71 insertions(+), 31 deletions(-)\n\n\nbase-commit: c8b2ade48c204690119936ada89cd938c476c5c2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v5\nPull-Request: https://github.com/git/git/pull/1171\n\nRange-diff vs v4:\n\n 1:  4e9200922a4 ! 1:  7c5fb10d87c name-rev: deprecate --stdin in favor of --annotate-stdin\n     @@ Documentation/git-name-rev.txt: OPTIONS\n       \t--name-only, substitute with \"$rev_name\", omitting $hex\n      -\taltogether.  Intended for the scripter's use.\n      +\taltogether.\n     -+\n     +++\n      +For example:\n     +++\n     ++--\n     ++\t$ cat sample.txt\n      +\n     -+----------\n     -+$ cat sample.txt\n     -+\n     -+An abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n     -+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     ++\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n     ++\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n     ++\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +\n     -+$ git name-rev --annotate-stdin <sample.txt\n     ++\t$ git name-rev --annotate-stdin <sample.txt\n      +\n     -+An abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n     -+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     ++\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n     ++\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n     ++\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +\n     -+$ git name-rev --name-only --annotate-stdin <sample.txt\n     ++\t$ git name-rev --name-only --annotate-stdin <sample.txt\n      +\n     -+An abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+The full name after substitution is master,\n     -+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     -+----------\n     ++\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n     ++\tThe full name after substitution is master,\n     ++\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     ++--\n      +\n      +--stdin::\n      +\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n 2:  18f77ab9dde = 2:  2acd70f36e7 name-rev.c: use strbuf_getline instead of limited size buffer\n\n-- \ngitgitgadget\n"},{"id":"445503","messageId":"2acd70f36e73fe47261fc7b2f86dcdfc10580d82.1641356439.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v5.git.git.1641356439.gitgitgadget@gmail.com","subject":"[PATCH v5 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T04:20:39Z","receivedAt":"2022-01-05T04:20:45Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nUsing a buffer limited to 2048 is unnecessarily limiting. Switch to\nusing a string buffer to read in stdin for annotation.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n builtin/name-rev.c | 9 ++++-----\n 1 file changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 21370afdaf9..d16b4ca0b66 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -625,12 +625,11 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tif (annotate_stdin) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\twhile (!feof(stdin)) {\n-\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n-\t\t\tif (!p)\n-\t\t\t\tbreak;\n-\t\t\tname_rev_line(p, &data);\n+\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n+\t\t\tstrbuf_addch(&sb, '\\n');\n+\t\t\tname_rev_line(sb.buf, &data);\n \t\t}\n+\t\tstrbuf_release(&sb);\n \t} else if (all) {\n \t\tint i, max;\n \n-- \ngitgitgadget\n"},{"id":"445504","messageId":"7c5fb10d87c4b807567db0ed83f987487532c7c1.1641356439.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v5.git.git.1641356439.gitgitgadget@gmail.com","subject":"[PATCH v5 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T04:20:38Z","receivedAt":"2022-01-05T04:20:50Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nIntroduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can\nbe a confusing and misleading name, rename it to --annotate-stdin.\n\nThis change adds a warning to --stdin warning that it will be removed in\nthe future.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 19 +++++++++++++-----\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 67 insertions(+), 26 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 5cb0eb0855f..f57d4633e3c 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -42,11 +42,37 @@ OPTIONS\n --all::\n \tList all commits reachable from all refs\n \n---stdin::\n+--annotate-stdin::\n \tTransform stdin by substituting all the 40-character SHA-1\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n-\taltogether.  Intended for the scripter's use.\n+\taltogether.\n++\n+For example:\n++\n+--\n+\t$ cat sample.txt\n+\n+\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n+\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n+\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+\t$ git name-rev --annotate-stdin <sample.txt\n+\n+\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n+\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n+\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+\t$ git name-rev --name-only --annotate-stdin <sample.txt\n+\n+\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n+\tThe full name after substitution is master,\n+\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+--\n+\n+--stdin::\n+\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n+\tThey are functionally equivalent.\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 27f60153a6c..21370afdaf9 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = OBJECT_ARRAY_INIT;\n-\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n+\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n \tstruct option opts[] = {\n \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n@@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n+\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n \t\tOPT_BOOL(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n@@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tinit_commit_rev_name(&rev_names);\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n-\tif (all + transform_stdin + !!argc > 1) {\n+\n+\tif (transform_stdin) {\n+\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n+\t\t\t\t\t\"which is functionally equivalent.\\n\"\n+\t\t\t\t\t\"This option will be removed in a future release.\");\n+\t\tannotate_stdin = 1;\n+\t}\n+\n+\tif (all + annotate_stdin + !!argc > 1) {\n \t\terror(\"Specify either a list, or --all, not both!\");\n \t\tusage_with_options(name_rev_usage, opts);\n \t}\n-\tif (all || transform_stdin)\n+\tif (all || annotate_stdin)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n@@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tfor_each_ref(name_ref, &data);\n \tname_tips();\n \n-\tif (transform_stdin) {\n-\t\tchar buffer[2048];\n+\tif (annotate_stdin) {\n+\t\tstruct strbuf sb = STRBUF_INIT;\n \n \t\twhile (!feof(stdin)) {\n \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\ndiff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\nindex 19c6f4acbf6..1e9f7833dd6 100755\n--- a/t/t3412-rebase-root.sh\n+++ b/t/t3412-rebase-root.sh\n@@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n log_with_names () {\n \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n-\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n+\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n }\n \n \ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 50495598619..dc884107de4 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -659,7 +659,7 @@ EOF\n \n test_expect_success 'log --graph with full output' '\n \tgit log --graph --date-order --pretty=short |\n-\t\tgit name-rev --name-only --stdin |\n+\t\tgit name-rev --name-only --annotate-stdin |\n \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex aebe4b69e13..6f3e5439771 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -58,7 +58,7 @@ EOF\n \n test_expect_success '--left-right' '\n \tgit rev-list --left-right B...C > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -78,14 +78,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty' '\n \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'bar does not come up empty' '\n \tgit rev-list --left-right B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -97,14 +97,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty (II)' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev multiple --refs combine inclusive' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -116,7 +116,7 @@ EOF\n test_expect_success 'name-rev --refs excludes non-matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -128,14 +128,14 @@ EOF\n test_expect_success 'name-rev --exclude excludes matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev --no-refs clears the refs list' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n \t\t<expect >actual &&\n \ttest_cmp expect actual\n '\n@@ -149,7 +149,7 @@ EOF\n \n test_expect_success '--cherry-mark' '\n \tgit rev-list --cherry-mark F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -163,7 +163,7 @@ EOF\n \n test_expect_success '--cherry-mark --left-right' '\n \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -174,14 +174,14 @@ EOF\n \n test_expect_success '--cherry-pick --right-only' '\n \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success '--cherry-pick --left-only' '\n \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -193,7 +193,7 @@ EOF\n \n test_expect_success '--cherry' '\n \tgit rev-list --cherry F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\ndiff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\nindex 4f7fa8b6c03..4fedc614fa6 100755\n--- a/t/t6012-rev-list-simplify.sh\n+++ b/t/t6012-rev-list-simplify.sh\n@@ -12,7 +12,7 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n+\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n }\n \n #\ndiff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\nindex e07b6070e0e..90ff1416400 100755\n--- a/t/t6111-rev-list-treesame.sh\n+++ b/t/t6111-rev-list-treesame.sh\n@@ -23,7 +23,8 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n+\tgit name-rev --tags --annotate-stdin | \\\n+\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n }\n \n test_expect_success setup '\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex d8af2bb9d2b..9781b92aedd 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'name-rev --stdin' '\n+test_expect_success 'name-rev --annotate-stdin' '\n \t>expect.unsorted &&\n \tfor rev in $(git rev-list --all)\n \tdo\n@@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n \tdone &&\n \tsort <expect.unsorted >expect &&\n-\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n+\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n \tsort <actual.unsorted >actual &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'name-rev --stdin deprecated' \"\n+\tgit rev-list --all | git name-rev --stdin 2>actual &&\n+\tgrep -E 'warning: --stdin is deprecated' actual\n+\"\n+\n test_expect_success 'describe --contains with the exact tags' '\n \techo \"A^0\" >expect &&\n \ttag_object=$(git rev-parse refs/tags/A) &&\n-- \ngitgitgadget\n\n"},{"id":"445513","messageId":"16666d32-833a-f3d7-351a-eeef7f25b002@gmail.com","threadId":"57152","inReplyTo":"4e9200922a4c2c91e69e3b497fbf4c8702046a27.1641307776.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2022-01-05T11:15:57Z","receivedAt":"2022-01-05T11:16:03Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"Hi John\n\nOn 04/01/2022 14:49, John Cai via GitGitGadget wrote:\n> From: John Cai <johncai86@gmail.com>\n> [...]\n> diff --git a/builtin/name-rev.c b/builtin/name-rev.c\n> index 27f60153a6c..21370afdaf9 100644\n> --- a/builtin/name-rev.c\n> +++ b/builtin/name-rev.c\n> @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n>   int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>   {\n>   \tstruct object_array revs = OBJECT_ARRAY_INIT;\n> -\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n> +\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n>   \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n>   \tstruct option opts[] = {\n>   \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n> @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>   \t\tOPT_GROUP(\"\"),\n>   \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n>   \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n\nIf the intention is to deprecate this option then it might be worth \nmarking it as PARSE_OPT_HIDDEN so that it is not shown by 'git name-rev \n-h'. (You need to change OPT_BOOL to OPT_BOOL_F to pass the flag)\n\n> +\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n>   \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n>   \t\tOPT_BOOL(0, \"always\",     &always,\n>   \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n> @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>   \tinit_commit_rev_name(&rev_names);\n>   \tgit_config(git_default_config, NULL);\n>   \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n> -\tif (all + transform_stdin + !!argc > 1) {\n> +\n> +\tif (transform_stdin) {\n> +\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n> +\t\t\t\t\t\"which is functionally equivalent.\\n\"\n> +\t\t\t\t\t\"This option will be removed in a future release.\");\n> +\t\tannotate_stdin = 1;\n> +\t}\n> +\n> +\tif (all + annotate_stdin + !!argc > 1) {\n>   \t\terror(\"Specify either a list, or --all, not both!\");\n>   \t\tusage_with_options(name_rev_usage, opts);\n>   \t}\n> -\tif (all || transform_stdin)\n> +\tif (all || annotate_stdin)\n>   \t\tcutoff = 0;\n>   \n>   \tfor (; argc; argc--, argv++) {\n> @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>   \tfor_each_ref(name_ref, &data);\n>   \tname_tips();\n>   \n> -\tif (transform_stdin) {\n> -\t\tchar buffer[2048];\n> +\tif (annotate_stdin) {\n> +\t\tstruct strbuf sb = STRBUF_INIT;\n\nI think this hunk belongs in the next patch. Before posting a patch \nseries I find it helpful to run\n\n     git rebase --keep-base -x'make -j4 git && cd t && prove -j4 <tests \nI think might fail> :: --root=/dev/shm'\n\nto check that the individual patches compile and pass the relevant \ntests. I've never got round to trying it but git-test[1] also lets you \ntest all the commits in a series\n\nBest Wishes\n\nPhillip\n\n[1] https://github.com/mhagger/git-test\n\n>   \t\twhile (!feof(stdin)) {\n>   \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n> diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\n> index 19c6f4acbf6..1e9f7833dd6 100755\n> --- a/t/t3412-rebase-root.sh\n> +++ b/t/t3412-rebase-root.sh\n> @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n>   \n>   log_with_names () {\n>   \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n> -\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n> +\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n>   }\n>   \n>   \n> diff --git a/t/t4202-log.sh b/t/t4202-log.sh\n> index 50495598619..dc884107de4 100755\n> --- a/t/t4202-log.sh\n> +++ b/t/t4202-log.sh\n> @@ -659,7 +659,7 @@ EOF\n>   \n>   test_expect_success 'log --graph with full output' '\n>   \tgit log --graph --date-order --pretty=short |\n> -\t\tgit name-rev --name-only --stdin |\n> +\t\tgit name-rev --name-only --annotate-stdin |\n>   \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n>   \ttest_cmp expect actual\n>   '\n> diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\n> index aebe4b69e13..6f3e5439771 100755\n> --- a/t/t6007-rev-list-cherry-pick-file.sh\n> +++ b/t/t6007-rev-list-cherry-pick-file.sh\n> @@ -58,7 +58,7 @@ EOF\n>   \n>   test_expect_success '--left-right' '\n>   \tgit rev-list --left-right B...C > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> @@ -78,14 +78,14 @@ EOF\n>   \n>   test_expect_success '--cherry-pick bar does not come up empty' '\n>   \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n>   \n>   test_expect_success 'bar does not come up empty' '\n>   \tgit rev-list --left-right B...C -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> @@ -97,14 +97,14 @@ EOF\n>   \n>   test_expect_success '--cherry-pick bar does not come up empty (II)' '\n>   \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n>   \n>   test_expect_success 'name-rev multiple --refs combine inclusive' '\n>   \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n>   \t\t<actual >actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> @@ -116,7 +116,7 @@ EOF\n>   test_expect_success 'name-rev --refs excludes non-matched patterns' '\n>   \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n>   \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n>   \t\t<actual >actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> @@ -128,14 +128,14 @@ EOF\n>   test_expect_success 'name-rev --exclude excludes matched patterns' '\n>   \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n>   \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n>   \t\t<actual >actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n>   \n>   test_expect_success 'name-rev --no-refs clears the refs list' '\n>   \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n>   \t\t<expect >actual &&\n>   \ttest_cmp expect actual\n>   '\n> @@ -149,7 +149,7 @@ EOF\n>   \n>   test_expect_success '--cherry-mark' '\n>   \tgit rev-list --cherry-mark F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> @@ -163,7 +163,7 @@ EOF\n>   \n>   test_expect_success '--cherry-mark --left-right' '\n>   \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> @@ -174,14 +174,14 @@ EOF\n>   \n>   test_expect_success '--cherry-pick --right-only' '\n>   \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n>   \n>   test_expect_success '--cherry-pick --left-only' '\n>   \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> @@ -193,7 +193,7 @@ EOF\n>   \n>   test_expect_success '--cherry' '\n>   \tgit rev-list --cherry F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>   \t\t< actual > actual.named &&\n>   \ttest_cmp expect actual.named\n>   '\n> diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\n> index 4f7fa8b6c03..4fedc614fa6 100755\n> --- a/t/t6012-rev-list-simplify.sh\n> +++ b/t/t6012-rev-list-simplify.sh\n> @@ -12,7 +12,7 @@ note () {\n>   }\n>   \n>   unnote () {\n> -\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n> +\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n>   }\n>   \n>   #\n> diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\n> index e07b6070e0e..90ff1416400 100755\n> --- a/t/t6111-rev-list-treesame.sh\n> +++ b/t/t6111-rev-list-treesame.sh\n> @@ -23,7 +23,8 @@ note () {\n>   }\n>   \n>   unnote () {\n> -\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n> +\tgit name-rev --tags --annotate-stdin | \\\n> +\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n>   }\n>   \n>   test_expect_success setup '\n> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\n> index d8af2bb9d2b..9781b92aedd 100755\n> --- a/t/t6120-describe.sh\n> +++ b/t/t6120-describe.sh\n> @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n>   \ttest_cmp expect actual\n>   '\n>   \n> -test_expect_success 'name-rev --stdin' '\n> +test_expect_success 'name-rev --annotate-stdin' '\n>   \t>expect.unsorted &&\n>   \tfor rev in $(git rev-list --all)\n>   \tdo\n> @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n>   \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n>   \tdone &&\n>   \tsort <expect.unsorted >expect &&\n> -\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n> +\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n>   \tsort <actual.unsorted >actual &&\n>   \ttest_cmp expect actual\n>   '\n>   \n> +test_expect_success 'name-rev --stdin deprecated' \"\n> +\tgit rev-list --all | git name-rev --stdin 2>actual &&\n> +\tgrep -E 'warning: --stdin is deprecated' actual\n> +\"\n> +\n>   test_expect_success 'describe --contains with the exact tags' '\n>   \techo \"A^0\" >expect &&\n>   \ttag_object=$(git rev-parse refs/tags/A) &&\n> \n\n"},{"id":"445556","messageId":"xmqqr19mhsmz.fsf@gitster.g","threadId":"57152","inReplyTo":"16666d32-833a-f3d7-351a-eeef7f25b002@gmail.com","subject":"Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-05T19:47:16Z","receivedAt":"2022-01-05T19:47:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n>> @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>>   \tfor_each_ref(name_ref, &data);\n>>   \tname_tips();\n>>   -\tif (transform_stdin) {\n>> -\t\tchar buffer[2048];\n>> +\tif (annotate_stdin) {\n>> +\t\tstruct strbuf sb = STRBUF_INIT;\n>\n> I think this hunk belongs in the next patch. Before posting a patch\n> series I find it helpful to run\n>\n>     git rebase --keep-base -x'make -j4 git && cd t && prove -j4 <tests\n>     I think might fail> :: --root=/dev/shm'\n>\n> to check that the individual patches compile and pass the relevant\n> tests. I've never got round to trying it but git-test[1] also lets you \n> test all the commits in a series\n\nAhh, I saw and pointed out exactly the same mistake in an earlier\nround, but failed to spot it this time around.  Thanks for spotting.\n"},{"id":"445557","messageId":"xmqqmtkahsez.fsf@gitster.g","threadId":"57152","inReplyTo":"16666d32-833a-f3d7-351a-eeef7f25b002@gmail.com","subject":"Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-05T19:52:04Z","receivedAt":"2022-01-05T19:52:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phillip Wood <phillip.wood123@gmail.com> writes:\n\n>> @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>>   \t\tOPT_GROUP(\"\"),\n>>   \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n>>   \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n>\n> If the intention is to deprecate this option then it might be worth\n> marking it as PARSE_OPT_HIDDEN so that it is not shown by 'git\n> name-rev -h'. (You need to change OPT_BOOL to OPT_BOOL_F to pass the\n> flag)\n\nWhether we want to do HIDDEN now or not, it is probably a good idea\nto update the help text to \n\n\tN_(\"deprecated synonym to --annotate-stdin\")\n\nor something like that.\n"},{"id":"445570","messageId":"xmqqh7aihrpx.fsf@gitster.g","threadId":"57152","inReplyTo":"7c5fb10d87c4b807567db0ed83f987487532c7c1.1641356439.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v5 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-05T20:07:06Z","receivedAt":"2022-01-05T20:07:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +\taltogether.\n> ++\n> +For example:\n> ++\n> +--\n> +\t$ cat sample.txt\n> +\n> +\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n> +\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n> +\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +\t$ git name-rev --annotate-stdin <sample.txt\n> +\n> +\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n> +\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n> +\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +\t$ git name-rev --name-only --annotate-stdin <sample.txt\n> +\n> +\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n> +\tThe full name after substitution is master,\n> +\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +--\n\nI compared the output from the earlier ones with this one; the way\nthe displayed sample was shown in the previous rounds looked better,\nat least in HTML pages.  The earlier ones used \"listingblock\" in\nwhich the sample is contained in a <pre>formatted <code> block, but\nthis one ends up in a series of one-<div>-per-paragraph.\n\n> -\tif (transform_stdin) {\n> -\t\tchar buffer[2048];\n> +\tif (annotate_stdin) {\n> +\t\tstruct strbuf sb = STRBUF_INIT;\n\nThis will break the compilation at this step.\n"},{"id":"445587","messageId":"pull.1171.v6.git.git.1641423600.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v5.git.git.1641356439.gitgitgadget@gmail.com","subject":"[PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T22:59:58Z","receivedAt":"2022-01-05T23:00:11Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can be a\nconfusing and misleading name, the goal is to rename it to --annotate-stdin.\n\nThis is the first step in a process of eventually fully deprecating --stdin.\nThis change also adds a warning to --stdin warning that it will be removed\nin the future.\n\nSee https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion.\n\nchanges since v5:\n\n * fixed documentation example indentation (again)\n * moved initialization of strbuf from 1/2 to 2/2\n\nchanges since v4:\n\n * fixed documentation example indentation\n\nchanges since v3:\n\n * use strbuf_getline instead of strbuf_getwholeline (based on Junio's\n   feedback)\n * fixed commit message s/annotate-text/annotate-stdin (based on Junio's\n   feedback)\n * since strbuf_getline does not keep the trailing terminator, add back '\\n'\n   with strbuf_addchr\n * reordered documentation blocks based on (Philip Oakley's feedback)\n * fixed doc typos in example block\n\nJohn Cai (2):\n  name-rev: deprecate --stdin in favor of --annotate-stdin\n  name-rev.c: use strbuf_getline instead of limited size buffer\n\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 30 ++++++++++++++++++----------\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 72 insertions(+), 32 deletions(-)\n\n\nbase-commit: c8b2ade48c204690119936ada89cd938c476c5c2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v6\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v6\nPull-Request: https://github.com/git/git/pull/1171\n\nRange-diff vs v5:\n\n 1:  7c5fb10d87c ! 1:  3caf254a73e name-rev: deprecate --stdin in favor of --annotate-stdin\n     @@ Documentation/git-name-rev.txt: OPTIONS\n      ++\n      +For example:\n      ++\n     -+--\n     -+\t$ cat sample.txt\n     ++-----------\n     ++$ cat sample.txt\n      +\n     -+\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n     -+\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     ++An abbreviated revision 2ae0a9cb82 will not be substituted.\n     ++The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n     ++while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +\n     -+\t$ git name-rev --annotate-stdin <sample.txt\n     ++$ git name-rev --annotate-stdin <sample.txt\n      +\n     -+\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+\tThe full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n     -+\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     ++An abbreviated revision 2ae0a9cb82 will not be substituted.\n     ++The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n     ++while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n      +\n     -+\t$ git name-rev --name-only --annotate-stdin <sample.txt\n     ++$ git name-rev --name-only --annotate-stdin <sample.txt\n      +\n     -+\tAn abbreviated revision 2ae0a9cb82 will not be substituted.\n     -+\tThe full name after substitution is master,\n     -+\twhile its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     -+--\n     ++An abbreviated revision 2ae0a9cb82 will not be substituted.\n     ++The full name after substitution is master,\n     ++while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n     ++-----------\n      +\n      +--stdin::\n      +\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n     @@ builtin/name-rev.c: static void name_rev_line(char *p, struct name_ref_data *dat\n       \tstruct option opts[] = {\n       \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n      @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *prefix)\n     + \t\t\t\t   N_(\"ignore refs matching <pattern>\")),\n       \t\tOPT_GROUP(\"\"),\n       \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n     - \t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n     +-\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n     ++\t\tOPT_BOOL_F(0, \"stdin\", &transform_stdin, N_(\"deprecated: use annotate-stdin instead\"), PARSE_OPT_HIDDEN),\n      +\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n       \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n       \t\tOPT_BOOL(0, \"always\",     &always,\n     @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr\n       \tname_tips();\n       \n      -\tif (transform_stdin) {\n     --\t\tchar buffer[2048];\n      +\tif (annotate_stdin) {\n     -+\t\tstruct strbuf sb = STRBUF_INIT;\n     + \t\tchar buffer[2048];\n       \n       \t\twhile (!feof(stdin)) {\n     - \t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n      \n       ## t/t3412-rebase-root.sh ##\n      @@ t/t3412-rebase-root.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n 2:  2acd70f36e7 ! 2:  32ad96530b9 name-rev.c: use strbuf_getline instead of limited size buffer\n     @@ Commit message\n      \n       ## builtin/name-rev.c ##\n      @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *prefix)\n     + \tname_tips();\n     + \n       \tif (annotate_stdin) {\n     - \t\tstruct strbuf sb = STRBUF_INIT;\n     +-\t\tchar buffer[2048];\n     ++\t\tstruct strbuf sb = STRBUF_INIT;\n       \n      -\t\twhile (!feof(stdin)) {\n      -\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n\n-- \ngitgitgadget\n"},{"id":"445588","messageId":"3caf254a73e26b4eb7397ba386c2bb0e5da36168.1641423600.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v6.git.git.1641423600.gitgitgadget@gmail.com","subject":"[PATCH v6 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T22:59:59Z","receivedAt":"2022-01-05T23:00:14Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nIntroduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can\nbe a confusing and misleading name, rename it to --annotate-stdin.\n\nThis change adds a warning to --stdin warning that it will be removed in\nthe future.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 19 +++++++++++++-----\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 67 insertions(+), 26 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 5cb0eb0855f..ec8a27ce8bf 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -42,11 +42,37 @@ OPTIONS\n --all::\n \tList all commits reachable from all refs\n \n---stdin::\n+--annotate-stdin::\n \tTransform stdin by substituting all the 40-character SHA-1\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n-\taltogether.  Intended for the scripter's use.\n+\taltogether.\n++\n+For example:\n++\n+-----------\n+$ cat sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --name-only --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is master,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+-----------\n+\n+--stdin::\n+\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n+\tThey are functionally equivalent.\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 27f60153a6c..4941cfb4340 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = OBJECT_ARRAY_INIT;\n-\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n+\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n \tstruct option opts[] = {\n \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n@@ -538,7 +538,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\t\t   N_(\"ignore refs matching <pattern>\")),\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n-\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n+\t\tOPT_BOOL_F(0, \"stdin\", &transform_stdin, N_(\"deprecated: use annotate-stdin instead\"), PARSE_OPT_HIDDEN),\n+\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n \t\tOPT_BOOL(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n@@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tinit_commit_rev_name(&rev_names);\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n-\tif (all + transform_stdin + !!argc > 1) {\n+\n+\tif (transform_stdin) {\n+\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n+\t\t\t\t\t\"which is functionally equivalent.\\n\"\n+\t\t\t\t\t\"This option will be removed in a future release.\");\n+\t\tannotate_stdin = 1;\n+\t}\n+\n+\tif (all + annotate_stdin + !!argc > 1) {\n \t\terror(\"Specify either a list, or --all, not both!\");\n \t\tusage_with_options(name_rev_usage, opts);\n \t}\n-\tif (all || transform_stdin)\n+\tif (all || annotate_stdin)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n@@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tfor_each_ref(name_ref, &data);\n \tname_tips();\n \n-\tif (transform_stdin) {\n+\tif (annotate_stdin) {\n \t\tchar buffer[2048];\n \n \t\twhile (!feof(stdin)) {\ndiff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\nindex 19c6f4acbf6..1e9f7833dd6 100755\n--- a/t/t3412-rebase-root.sh\n+++ b/t/t3412-rebase-root.sh\n@@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n log_with_names () {\n \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n-\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n+\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n }\n \n \ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 50495598619..dc884107de4 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -659,7 +659,7 @@ EOF\n \n test_expect_success 'log --graph with full output' '\n \tgit log --graph --date-order --pretty=short |\n-\t\tgit name-rev --name-only --stdin |\n+\t\tgit name-rev --name-only --annotate-stdin |\n \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex aebe4b69e13..6f3e5439771 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -58,7 +58,7 @@ EOF\n \n test_expect_success '--left-right' '\n \tgit rev-list --left-right B...C > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -78,14 +78,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty' '\n \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'bar does not come up empty' '\n \tgit rev-list --left-right B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -97,14 +97,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty (II)' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev multiple --refs combine inclusive' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -116,7 +116,7 @@ EOF\n test_expect_success 'name-rev --refs excludes non-matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -128,14 +128,14 @@ EOF\n test_expect_success 'name-rev --exclude excludes matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev --no-refs clears the refs list' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n \t\t<expect >actual &&\n \ttest_cmp expect actual\n '\n@@ -149,7 +149,7 @@ EOF\n \n test_expect_success '--cherry-mark' '\n \tgit rev-list --cherry-mark F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -163,7 +163,7 @@ EOF\n \n test_expect_success '--cherry-mark --left-right' '\n \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -174,14 +174,14 @@ EOF\n \n test_expect_success '--cherry-pick --right-only' '\n \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success '--cherry-pick --left-only' '\n \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -193,7 +193,7 @@ EOF\n \n test_expect_success '--cherry' '\n \tgit rev-list --cherry F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\ndiff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\nindex 4f7fa8b6c03..4fedc614fa6 100755\n--- a/t/t6012-rev-list-simplify.sh\n+++ b/t/t6012-rev-list-simplify.sh\n@@ -12,7 +12,7 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n+\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n }\n \n #\ndiff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\nindex e07b6070e0e..90ff1416400 100755\n--- a/t/t6111-rev-list-treesame.sh\n+++ b/t/t6111-rev-list-treesame.sh\n@@ -23,7 +23,8 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n+\tgit name-rev --tags --annotate-stdin | \\\n+\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n }\n \n test_expect_success setup '\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex d8af2bb9d2b..9781b92aedd 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'name-rev --stdin' '\n+test_expect_success 'name-rev --annotate-stdin' '\n \t>expect.unsorted &&\n \tfor rev in $(git rev-list --all)\n \tdo\n@@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n \tdone &&\n \tsort <expect.unsorted >expect &&\n-\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n+\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n \tsort <actual.unsorted >actual &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'name-rev --stdin deprecated' \"\n+\tgit rev-list --all | git name-rev --stdin 2>actual &&\n+\tgrep -E 'warning: --stdin is deprecated' actual\n+\"\n+\n test_expect_success 'describe --contains with the exact tags' '\n \techo \"A^0\" >expect &&\n \ttag_object=$(git rev-parse refs/tags/A) &&\n-- \ngitgitgadget\n\n"},{"id":"445589","messageId":"32ad96530b98d6def19c6871e30ad1774e55626a.1641423600.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v6.git.git.1641423600.gitgitgadget@gmail.com","subject":"[PATCH v6 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T23:00:00Z","receivedAt":"2022-01-05T23:00:17Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nUsing a buffer limited to 2048 is unnecessarily limiting. Switch to\nusing a string buffer to read in stdin for annotation.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n builtin/name-rev.c | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 4941cfb4340..7164b54cb79 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tname_tips();\n \n \tif (annotate_stdin) {\n-\t\tchar buffer[2048];\n+\t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\twhile (!feof(stdin)) {\n-\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n-\t\t\tif (!p)\n-\t\t\t\tbreak;\n-\t\t\tname_rev_line(p, &data);\n+\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n+\t\t\tstrbuf_addch(&sb, '\\n');\n+\t\t\tname_rev_line(sb.buf, &data);\n \t\t}\n+\t\tstrbuf_release(&sb);\n \t} else if (all) {\n \t\tint i, max;\n \n-- \ngitgitgadget\n"},{"id":"445590","messageId":"xmqqfsq1g4la.fsf@gitster.g","threadId":"57152","inReplyTo":"pull.1171.v6.git.git.1641423600.gitgitgadget@gmail.com","subject":"Re: [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-05T23:12:01Z","receivedAt":"2022-01-05T23:12:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"John Cai via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n> --stdin does not behave as --stdin in other subcommands, such as\n> pack-objects whereby it takes one argument per line. Since --stdin can be a\n> confusing and misleading name, the goal is to rename it to --annotate-stdin.\n>\n> This is the first step in a process of eventually fully deprecating --stdin.\n> This change also adds a warning to --stdin warning that it will be removed\n> in the future.\n>\n> See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion.\n>\n> changes since v5:\n>\n>  * fixed documentation example indentation (again)\n>  * moved initialization of strbuf from 1/2 to 2/2\n\nThis round looks almost perfect.\n\nOne I can think of that _may_ be a good idea to change from this\nversion is to undo the HIDDEN thing, so that \"git name-rev -h\",\nwithout \"git name-rev --help-all\", will prominently say that\n\"--stdin\" is deprecated, and make it an hidden option sometime\nlater, but that is not even \"I think we should do so\", but more like\n\"if other people think it is a good idea, I would be supportive\".\n\nThanks.\n\n"},{"id":"445594","messageId":"pull.1171.v7.git.git.1641425372.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v6.git.git.1641423600.gitgitgadget@gmail.com","subject":"[PATCH v7 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T23:29:30Z","receivedAt":"2022-01-05T23:29:40Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can be a\nconfusing and misleading name, the goal is to rename it to --annotate-stdin.\n\nThis is the first step in a process of eventually fully deprecating --stdin.\nThis change also adds a warning to --stdin warning that it will be removed\nin the future.\n\nSee https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion.\n\nchanges since v6:\n\n * change OPT_BOOL from hidden back to normal mode\n\nchanges since v5:\n\n * fixed documentation example indentation (again)\n * moved initialization of strbuf from 1/2 to 2/2\n\nchanges since v4:\n\n * fixed documentation example indentation\n\nchanges since v3:\n\n * use strbuf_getline instead of strbuf_getwholeline (based on Junio's\n   feedback)\n * fixed commit message s/annotate-text/annotate-stdin (based on Junio's\n   feedback)\n * since strbuf_getline does not keep the trailing terminator, add back '\\n'\n   with strbuf_addchr\n * reordered documentation blocks based on (Philip Oakley's feedback)\n * fixed doc typos in example block\n\nJohn Cai (2):\n  name-rev: deprecate --stdin in favor of --annotate-stdin\n  name-rev.c: use strbuf_getline instead of limited size buffer\n\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 30 ++++++++++++++++++----------\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 72 insertions(+), 32 deletions(-)\n\n\nbase-commit: c8b2ade48c204690119936ada89cd938c476c5c2\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v7\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v7\nPull-Request: https://github.com/git/git/pull/1171\n\nRange-diff vs v6:\n\n 1:  3caf254a73e ! 1:  153f69ea9b6 name-rev: deprecate --stdin in favor of --annotate-stdin\n     @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr\n       \t\tOPT_GROUP(\"\"),\n       \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n      -\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n     -+\t\tOPT_BOOL_F(0, \"stdin\", &transform_stdin, N_(\"deprecated: use annotate-stdin instead\"), PARSE_OPT_HIDDEN),\n     ++\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"deprecated: use annotate-stdin instead\")),\n      +\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n       \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n       \t\tOPT_BOOL(0, \"always\",     &always,\n 2:  32ad96530b9 = 2:  19e7bf96557 name-rev.c: use strbuf_getline instead of limited size buffer\n\n-- \ngitgitgadget\n"},{"id":"445595","messageId":"153f69ea9b6cfc3fff47c91fa237cf97efd6bfae.1641425372.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v7.git.git.1641425372.gitgitgadget@gmail.com","subject":"[PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T23:29:31Z","receivedAt":"2022-01-05T23:29:42Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nIntroduce a --annotate-stdin that is functionally equivalent of --stdin.\n--stdin does not behave as --stdin in other subcommands, such as\npack-objects whereby it takes one argument per line. Since --stdin can\nbe a confusing and misleading name, rename it to --annotate-stdin.\n\nThis change adds a warning to --stdin warning that it will be removed in\nthe future.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n builtin/name-rev.c                   | 19 +++++++++++++-----\n t/t3412-rebase-root.sh               |  2 +-\n t/t4202-log.sh                       |  2 +-\n t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n t/t6012-rev-list-simplify.sh         |  2 +-\n t/t6111-rev-list-treesame.sh         |  3 ++-\n t/t6120-describe.sh                  |  9 +++++++--\n 8 files changed, 67 insertions(+), 26 deletions(-)\n\ndiff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\nindex 5cb0eb0855f..ec8a27ce8bf 100644\n--- a/Documentation/git-name-rev.txt\n+++ b/Documentation/git-name-rev.txt\n@@ -42,11 +42,37 @@ OPTIONS\n --all::\n \tList all commits reachable from all refs\n \n---stdin::\n+--annotate-stdin::\n \tTransform stdin by substituting all the 40-character SHA-1\n \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n \t--name-only, substitute with \"$rev_name\", omitting $hex\n-\taltogether.  Intended for the scripter's use.\n+\taltogether.\n++\n+For example:\n++\n+-----------\n+$ cat sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+\n+$ git name-rev --name-only --annotate-stdin <sample.txt\n+\n+An abbreviated revision 2ae0a9cb82 will not be substituted.\n+The full name after substitution is master,\n+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n+-----------\n+\n+--stdin::\n+\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n+\tThey are functionally equivalent.\n \n --name-only::\n \tInstead of printing both the SHA-1 and the name, print only\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 27f60153a6c..8baf5b52d0b 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n int cmd_name_rev(int argc, const char **argv, const char *prefix)\n {\n \tstruct object_array revs = OBJECT_ARRAY_INIT;\n-\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n+\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n \tstruct option opts[] = {\n \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n@@ -538,7 +538,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \t\t\t\t   N_(\"ignore refs matching <pattern>\")),\n \t\tOPT_GROUP(\"\"),\n \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n-\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n+\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"deprecated: use annotate-stdin instead\")),\n+\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n \t\tOPT_BOOL(0, \"always\",     &always,\n \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n@@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tinit_commit_rev_name(&rev_names);\n \tgit_config(git_default_config, NULL);\n \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n-\tif (all + transform_stdin + !!argc > 1) {\n+\n+\tif (transform_stdin) {\n+\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n+\t\t\t\t\t\"which is functionally equivalent.\\n\"\n+\t\t\t\t\t\"This option will be removed in a future release.\");\n+\t\tannotate_stdin = 1;\n+\t}\n+\n+\tif (all + annotate_stdin + !!argc > 1) {\n \t\terror(\"Specify either a list, or --all, not both!\");\n \t\tusage_with_options(name_rev_usage, opts);\n \t}\n-\tif (all || transform_stdin)\n+\tif (all || annotate_stdin)\n \t\tcutoff = 0;\n \n \tfor (; argc; argc--, argv++) {\n@@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tfor_each_ref(name_ref, &data);\n \tname_tips();\n \n-\tif (transform_stdin) {\n+\tif (annotate_stdin) {\n \t\tchar buffer[2048];\n \n \t\twhile (!feof(stdin)) {\ndiff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\nindex 19c6f4acbf6..1e9f7833dd6 100755\n--- a/t/t3412-rebase-root.sh\n+++ b/t/t3412-rebase-root.sh\n@@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n log_with_names () {\n \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n-\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n+\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n }\n \n \ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 50495598619..dc884107de4 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -659,7 +659,7 @@ EOF\n \n test_expect_success 'log --graph with full output' '\n \tgit log --graph --date-order --pretty=short |\n-\t\tgit name-rev --name-only --stdin |\n+\t\tgit name-rev --name-only --annotate-stdin |\n \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n \ttest_cmp expect actual\n '\ndiff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\nindex aebe4b69e13..6f3e5439771 100755\n--- a/t/t6007-rev-list-cherry-pick-file.sh\n+++ b/t/t6007-rev-list-cherry-pick-file.sh\n@@ -58,7 +58,7 @@ EOF\n \n test_expect_success '--left-right' '\n \tgit rev-list --left-right B...C > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -78,14 +78,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty' '\n \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'bar does not come up empty' '\n \tgit rev-list --left-right B...C -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -97,14 +97,14 @@ EOF\n \n test_expect_success '--cherry-pick bar does not come up empty (II)' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev multiple --refs combine inclusive' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -116,7 +116,7 @@ EOF\n test_expect_success 'name-rev --refs excludes non-matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -128,14 +128,14 @@ EOF\n test_expect_success 'name-rev --exclude excludes matched patterns' '\n \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n \t\t<actual >actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success 'name-rev --no-refs clears the refs list' '\n \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n \t\t<expect >actual &&\n \ttest_cmp expect actual\n '\n@@ -149,7 +149,7 @@ EOF\n \n test_expect_success '--cherry-mark' '\n \tgit rev-list --cherry-mark F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -163,7 +163,7 @@ EOF\n \n test_expect_success '--cherry-mark --left-right' '\n \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -174,14 +174,14 @@ EOF\n \n test_expect_success '--cherry-pick --right-only' '\n \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n \n test_expect_success '--cherry-pick --left-only' '\n \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\n@@ -193,7 +193,7 @@ EOF\n \n test_expect_success '--cherry' '\n \tgit rev-list --cherry F...E -- bar > actual &&\n-\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n+\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n \t\t< actual > actual.named &&\n \ttest_cmp expect actual.named\n '\ndiff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\nindex 4f7fa8b6c03..4fedc614fa6 100755\n--- a/t/t6012-rev-list-simplify.sh\n+++ b/t/t6012-rev-list-simplify.sh\n@@ -12,7 +12,7 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n+\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n }\n \n #\ndiff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\nindex e07b6070e0e..90ff1416400 100755\n--- a/t/t6111-rev-list-treesame.sh\n+++ b/t/t6111-rev-list-treesame.sh\n@@ -23,7 +23,8 @@ note () {\n }\n \n unnote () {\n-\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n+\tgit name-rev --tags --annotate-stdin | \\\n+\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n }\n \n test_expect_success setup '\ndiff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\nindex d8af2bb9d2b..9781b92aedd 100755\n--- a/t/t6120-describe.sh\n+++ b/t/t6120-describe.sh\n@@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n \ttest_cmp expect actual\n '\n \n-test_expect_success 'name-rev --stdin' '\n+test_expect_success 'name-rev --annotate-stdin' '\n \t>expect.unsorted &&\n \tfor rev in $(git rev-list --all)\n \tdo\n@@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n \tdone &&\n \tsort <expect.unsorted >expect &&\n-\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n+\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n \tsort <actual.unsorted >actual &&\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'name-rev --stdin deprecated' \"\n+\tgit rev-list --all | git name-rev --stdin 2>actual &&\n+\tgrep -E 'warning: --stdin is deprecated' actual\n+\"\n+\n test_expect_success 'describe --contains with the exact tags' '\n \techo \"A^0\" >expect &&\n \ttag_object=$(git rev-parse refs/tags/A) &&\n-- \ngitgitgadget\n\n"},{"id":"445596","messageId":"19e7bf965574652840c5e0cde6f3dd188bec82b0.1641425372.git.gitgitgadget@gmail.com","threadId":"57152","inReplyTo":"pull.1171.v7.git.git.1641425372.gitgitgadget@gmail.com","subject":"[PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"John Cai via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-01-05T23:29:32Z","receivedAt":"2022-01-05T23:29:46Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"From: John Cai <johncai86@gmail.com>\n\nUsing a buffer limited to 2048 is unnecessarily limiting. Switch to\nusing a string buffer to read in stdin for annotation.\n\nSigned-off-by: \"John Cai\" <johncai86@gmail.com>\n---\n builtin/name-rev.c | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 8baf5b52d0b..138e3c30a2b 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tname_tips();\n \n \tif (annotate_stdin) {\n-\t\tchar buffer[2048];\n+\t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\twhile (!feof(stdin)) {\n-\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n-\t\t\tif (!p)\n-\t\t\t\tbreak;\n-\t\t\tname_rev_line(p, &data);\n+\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n+\t\t\tstrbuf_addch(&sb, '\\n');\n+\t\t\tname_rev_line(sb.buf, &data);\n \t\t}\n+\t\tstrbuf_release(&sb);\n \t} else if (all) {\n \t\tint i, max;\n \n-- \ngitgitgadget\n"},{"id":"445793","messageId":"56FFAD1E-D081-4D13-A12E-DD6807375B69@gmail.com","threadId":"57152","inReplyTo":"153f69ea9b6cfc3fff47c91fa237cf97efd6bfae.1641425372.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai","fromEmail":"johncai86@gmail.com","sentAt":"2022-01-08T13:47:30Z","receivedAt":"2022-01-08T13:47:34Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Hi Junio,\n\nOn 5 Jan 2022, at 18:29, John Cai via GitGitGadget wrote:\n\n> From: John Cai <johncai86@gmail.com>\n>\n> Introduce a --annotate-stdin that is functionally equivalent of --stdin.\n> --stdin does not behave as --stdin in other subcommands, such as\n> pack-objects whereby it takes one argument per line. Since --stdin can\n> be a confusing and misleading name, rename it to --annotate-stdin.\n>\n> This change adds a warning to --stdin warning that it will be removed in\n> the future.\n>\n> Signed-off-by: \"John Cai\" <johncai86@gmail.com>\n> ---\n>  Documentation/git-name-rev.txt       | 30 ++++++++++++++++++++++++++--\n>  builtin/name-rev.c                   | 19 +++++++++++++-----\n>  t/t3412-rebase-root.sh               |  2 +-\n>  t/t4202-log.sh                       |  2 +-\n>  t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------\n>  t/t6012-rev-list-simplify.sh         |  2 +-\n>  t/t6111-rev-list-treesame.sh         |  3 ++-\n>  t/t6120-describe.sh                  |  9 +++++++--\n>  8 files changed, 67 insertions(+), 26 deletions(-)\n>\n> diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt\n> index 5cb0eb0855f..ec8a27ce8bf 100644\n> --- a/Documentation/git-name-rev.txt\n> +++ b/Documentation/git-name-rev.txt\n> @@ -42,11 +42,37 @@ OPTIONS\n>  --all::\n>  \tList all commits reachable from all refs\n>\n> ---stdin::\n> +--annotate-stdin::\n>  \tTransform stdin by substituting all the 40-character SHA-1\n>  \thexes (say $hex) with \"$hex ($rev_name)\".  When used with\n>  \t--name-only, substitute with \"$rev_name\", omitting $hex\n> -\taltogether.  Intended for the scripter's use.\n> +\taltogether.\n> ++\n> +For example:\n> ++\n> +-----------\n> +$ cat sample.txt\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907,\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +$ git name-rev --annotate-stdin <sample.txt\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master),\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +\n> +$ git name-rev --name-only --annotate-stdin <sample.txt\n> +\n> +An abbreviated revision 2ae0a9cb82 will not be substituted.\n> +The full name after substitution is master,\n> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad\n> +-----------\n> +\n> +--stdin::\n> +\tThis option is deprecated in favor of 'git name-rev --annotate-stdin'.\n> +\tThey are functionally equivalent.\n>\n>  --name-only::\n>  \tInstead of printing both the SHA-1 and the name, print only\n> diff --git a/builtin/name-rev.c b/builtin/name-rev.c\n> index 27f60153a6c..8baf5b52d0b 100644\n> --- a/builtin/name-rev.c\n> +++ b/builtin/name-rev.c\n> @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)\n>  int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  {\n>  \tstruct object_array revs = OBJECT_ARRAY_INIT;\n> -\tint all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n> +\tint all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;\n>  \tstruct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };\n>  \tstruct option opts[] = {\n>  \t\tOPT_BOOL(0, \"name-only\", &data.name_only, N_(\"print only ref-based names (no object names)\")),\n> @@ -538,7 +538,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \t\t\t\t   N_(\"ignore refs matching <pattern>\")),\n>  \t\tOPT_GROUP(\"\"),\n>  \t\tOPT_BOOL(0, \"all\", &all, N_(\"list all commits reachable from all refs\")),\n> -\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"read from stdin\")),\n> +\t\tOPT_BOOL(0, \"stdin\", &transform_stdin, N_(\"deprecated: use annotate-stdin instead\")),\n> +\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n>  \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n\nI’ve changed this back to a non hidden bool. I believe this should be the last thing needed on this one.\nLet me know if anything else needs adjustment, thanks!\n\n>  \t\tOPT_BOOL(0, \"always\",     &always,\n>  \t\t\t   N_(\"show abbreviated commit object as fallback\")),\n> @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tinit_commit_rev_name(&rev_names);\n>  \tgit_config(git_default_config, NULL);\n>  \targc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);\n> -\tif (all + transform_stdin + !!argc > 1) {\n> +\n> +\tif (transform_stdin) {\n> +\t\twarning(\"--stdin is deprecated. Please use --annotate-stdin instead, \"\n> +\t\t\t\t\t\"which is functionally equivalent.\\n\"\n> +\t\t\t\t\t\"This option will be removed in a future release.\");\n> +\t\tannotate_stdin = 1;\n> +\t}\n> +\n> +\tif (all + annotate_stdin + !!argc > 1) {\n>  \t\terror(\"Specify either a list, or --all, not both!\");\n>  \t\tusage_with_options(name_rev_usage, opts);\n>  \t}\n> -\tif (all || transform_stdin)\n> +\tif (all || annotate_stdin)\n>  \t\tcutoff = 0;\n>\n>  \tfor (; argc; argc--, argv++) {\n> @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tfor_each_ref(name_ref, &data);\n>  \tname_tips();\n>\n> -\tif (transform_stdin) {\n> +\tif (annotate_stdin) {\n>  \t\tchar buffer[2048];\n>\n>  \t\twhile (!feof(stdin)) {\n> diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh\n> index 19c6f4acbf6..1e9f7833dd6 100755\n> --- a/t/t3412-rebase-root.sh\n> +++ b/t/t3412-rebase-root.sh\n> @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n>\n>  log_with_names () {\n>  \tgit rev-list --topo-order --parents --pretty=\"tformat:%s\" HEAD |\n> -\tgit name-rev --stdin --name-only --refs=refs/heads/$1\n> +\tgit name-rev --annotate-stdin --name-only --refs=refs/heads/$1\n>  }\n>\n>\n> diff --git a/t/t4202-log.sh b/t/t4202-log.sh\n> index 50495598619..dc884107de4 100755\n> --- a/t/t4202-log.sh\n> +++ b/t/t4202-log.sh\n> @@ -659,7 +659,7 @@ EOF\n>\n>  test_expect_success 'log --graph with full output' '\n>  \tgit log --graph --date-order --pretty=short |\n> -\t\tgit name-rev --name-only --stdin |\n> +\t\tgit name-rev --name-only --annotate-stdin |\n>  \t\tsed \"s/Merge:.*/Merge: A B/;s/ *\\$//\" >actual &&\n>  \ttest_cmp expect actual\n>  '\n> diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh\n> index aebe4b69e13..6f3e5439771 100755\n> --- a/t/t6007-rev-list-cherry-pick-file.sh\n> +++ b/t/t6007-rev-list-cherry-pick-file.sh\n> @@ -58,7 +58,7 @@ EOF\n>\n>  test_expect_success '--left-right' '\n>  \tgit rev-list --left-right B...C > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -78,14 +78,14 @@ EOF\n>\n>  test_expect_success '--cherry-pick bar does not come up empty' '\n>  \tgit rev-list --left-right --cherry-pick B...C -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>\n>  test_expect_success 'bar does not come up empty' '\n>  \tgit rev-list --left-right B...C -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -97,14 +97,14 @@ EOF\n>\n>  test_expect_success '--cherry-pick bar does not come up empty (II)' '\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>\n>  test_expect_success 'name-rev multiple --refs combine inclusive' '\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" \\\n>  \t\t<actual >actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -116,7 +116,7 @@ EOF\n>  test_expect_success 'name-rev --refs excludes non-matched patterns' '\n>  \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" \\\n>  \t\t<actual >actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -128,14 +128,14 @@ EOF\n>  test_expect_success 'name-rev --exclude excludes matched patterns' '\n>  \tgit rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect &&\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" --exclude=\"*E\" \\\n>  \t\t<actual >actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>\n>  test_expect_success 'name-rev --no-refs clears the refs list' '\n>  \tgit rev-list --left-right --cherry-pick F...E -- bar >expect &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/F\" --refs=\"*tags/E\" --no-refs --refs=\"*tags/G\" \\\n>  \t\t<expect >actual &&\n>  \ttest_cmp expect actual\n>  '\n> @@ -149,7 +149,7 @@ EOF\n>\n>  test_expect_success '--cherry-mark' '\n>  \tgit rev-list --cherry-mark F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -163,7 +163,7 @@ EOF\n>\n>  test_expect_success '--cherry-mark --left-right' '\n>  \tgit rev-list --cherry-mark --left-right F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -174,14 +174,14 @@ EOF\n>\n>  test_expect_success '--cherry-pick --right-only' '\n>  \tgit rev-list --cherry-pick --right-only F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n>\n>  test_expect_success '--cherry-pick --left-only' '\n>  \tgit rev-list --cherry-pick --left-only E...F -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> @@ -193,7 +193,7 @@ EOF\n>\n>  test_expect_success '--cherry' '\n>  \tgit rev-list --cherry F...E -- bar > actual &&\n> -\tgit name-rev --stdin --name-only --refs=\"*tags/*\" \\\n> +\tgit name-rev --annotate-stdin --name-only --refs=\"*tags/*\" \\\n>  \t\t< actual > actual.named &&\n>  \ttest_cmp expect actual.named\n>  '\n> diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\n> index 4f7fa8b6c03..4fedc614fa6 100755\n> --- a/t/t6012-rev-list-simplify.sh\n> +++ b/t/t6012-rev-list-simplify.sh\n> @@ -12,7 +12,7 @@ note () {\n>  }\n>\n>  unnote () {\n> -\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n> +\tgit name-rev --tags --annotate-stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\)) |\\1 |g\"\n>  }\n>\n>  #\n> diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh\n> index e07b6070e0e..90ff1416400 100755\n> --- a/t/t6111-rev-list-treesame.sh\n> +++ b/t/t6111-rev-list-treesame.sh\n> @@ -23,7 +23,8 @@ note () {\n>  }\n>\n>  unnote () {\n> -\tgit name-rev --tags --stdin | sed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n> +\tgit name-rev --tags --annotate-stdin | \\\n> +\tsed -e \"s|$OID_REGEX (tags/\\([^)]*\\))\\([ \t]\\)|\\1\\2|g\"\n>  }\n>\n>  test_expect_success setup '\n> diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh\n> index d8af2bb9d2b..9781b92aedd 100755\n> --- a/t/t6120-describe.sh\n> +++ b/t/t6120-describe.sh\n> @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' '\n>  \ttest_cmp expect actual\n>  '\n>\n> -test_expect_success 'name-rev --stdin' '\n> +test_expect_success 'name-rev --annotate-stdin' '\n>  \t>expect.unsorted &&\n>  \tfor rev in $(git rev-list --all)\n>  \tdo\n> @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' '\n>  \t\techo \"$rev ($name)\" >>expect.unsorted || return 1\n>  \tdone &&\n>  \tsort <expect.unsorted >expect &&\n> -\tgit rev-list --all | git name-rev --stdin >actual.unsorted &&\n> +\tgit rev-list --all | git name-rev --annotate-stdin >actual.unsorted &&\n>  \tsort <actual.unsorted >actual &&\n>  \ttest_cmp expect actual\n>  '\n>\n> +test_expect_success 'name-rev --stdin deprecated' \"\n> +\tgit rev-list --all | git name-rev --stdin 2>actual &&\n> +\tgrep -E 'warning: --stdin is deprecated' actual\n> +\"\n> +\n>  test_expect_success 'describe --contains with the exact tags' '\n>  \techo \"A^0\" >expect &&\n>  \ttag_object=$(git rev-parse refs/tags/A) &&\n> -- \n> gitgitgadget\n"},{"id":"445844","messageId":"xmqqo84j1oel.fsf@gitster.g","threadId":"57152","inReplyTo":"56FFAD1E-D081-4D13-A12E-DD6807375B69@gmail.com","subject":"Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-10T17:38:58Z","receivedAt":"2022-01-10T17:39:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Cai <johncai86@gmail.com> writes:\n\n> Hi Junio,\n>\n> ...\n\nPlease trim quotes that are irrelevant for understanding what you\nwant to say in your message to save recipient's time to find what\nyou wrote.\n\n>> +\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n>>  \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n>\n> I’ve changed this back to a non hidden bool. I believe this should be the last thing needed on this one.\n> Let me know if anything else needs adjustment, thanks!\n\nAs I said, my mention of hidden vs non-hidden was not my preferrence\nof non-hidden over hidden, but was soliciting opinions from others,\nso I was a bit surprised to see a reroll to change only that thing\nand nothing else so soon.\n\nBut if it is your preference to leave it unhidden for now, that is\nfine as well.  I have no strong preference over the matter either\nway.\n\nI see only Dscho on the CC list, but I have this feeling that he\nwasn't the one who suggested to hide the old option.  Whoever it\nwas, if we can get an ack from them, that would be nicer.\n\nThanks for working on this.\n"},{"id":"445864","messageId":"A869C5DC-98D0-4093-90ED-5F7933041968@gmail.com","threadId":"57152","inReplyTo":"xmqqo84j1oel.fsf@gitster.g","subject":"Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"John Cai","fromEmail":"johncai86@gmail.com","sentAt":"2022-01-10T19:01:06Z","receivedAt":"2022-01-10T19:01:11Z","isPatch":true,"sender":{"key":"johncai86@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2354211?v=4"},"body":"Cc’ing Phillip, as he was the one who made the suggestion to make it hidden\n\nOn 10 Jan 2022, at 12:38, Junio C Hamano wrote:\n\n> John Cai <johncai86@gmail.com> writes:\n>\n>> Hi Junio,\n>>\n>> ...\n>\n> Please trim quotes that are irrelevant for understanding what you\n> want to say in your message to save recipient's time to find what\n> you wrote.\n>\n>>> +\t\tOPT_BOOL(0, \"annotate-stdin\", &annotate_stdin, N_(\"annotate text from stdin\")),\n>>>  \t\tOPT_BOOL(0, \"undefined\", &allow_undefined, N_(\"allow to print `undefined` names (default)\")),\n>>\n>> I’ve changed this back to a non hidden bool. I believe this should be the last thing needed on this one.\n>> Let me know if anything else needs adjustment, thanks!\n>\n> As I said, my mention of hidden vs non-hidden was not my preferrence\n> of non-hidden over hidden, but was soliciting opinions from others,\n> so I was a bit surprised to see a reroll to change only that thing\n> and nothing else so soon.\n>\n> But if it is your preference to leave it unhidden for now, that is\n> fine as well.  I have no strong preference over the matter either\n> way.\n\nI think it makes sense in this first iteration to keep it non-hidden for visibility purposes.\nMaybe in the next release we can make it hidden before we move it altogether.\n\n>\n> I see only Dscho on the CC list, but I have this feeling that he\n> wasn't the one who suggested to hide the old option.  Whoever it\n> was, if we can get an ack from them, that would be nicer.\n>\n> Thanks for working on this.\n"},{"id":"445866","messageId":"xmqqo84jz9qf.fsf@gitster.g","threadId":"57152","inReplyTo":"A869C5DC-98D0-4093-90ED-5F7933041968@gmail.com","subject":"Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-01-10T19:11:52Z","receivedAt":"2022-01-10T19:11:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"John Cai <johncai86@gmail.com> writes:\n\n>> As I said, my mention of hidden vs non-hidden was not my preferrence\n>> of non-hidden over hidden, but was soliciting opinions from others,\n>> so I was a bit surprised to see a reroll to change only that thing\n>> and nothing else so soon.\n>>\n>> But if it is your preference to leave it unhidden for now, that is\n>> fine as well.  I have no strong preference over the matter either\n>> way.\n>\n> I think it makes sense in this first iteration to keep it\n> non-hidden for visibility purposes.  Maybe in the next release we\n> can make it hidden before we move it altogether.\n\nI think that is a sensible way forward.\n\n\n"},{"id":"445911","messageId":"8d07e92e-b63a-6be4-6999-79c36ca07cb5@gmail.com","threadId":"57152","inReplyTo":"xmqqo84jz9qf.fsf@gitster.g","subject":"Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin","fromName":"Phillip Wood","fromEmail":"phillip.wood123@gmail.com","sentAt":"2022-01-11T11:01:55Z","receivedAt":"2022-01-11T11:02:01Z","isPatch":true,"sender":{"key":"phillip.wood@dunelm.org.uk","avatar":null},"body":"On 10/01/2022 19:11, Junio C Hamano wrote:\n> John Cai <johncai86@gmail.com> writes:\n> \n>>> As I said, my mention of hidden vs non-hidden was not my preferrence\n>>> of non-hidden over hidden, but was soliciting opinions from others,\n>>> so I was a bit surprised to see a reroll to change only that thing\n>>> and nothing else so soon.\n>>>\n>>> But if it is your preference to leave it unhidden for now, that is\n>>> fine as well.  I have no strong preference over the matter either\n>>> way.\n>>\n>> I think it makes sense in this first iteration to keep it\n>> non-hidden for visibility purposes.  Maybe in the next release we\n>> can make it hidden before we move it altogether.\n> \n> I think that is a sensible way forward.\n\nI agree\n\nThanks\n\nPhillip\n\n"},{"id":"446427","messageId":"220118.865yqhow6z.gmgdl@evledraar.gmail.com","threadId":"57152","inReplyTo":"19e7bf965574652840c5e0cde6f3dd188bec82b0.1641425372.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-01-18T16:09:37Z","receivedAt":"2022-01-18T16:17:30Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Jan 05 2022, John Cai via GitGitGadget wrote:\n\n> From: John Cai <johncai86@gmail.com>\n>\n> Using a buffer limited to 2048 is unnecessarily limiting. Switch to\n> using a string buffer to read in stdin for annotation.\n>\n> Signed-off-by: \"John Cai\" <johncai86@gmail.com>\n> ---\n>  builtin/name-rev.c | 11 +++++------\n>  1 file changed, 5 insertions(+), 6 deletions(-)\n>\n> diff --git a/builtin/name-rev.c b/builtin/name-rev.c\n> index 8baf5b52d0b..138e3c30a2b 100644\n> --- a/builtin/name-rev.c\n> +++ b/builtin/name-rev.c\n> @@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n>  \tname_tips();\n>  \n>  \tif (annotate_stdin) {\n> -\t\tchar buffer[2048];\n> +\t\tstruct strbuf sb = STRBUF_INIT;\n>  \n> -\t\twhile (!feof(stdin)) {\n> -\t\t\tchar *p = fgets(buffer, sizeof(buffer), stdin);\n> -\t\t\tif (!p)\n> -\t\t\t\tbreak;\n> -\t\t\tname_rev_line(p, &data);\n> +\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n> +\t\t\tstrbuf_addch(&sb, '\\n');\n> +\t\t\tname_rev_line(sb.buf, &data);\n>  \t\t}\n> +\t\tstrbuf_release(&sb);\n>  \t} else if (all) {\n>  \t\tint i, max;\n\nMaybe there's a subtlety with \\r in newlines (Windows), but isn't this\ndoing the same thing as:\n\ndiff --git a/builtin/name-rev.c b/builtin/name-rev.c\nindex 138e3c30a2b..03dbf251450 100644\n--- a/builtin/name-rev.c\n+++ b/builtin/name-rev.c\n@@ -625,10 +625,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)\n \tif (annotate_stdin) {\n \t\tstruct strbuf sb = STRBUF_INIT;\n \n-\t\twhile (strbuf_getline(&sb, stdin) != EOF) {\n-\t\t\tstrbuf_addch(&sb, '\\n');\n+\t\twhile (!strbuf_getwholeline(&sb, stdin, '\\n'))\n \t\t\tname_rev_line(sb.buf, &data);\n-\t\t}\n \t\tstrbuf_release(&sb);\n \t} else if (all) {\n \t\tint i, max;\n\nAfter writing that I see this was changed on the basis of Junio's\nfeedback in https://lore.kernel.org/git/xmqqr19ofdo5.fsf@gitster.g/ :)\n\nFWIW I think it's fine as-is, but it also seems that name_rev_line()\nreally doesn't care about lines per-se, but just that we don't split\nOIDs across \"lines\" (as we'll tokenize get_oid() on them). So\ne.g. splitting by ' ' lines (spaces) also works here, but not 'a' (as\nthat would split a [0-9a-f].\n"}]}