* [PATCH] name-rev: deprecate --stdin in favor of --annotate-text @ 2021-12-26 4:28 John Cai via GitGitGadget 2021-12-27 19:49 ` Junio C Hamano 2021-12-29 6:23 ` [PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text John Cai via GitGitGadget 0 siblings, 2 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2021-12-26 4:28 UTC (permalink / raw) To: git; +Cc: John Cai, John Cai From: John Cai <johncai86@gmail.com> Introduce a --annotate-text that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, rename it to --annotate-text. This change adds a warning to --stdin warning that it will be removed in the future. Signed-off-by: "John Cai" <johncai86@gmail.com> --- name-rev: deprecate --stdin in favor of --anotate-text Introduce a --anontate-text that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, the goal is to rename it to --anotate-text. This is the first step in a process of eventually fully deprecating --stdin. This change also adds a warning to --stdin warning that it will be removed in the future. See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v1 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v1 Pull-Request: https://github.com/git/git/pull/1171 Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++- builtin/name-rev.c | 17 +++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 5cb0eb0855f..64d59c6ee1a 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -43,10 +43,37 @@ OPTIONS List all commits reachable from all refs --stdin:: + This option is deprecated in favor of 'git name-rev --annotate-text'. + They are functionally equivalent. + +--annotate-text:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. + + For example: ++ +---------- +$ cat sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --annotate-text < sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 +(master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-text < sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +---------- --name-only:: Instead of printing both the SHA-1 and the name, print only diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 27f60153a6c..73b244a5aac 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; + int all = 0, annotate_text = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), + OPT_BOOL(0, "annotate-text", &annotate_text, N_("annotate text text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) init_commit_rev_name(&rev_names); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { + warning("--stdin is deprecated. Please use --annotate-text instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); + annotate_text = 1; + } + + if (all + annotate_text + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) + if (all || annotate_text) cutoff = 0; for (; argc; argc--, argv++) { @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) for_each_ref(name_ref, &data); name_tips(); - if (transform_stdin) { + if (annotate_text) { char buffer[2048]; while (!feof(stdin)) { base-commit: 2ae0a9cb8298185a94e5998086f380a355dd8907 -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text 2021-12-26 4:28 [PATCH] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget @ 2021-12-27 19:49 ` Junio C Hamano 2021-12-28 5:13 ` John Cai 2022-01-01 22:59 ` Johannes Schindelin 2021-12-29 6:23 ` [PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text John Cai via GitGitGadget 1 sibling, 2 replies; 43+ messages in thread From: Junio C Hamano @ 2021-12-27 19:49 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, John Cai, Johannes Schindelin "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: As name-rev is Dscho's brainchild, I think it is benefitial to ask input from him, so I added an address to the CC: list. > From: John Cai <johncai86@gmail.com> > > Introduce a --annotate-text that is functionally equivalent of --stdin. > --stdin does not behave as --stdin in other subcommands, such as > pack-objects whereby it takes one argument per line. Since --stdin can > be a confusing and misleading name, rename it to --annotate-text. > > This change adds a warning to --stdin warning that it will be removed in > the future. I know I've suggested the name, but 'text' in --annotate-text is a low value word in an option name where every byte is precious. "Annotate" is very good to convey what is done to the object of the verb, but "text" stresses the wrong thing (we do not annotate binary,o we annotate text) without saying where the text comes from (i.e. standard input). Perhaps "--annotate-stdin" would be a much better name. I agree that letting "--stdin" to deviate so much from an emulation of "xargs git name-rev" was indeed a mistake that caused the confusion that led to the other thread. If the mode had a better name from the day 1, the thread would have been avoided. What I am not sure about is how much this transition would hurt existing users and scripts. > + For example: > ++ > +---------- > +$ cat sample.txt > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > +$ git name-rev --annotate-text < sample.txt Lose SP between the redirection operator '<' and its file 'sample.txt'. > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 > +(master), > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > +$ git name-rev --name-only --annotate-text < sample.txt Ditto. > + if (transform_stdin) { > + warning("--stdin is deprecated. Please use --annotate-text instead, " > + "which is functionally equivalent.\n" > + "This option will be removed in a future release."); > + annotate_text = 1; I guess that is sensible. To squelch the warning, they can switch to the new option. > + } > + > + if (all + annotate_text + !!argc > 1) { > error("Specify either a list, or --all, not both!"); > usage_with_options(name_rev_usage, opts); > } > - if (all || transform_stdin) > + if (all || annotate_text) > cutoff = 0; > > for (; argc; argc--, argv++) { > @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > for_each_ref(name_ref, &data); > name_tips(); > > - if (transform_stdin) { > + if (annotate_text) { > char buffer[2048]; > > while (!feof(stdin)) { Not a suggestion to change anything in this patch, but just an observation. - If the mode is useful enough for many users, certainly somebody would have rewritten this loop to lift the line-length limit, but nobody noticed and complained about this 2k limit for the past 17 years. I am not sure if that is an indication that nobody uses the option in its current form. - A low hanging fruit, if we do not go full strbuf_getline(), at least we should narrow the scope of buffer[] array. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text 2021-12-27 19:49 ` Junio C Hamano @ 2021-12-28 5:13 ` John Cai 2021-12-31 8:16 ` Junio C Hamano 2022-01-01 22:59 ` Johannes Schindelin 1 sibling, 1 reply; 43+ messages in thread From: John Cai @ 2021-12-28 5:13 UTC (permalink / raw) To: Junio C Hamano; +Cc: John Cai via GitGitGadget, git, Johannes Schindelin > On Dec 27, 2021, at 11:49 AM, Junio C Hamano <gitster@pobox.com> wrote: > > "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > > As name-rev is Dscho's brainchild, I think it is benefitial to ask input > from him, so I added an address to the CC: list. > >> From: John Cai <johncai86@gmail.com> >> >> Introduce a --annotate-text that is functionally equivalent of --stdin. >> --stdin does not behave as --stdin in other subcommands, such as >> pack-objects whereby it takes one argument per line. Since --stdin can >> be a confusing and misleading name, rename it to --annotate-text. >> >> This change adds a warning to --stdin warning that it will be removed in >> the future. > > I know I've suggested the name, but 'text' in --annotate-text is a > low value word in an option name where every byte is precious. > "Annotate" is very good to convey what is done to the object of the > verb, but "text" stresses the wrong thing (we do not annotate > binary,o we annotate text) without saying where the text comes from > (i.e. standard input). Perhaps "--annotate-stdin" would be a much > better name. > > I agree that letting "--stdin" to deviate so much from an emulation > of "xargs git name-rev" was indeed a mistake that caused the > confusion that led to the other thread. If the mode had a better > name from the day 1, the thread would have been avoided. > > What I am not sure about is how much this transition would hurt > existing users and scripts. > >> + For example: >> ++ >> +---------- >> +$ cat sample.txt >> + >> +An abbreviated revision 2ae0a9cb82 will not be substituted. >> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, >> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad >> + >> +$ git name-rev --annotate-text < sample.txt > > Lose SP between the redirection operator '<' and its file 'sample.txt'. > >> + >> +An abbreviated revision 2ae0a9cb82 will not be substituted. >> +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 >> +(master), >> +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad >> + >> +$ git name-rev --name-only --annotate-text < sample.txt > > Ditto. > >> + if (transform_stdin) { >> + warning("--stdin is deprecated. Please use --annotate-text instead, " >> + "which is functionally equivalent.\n" >> + "This option will be removed in a future release."); >> + annotate_text = 1; > > I guess that is sensible. To squelch the warning, they can switch > to the new option. > >> + } >> + >> + if (all + annotate_text + !!argc > 1) { >> error("Specify either a list, or --all, not both!"); >> usage_with_options(name_rev_usage, opts); >> } >> - if (all || transform_stdin) >> + if (all || annotate_text) >> cutoff = 0; >> >> for (; argc; argc--, argv++) { >> @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) >> for_each_ref(name_ref, &data); >> name_tips(); >> >> - if (transform_stdin) { >> + if (annotate_text) { >> char buffer[2048]; >> >> while (!feof(stdin)) { > > Not a suggestion to change anything in this patch, but just an > observation. > > - If the mode is useful enough for many users, certainly somebody > would have rewritten this loop to lift the line-length limit, but > nobody noticed and complained about this 2k limit for the past 17 > years. I am not sure if that is an indication that nobody uses > the option in its current form. Would this also mean that deprecating --stdin wouldn’t be **too** disruptive to existing users and scripts? > - A low hanging fruit, if we do not go full strbuf_getline(), at > least we should narrow the scope of buffer[] array. > ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text 2021-12-28 5:13 ` John Cai @ 2021-12-31 8:16 ` Junio C Hamano 0 siblings, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2021-12-31 8:16 UTC (permalink / raw) To: John Cai; +Cc: John Cai via GitGitGadget, git, Johannes Schindelin John Cai <johncai86@gmail.com> writes: >> Not a suggestion to change anything in this patch, but just an >> observation. >> >> - If the mode is useful enough for many users, certainly somebody >> would have rewritten this loop to lift the line-length limit, but >> nobody noticed and complained about this 2k limit for the past 17 >> years. I am not sure if that is an indication that nobody uses >> the option in its current form. > > Would this also mean that deprecating --stdin wouldn’t be **too** > disruptive to existing users and scripts? That probably is a lot of wishful thinking. Most likely, it is an indication that most text input files that go into the command have no overly long lines ;-) Loss of or change in behaviour of the command would be disruptive for the users who are content with the limitation that they cannot feed lines wider than 2k. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH] name-rev: deprecate --stdin in favor of --annotate-text 2021-12-27 19:49 ` Junio C Hamano 2021-12-28 5:13 ` John Cai @ 2022-01-01 22:59 ` Johannes Schindelin 1 sibling, 0 replies; 43+ messages in thread From: Johannes Schindelin @ 2022-01-01 22:59 UTC (permalink / raw) To: Junio C Hamano; +Cc: John Cai via GitGitGadget, git, John Cai Hi Junio, On Mon, 27 Dec 2021, Junio C Hamano wrote: > "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > > As name-rev is Dscho's brainchild, I think it is benefitial to ask input > from him, so I added an address to the CC: list. Thank you! > > From: John Cai <johncai86@gmail.com> > > > > Introduce a --annotate-text that is functionally equivalent of --stdin. > > --stdin does not behave as --stdin in other subcommands, such as > > pack-objects whereby it takes one argument per line. Since --stdin can > > be a confusing and misleading name, rename it to --annotate-text. > > > > This change adds a warning to --stdin warning that it will be removed in > > the future. > > I know I've suggested the name, but 'text' in --annotate-text is a > low value word in an option name where every byte is precious. > "Annotate" is very good to convey what is done to the object of the > verb, but "text" stresses the wrong thing (we do not annotate > binary,o we annotate text) without saying where the text comes from > (i.e. standard input). Perhaps "--annotate-stdin" would be a much > better name. I agree that `--annotate-stdin` is better, especially since people who might look for a replacement for `--stdin` in the documentation are much more likely to find what they're looking for. In addition to this, I also agree with Junio on the deprecation needing to be done carefully. Ciao, Dscho ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text 2021-12-26 4:28 [PATCH] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2021-12-27 19:49 ` Junio C Hamano @ 2021-12-29 6:23 ` John Cai via GitGitGadget 2021-12-29 6:23 ` [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget ` (2 more replies) 1 sibling, 3 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2021-12-29 6:23 UTC (permalink / raw) To: git; +Cc: John Cai Introduce a --anontate-text that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, the goal is to rename it to --anotate-text. This is the first step in a process of eventually fully deprecating --stdin. This change also adds a warning to --stdin warning that it will be removed in the future. See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. changes since v1 (thanks to Junio's review): * s/annotate_text/annotate_stdin * add a commit to replace the 2048 size buffer with a strbuf and use strbuf_getwholeline to get lines from stdin * fixed formatting bugs in documentation udpates. John Cai (2): name-rev: deprecate --stdin in favor of --annotate-text name-rev.c: use strbuf_getline instead of limited size buffer Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++- builtin/name-rev.c | 27 +++++++++++++++++---------- 2 files changed, 45 insertions(+), 11 deletions(-) base-commit: 55b058a8bbcc54bd93c733035c995abc7967e539 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v2 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v2 Pull-Request: https://github.com/git/git/pull/1171 Range-diff vs v1: 1: b83d9422d0c ! 1: e8063284b4d name-rev: deprecate --stdin in favor of --annotate-text @@ Documentation/git-name-rev.txt: OPTIONS List all commits reachable from all refs --stdin:: -+ This option is deprecated in favor of 'git name-rev --annotate-text'. ++ This option is deprecated in favor of 'git name-rev --annotate-stdin'. + They are functionally equivalent. + -+--annotate-text:: ++--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex @@ Documentation/git-name-rev.txt: OPTIONS +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + -+$ git name-rev --annotate-text < sample.txt ++$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 +(master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + -+$ git name-rev --name-only --annotate-text < sample.txt ++$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name is master, @@ builtin/name-rev.c: static void name_rev_line(char *p, struct name_ref_data *dat { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; -+ int all = 0, annotate_text = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; ++ int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), -+ OPT_BOOL(0, "annotate-text", &annotate_text, N_("annotate text text from stdin")), ++ OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { -+ warning("--stdin is deprecated. Please use --annotate-text instead, " ++ warning("--stdin is deprecated. Please use --annotate-stdin instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); -+ annotate_text = 1; ++ annotate_stdin = 1; + } + -+ if (all + annotate_text + !!argc > 1) { ++ if (all + annotate_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) -+ if (all || annotate_text) ++ if (all || annotate_stdin) cutoff = 0; for (; argc; argc--, argv++) { @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr name_tips(); - if (transform_stdin) { -+ if (annotate_text) { - char buffer[2048]; +- char buffer[2048]; ++ if (annotate_stdin) { ++ struct strbuf sb = STRBUF_INIT; while (!feof(stdin)) { + char *p = fgets(buffer, sizeof(buffer), stdin); -: ----------- > 2: 4636e27f53e name-rev.c: use strbuf_getline instead of limited size buffer -- gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2021-12-29 6:23 ` [PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text John Cai via GitGitGadget @ 2021-12-29 6:23 ` John Cai via GitGitGadget 2021-12-30 22:36 ` Junio C Hamano 2021-12-29 6:23 ` [PATCH v2 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 1 reply; 43+ messages in thread From: John Cai via GitGitGadget @ 2021-12-29 6:23 UTC (permalink / raw) To: git; +Cc: John Cai, John Cai From: John Cai <johncai86@gmail.com> Introduce a --annotate-text that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, rename it to --annotate-text. This change adds a warning to --stdin warning that it will be removed in the future. Signed-off-by: "John Cai" <johncai86@gmail.com> --- Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++- builtin/name-rev.c | 19 ++++++++++++++----- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 5cb0eb0855f..ee11b2ca9e7 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -43,10 +43,37 @@ OPTIONS List all commits reachable from all refs --stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. + They are functionally equivalent. + +--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. + + For example: ++ +---------- +$ cat sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 +(master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +---------- --name-only:: Instead of printing both the SHA-1 and the name, print only diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 27f60153a6c..21370afdaf9 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) init_commit_rev_name(&rev_names); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { + warning("--stdin is deprecated. Please use --annotate-stdin instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); + annotate_stdin = 1; + } + + if (all + annotate_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) + if (all || annotate_stdin) cutoff = 0; for (; argc; argc--, argv++) { @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) for_each_ref(name_ref, &data); name_tips(); - if (transform_stdin) { - char buffer[2048]; + if (annotate_stdin) { + struct strbuf sb = STRBUF_INIT; while (!feof(stdin)) { char *p = fgets(buffer, sizeof(buffer), stdin); -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2021-12-29 6:23 ` [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget @ 2021-12-30 22:36 ` Junio C Hamano 0 siblings, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2021-12-30 22:36 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, John Cai, Johannes Schindelin "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: John Cai <johncai86@gmail.com> > > Introduce a --annotate-text that is functionally equivalent of --stdin. > --stdin does not behave as --stdin in other subcommands, such as > pack-objects whereby it takes one argument per line. Since --stdin can > be a confusing and misleading name, rename it to --annotate-text. > > This change adds a warning to --stdin warning that it will be removed in > the future. The above (including the title) uses --annotate-TEXT; the documentation and the code seems to use --annotate-STDIN. > > Signed-off-by: "John Cai" <johncai86@gmail.com> > --- > Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++- > builtin/name-rev.c | 19 ++++++++++++++----- > 2 files changed, 42 insertions(+), 6 deletions(-) We probably would want to fix existing tests that use --stdin for its originally intended purpose to use its new spelling instead, and a single new test to ensure that use of --stdin gives a warning as expected. > @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > for_each_ref(name_ref, &data); > name_tips(); > > - if (transform_stdin) { > - char buffer[2048]; > + if (annotate_stdin) { > + struct strbuf sb = STRBUF_INIT; > > while (!feof(stdin)) { > char *p = fgets(buffer, sizeof(buffer), stdin); This block probably would not compile well. ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v2 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2021-12-29 6:23 ` [PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text John Cai via GitGitGadget 2021-12-29 6:23 ` [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget @ 2021-12-29 6:23 ` John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 0 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2021-12-29 6:23 UTC (permalink / raw) To: git; +Cc: John Cai, John Cai From: John Cai <johncai86@gmail.com> Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <johncai86@gmail.com> --- builtin/name-rev.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 21370afdaf9..85993bc2b38 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -625,12 +625,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) if (annotate_stdin) { struct strbuf sb = STRBUF_INIT; - while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); - if (!p) - break; - name_rev_line(p, &data); + while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) { + name_rev_line(sb.buf, &data); } + strbuf_release(&sb); } else if (all) { int i, max; -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2021-12-29 6:23 ` [PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text John Cai via GitGitGadget 2021-12-29 6:23 ` [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2021-12-29 6:23 ` [PATCH v2 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-03 14:47 ` John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget ` (2 more replies) 2 siblings, 3 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-03 14:47 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, the goal is to rename it to --anotate-stdin. This is the first step in a process of eventually fully deprecating --stdin. This change also adds a warning to --stdin warning that it will be removed in the future. See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. changes since v2: * updated title and cover letter with --annotate-stdin * s/--stdin/--annotate-stdin in tests that call name-rev * added a test to ensure correct warning is shown when --stdin is passed John Cai (2): name-rev: deprecate --stdin in favor of --annotate-text name-rev.c: use strbuf_getline instead of limited size buffer Documentation/git-name-rev.txt | 29 +++++++++++++++++++++++++++- builtin/name-rev.c | 27 ++++++++++++++++---------- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------- t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 70 insertions(+), 30 deletions(-) base-commit: c8b2ade48c204690119936ada89cd938c476c5c2 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v3 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v3 Pull-Request: https://github.com/git/git/pull/1171 Range-diff vs v2: 1: e8063284b4d ! 1: 55ec2a5fa3e name-rev: deprecate --stdin in favor of --annotate-text @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr while (!feof(stdin)) { char *p = fgets(buffer, sizeof(buffer), stdin); + + ## t/t3412-rebase-root.sh ## +@@ t/t3412-rebase-root.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME + + log_with_names () { + git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | +- git name-rev --stdin --name-only --refs=refs/heads/$1 ++ git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 + } + + + + ## t/t4202-log.sh ## +@@ t/t4202-log.sh: EOF + + test_expect_success 'log --graph with full output' ' + git log --graph --date-order --pretty=short | +- git name-rev --name-only --stdin | ++ git name-rev --name-only --annotate-stdin | + sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && + test_cmp expect actual + ' + + ## t/t6007-rev-list-cherry-pick-file.sh ## +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + + test_expect_success '--left-right' ' + git rev-list --left-right B...C > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + + test_expect_success '--cherry-pick bar does not come up empty' ' + git rev-list --left-right --cherry-pick B...C -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' + + test_expect_success 'bar does not come up empty' ' + git rev-list --left-right B...C -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + + test_expect_success '--cherry-pick bar does not come up empty (II)' ' + git rev-list --left-right --cherry-pick F...E -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' + + test_expect_success 'name-rev multiple --refs combine inclusive' ' + git rev-list --left-right --cherry-pick F...E -- bar >actual && +- git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ + <actual >actual.named && + test_cmp expect actual.named + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + test_expect_success 'name-rev --refs excludes non-matched patterns' ' + git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && + git rev-list --left-right --cherry-pick F...E -- bar >actual && +- git name-rev --stdin --name-only --refs="*tags/F" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/F" \ + <actual >actual.named && + test_cmp expect actual.named + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + test_expect_success 'name-rev --exclude excludes matched patterns' ' + git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && + git rev-list --left-right --cherry-pick F...E -- bar >actual && +- git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ + <actual >actual.named && + test_cmp expect actual.named + ' + + test_expect_success 'name-rev --no-refs clears the refs list' ' + git rev-list --left-right --cherry-pick F...E -- bar >expect && +- git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ + <expect >actual && + test_cmp expect actual + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + + test_expect_success '--cherry-mark' ' + git rev-list --cherry-mark F...E -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + + test_expect_success '--cherry-mark --left-right' ' + git rev-list --cherry-mark --left-right F...E -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + + test_expect_success '--cherry-pick --right-only' ' + git rev-list --cherry-pick --right-only F...E -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' + + test_expect_success '--cherry-pick --left-only' ' + git rev-list --cherry-pick --left-only E...F -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' +@@ t/t6007-rev-list-cherry-pick-file.sh: EOF + + test_expect_success '--cherry' ' + git rev-list --cherry F...E -- bar > actual && +- git name-rev --stdin --name-only --refs="*tags/*" \ ++ git name-rev --annotate-stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp expect actual.named + ' + + ## t/t6012-rev-list-simplify.sh ## +@@ t/t6012-rev-list-simplify.sh: note () { + } + + unnote () { +- git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" ++ git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" + } + + # + + ## t/t6111-rev-list-treesame.sh ## +@@ t/t6111-rev-list-treesame.sh: note () { + } + + unnote () { +- git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" ++ git name-rev --tags --annotate-stdin | \ ++ sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" + } + + test_expect_success setup ' + + ## t/t6120-describe.sh ## +@@ t/t6120-describe.sh: test_expect_success 'name-rev --all' ' + test_cmp expect actual + ' + +-test_expect_success 'name-rev --stdin' ' ++test_expect_success 'name-rev --annotate-stdin' ' + >expect.unsorted && + for rev in $(git rev-list --all) + do +@@ t/t6120-describe.sh: test_expect_success 'name-rev --stdin' ' + echo "$rev ($name)" >>expect.unsorted || return 1 + done && + sort <expect.unsorted >expect && +- git rev-list --all | git name-rev --stdin >actual.unsorted && ++ git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && + sort <actual.unsorted >actual && + test_cmp expect actual + ' + ++test_expect_success 'name-rev --stdin deprecated' " ++ git rev-list --all | git name-rev --stdin 2>actual && ++ grep -E 'warning: --stdin is deprecated' actual ++" ++ + test_expect_success 'describe --contains with the exact tags' ' + echo "A^0" >expect && + tag_object=$(git rev-parse refs/tags/A) && 2: 4636e27f53e = 2: e4bd09ccf75 name-rev.c: use strbuf_getline instead of limited size buffer -- gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2022-01-03 14:47 ` [PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget @ 2022-01-03 14:47 ` John Cai via GitGitGadget 2022-01-04 2:36 ` Junio C Hamano ` (2 more replies) 2022-01-03 14:47 ` [PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-04 14:49 ` [PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 3 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-03 14:47 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Introduce a --annotate-text that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, rename it to --annotate-text. This change adds a warning to --stdin warning that it will be removed in the future. Signed-off-by: "John Cai" <johncai86@gmail.com> --- Documentation/git-name-rev.txt | 29 +++++++++++++++++++++++++++- builtin/name-rev.c | 19 +++++++++++++----- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------- t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 67 insertions(+), 25 deletions(-) diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 5cb0eb0855f..ee11b2ca9e7 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -43,10 +43,37 @@ OPTIONS List all commits reachable from all refs --stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. + They are functionally equivalent. + +--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. + + For example: ++ +---------- +$ cat sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 +(master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +---------- --name-only:: Instead of printing both the SHA-1 and the name, print only diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 27f60153a6c..21370afdaf9 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) init_commit_rev_name(&rev_names); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { + warning("--stdin is deprecated. Please use --annotate-stdin instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); + annotate_stdin = 1; + } + + if (all + annotate_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) + if (all || annotate_stdin) cutoff = 0; for (; argc; argc--, argv++) { @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) for_each_ref(name_ref, &data); name_tips(); - if (transform_stdin) { - char buffer[2048]; + if (annotate_stdin) { + struct strbuf sb = STRBUF_INIT; while (!feof(stdin)) { char *p = fgets(buffer, sizeof(buffer), stdin); diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index 19c6f4acbf6..1e9f7833dd6 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME log_with_names () { git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | - git name-rev --stdin --name-only --refs=refs/heads/$1 + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 } diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 50495598619..dc884107de4 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -659,7 +659,7 @@ EOF test_expect_success 'log --graph with full output' ' git log --graph --date-order --pretty=short | - git name-rev --name-only --stdin | + git name-rev --name-only --annotate-stdin | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && test_cmp expect actual ' diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index aebe4b69e13..6f3e5439771 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -58,7 +58,7 @@ EOF test_expect_success '--left-right' ' git rev-list --left-right B...C > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -78,14 +78,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty' ' git rev-list --left-right --cherry-pick B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'bar does not come up empty' ' git rev-list --left-right B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -97,14 +97,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty (II)' ' git rev-list --left-right --cherry-pick F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev multiple --refs combine inclusive' ' git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ <actual >actual.named && test_cmp expect actual.named ' @@ -116,7 +116,7 @@ EOF test_expect_success 'name-rev --refs excludes non-matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ <actual >actual.named && test_cmp expect actual.named ' @@ -128,14 +128,14 @@ EOF test_expect_success 'name-rev --exclude excludes matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ <actual >actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev --no-refs clears the refs list' ' git rev-list --left-right --cherry-pick F...E -- bar >expect && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ <expect >actual && test_cmp expect actual ' @@ -149,7 +149,7 @@ EOF test_expect_success '--cherry-mark' ' git rev-list --cherry-mark F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -163,7 +163,7 @@ EOF test_expect_success '--cherry-mark --left-right' ' git rev-list --cherry-mark --left-right F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -174,14 +174,14 @@ EOF test_expect_success '--cherry-pick --right-only' ' git rev-list --cherry-pick --right-only F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success '--cherry-pick --left-only' ' git rev-list --cherry-pick --left-only E...F -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -193,7 +193,7 @@ EOF test_expect_success '--cherry' ' git rev-list --cherry F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index 4f7fa8b6c03..4fedc614fa6 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -12,7 +12,7 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" } # diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh index e07b6070e0e..90ff1416400 100755 --- a/t/t6111-rev-list-treesame.sh +++ b/t/t6111-rev-list-treesame.sh @@ -23,7 +23,8 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" + git name-rev --tags --annotate-stdin | \ + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" } test_expect_success setup ' diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index d8af2bb9d2b..9781b92aedd 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' test_cmp expect actual ' -test_expect_success 'name-rev --stdin' ' +test_expect_success 'name-rev --annotate-stdin' ' >expect.unsorted && for rev in $(git rev-list --all) do @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' echo "$rev ($name)" >>expect.unsorted || return 1 done && sort <expect.unsorted >expect && - git rev-list --all | git name-rev --stdin >actual.unsorted && + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && sort <actual.unsorted >actual && test_cmp expect actual ' +test_expect_success 'name-rev --stdin deprecated' " + git rev-list --all | git name-rev --stdin 2>actual && + grep -E 'warning: --stdin is deprecated' actual +" + test_expect_success 'describe --contains with the exact tags' ' echo "A^0" >expect && tag_object=$(git rev-parse refs/tags/A) && -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2022-01-03 14:47 ` [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget @ 2022-01-04 2:36 ` Junio C Hamano 2022-01-04 3:16 ` Junio C Hamano 2022-01-04 13:25 ` Philip Oakley 2 siblings, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-04 2:36 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin, John Cai "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > +--annotate-stdin:: > Transform stdin by substituting all the 40-character SHA-1 > hexes (say $hex) with "$hex ($rev_name)". When used with > --name-only, substitute with "$rev_name", omitting $hex > - altogether. Intended for the scripter's use. > + altogether. > + > + For example: > ++ I wonder if you also need the "There is no paragraph break, concluding the bulleted item" marker that is a sole plus sign on a line before the "For example:" thing. Other than that, looking good. Thanks. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2022-01-03 14:47 ` [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2022-01-04 2:36 ` Junio C Hamano @ 2022-01-04 3:16 ` Junio C Hamano 2022-01-04 13:25 ` Philip Oakley 2 siblings, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-04 3:16 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin, John Cai "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: John Cai <johncai86@gmail.com> > > Introduce a --annotate-text that is functionally equivalent of --stdin. This line and the title need to be updated to use "--annotate-stdin". ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2022-01-03 14:47 ` [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2022-01-04 2:36 ` Junio C Hamano 2022-01-04 3:16 ` Junio C Hamano @ 2022-01-04 13:25 ` Philip Oakley 2022-01-04 19:00 ` Junio C Hamano 2022-01-04 19:38 ` Eric Sunshine 2 siblings, 2 replies; 43+ messages in thread From: Philip Oakley @ 2022-01-04 13:25 UTC (permalink / raw) To: John Cai via GitGitGadget, git; +Cc: Johannes Schindelin, John Cai On 03/01/2022 14:47, John Cai via GitGitGadget wrote: > From: John Cai <johncai86@gmail.com> > > Introduce a --annotate-text that is functionally equivalent of --stdin. > --stdin does not behave as --stdin in other subcommands, such as > pack-objects whereby it takes one argument per line. Since --stdin can > be a confusing and misleading name, rename it to --annotate-text. > > This change adds a warning to --stdin warning that it will be removed in > the future. > > Signed-off-by: "John Cai" <johncai86@gmail.com> > --- > Documentation/git-name-rev.txt | 29 +++++++++++++++++++++++++++- > builtin/name-rev.c | 19 +++++++++++++----- > t/t3412-rebase-root.sh | 2 +- > t/t4202-log.sh | 2 +- > t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------- > t/t6012-rev-list-simplify.sh | 2 +- > t/t6111-rev-list-treesame.sh | 3 ++- > t/t6120-describe.sh | 9 +++++++-- > 8 files changed, 67 insertions(+), 25 deletions(-) > > diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt > index 5cb0eb0855f..ee11b2ca9e7 100644 > --- a/Documentation/git-name-rev.txt > +++ b/Documentation/git-name-rev.txt > @@ -43,10 +43,37 @@ OPTIONS > List all commits reachable from all refs > > --stdin:: > + This option is deprecated in favor of 'git name-rev --annotate-stdin'. > + They are functionally equivalent. > + > +--annotate-stdin:: > Transform stdin by substituting all the 40-character SHA-1 > hexes (say $hex) with "$hex ($rev_name)". When used with > --name-only, substitute with "$rev_name", omitting $hex > - altogether. Intended for the scripter's use. > + altogether. Is there a preferred order for the old/new variant documentation? It struck me that the docs should offer the new (now 'correct') variant first. I didn't see anything about deprecation in the CodingGuidlines or SubmittingPatches (only a quick search though) -- Philip > + > + For example: > ++ > +---------- > +$ cat sample.txt > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > +$ git name-rev --annotate-stdin <sample.txt > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 > +(master), > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > +$ git name-rev --name-only --annotate-stdin <sample.txt > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name is master, > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > +---------- > > --name-only:: > Instead of printing both the SHA-1 and the name, print only > diff --git a/builtin/name-rev.c b/builtin/name-rev.c > index 27f60153a6c..21370afdaf9 100644 > --- a/builtin/name-rev.c > +++ b/builtin/name-rev.c > @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) > int cmd_name_rev(int argc, const char **argv, const char *prefix) > { > struct object_array revs = OBJECT_ARRAY_INIT; > - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; > + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; > struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; > struct option opts[] = { > OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), > @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > OPT_GROUP(""), > OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), > OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), > + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), > OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), > OPT_BOOL(0, "always", &always, > N_("show abbreviated commit object as fallback")), > @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > init_commit_rev_name(&rev_names); > git_config(git_default_config, NULL); > argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); > - if (all + transform_stdin + !!argc > 1) { > + > + if (transform_stdin) { > + warning("--stdin is deprecated. Please use --annotate-stdin instead, " > + "which is functionally equivalent.\n" > + "This option will be removed in a future release."); > + annotate_stdin = 1; > + } > + > + if (all + annotate_stdin + !!argc > 1) { > error("Specify either a list, or --all, not both!"); > usage_with_options(name_rev_usage, opts); > } > - if (all || transform_stdin) > + if (all || annotate_stdin) > cutoff = 0; > > for (; argc; argc--, argv++) { > @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > for_each_ref(name_ref, &data); > name_tips(); > > - if (transform_stdin) { > - char buffer[2048]; > + if (annotate_stdin) { > + struct strbuf sb = STRBUF_INIT; > > while (!feof(stdin)) { > char *p = fgets(buffer, sizeof(buffer), stdin); > diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh > index 19c6f4acbf6..1e9f7833dd6 100755 > --- a/t/t3412-rebase-root.sh > +++ b/t/t3412-rebase-root.sh > @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME > > log_with_names () { > git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | > - git name-rev --stdin --name-only --refs=refs/heads/$1 > + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 > } > > > diff --git a/t/t4202-log.sh b/t/t4202-log.sh > index 50495598619..dc884107de4 100755 > --- a/t/t4202-log.sh > +++ b/t/t4202-log.sh > @@ -659,7 +659,7 @@ EOF > > test_expect_success 'log --graph with full output' ' > git log --graph --date-order --pretty=short | > - git name-rev --name-only --stdin | > + git name-rev --name-only --annotate-stdin | > sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && > test_cmp expect actual > ' > diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh > index aebe4b69e13..6f3e5439771 100755 > --- a/t/t6007-rev-list-cherry-pick-file.sh > +++ b/t/t6007-rev-list-cherry-pick-file.sh > @@ -58,7 +58,7 @@ EOF > > test_expect_success '--left-right' ' > git rev-list --left-right B...C > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -78,14 +78,14 @@ EOF > > test_expect_success '--cherry-pick bar does not come up empty' ' > git rev-list --left-right --cherry-pick B...C -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'bar does not come up empty' ' > git rev-list --left-right B...C -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -97,14 +97,14 @@ EOF > > test_expect_success '--cherry-pick bar does not come up empty (II)' ' > git rev-list --left-right --cherry-pick F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'name-rev multiple --refs combine inclusive' ' > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ > <actual >actual.named && > test_cmp expect actual.named > ' > @@ -116,7 +116,7 @@ EOF > test_expect_success 'name-rev --refs excludes non-matched patterns' ' > git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/F" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ > <actual >actual.named && > test_cmp expect actual.named > ' > @@ -128,14 +128,14 @@ EOF > test_expect_success 'name-rev --exclude excludes matched patterns' ' > git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ > <actual >actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'name-rev --no-refs clears the refs list' ' > git rev-list --left-right --cherry-pick F...E -- bar >expect && > - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ > <expect >actual && > test_cmp expect actual > ' > @@ -149,7 +149,7 @@ EOF > > test_expect_success '--cherry-mark' ' > git rev-list --cherry-mark F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -163,7 +163,7 @@ EOF > > test_expect_success '--cherry-mark --left-right' ' > git rev-list --cherry-mark --left-right F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -174,14 +174,14 @@ EOF > > test_expect_success '--cherry-pick --right-only' ' > git rev-list --cherry-pick --right-only F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success '--cherry-pick --left-only' ' > git rev-list --cherry-pick --left-only E...F -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -193,7 +193,7 @@ EOF > > test_expect_success '--cherry' ' > git rev-list --cherry F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh > index 4f7fa8b6c03..4fedc614fa6 100755 > --- a/t/t6012-rev-list-simplify.sh > +++ b/t/t6012-rev-list-simplify.sh > @@ -12,7 +12,7 @@ note () { > } > > unnote () { > - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" > + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" > } > > # > diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh > index e07b6070e0e..90ff1416400 100755 > --- a/t/t6111-rev-list-treesame.sh > +++ b/t/t6111-rev-list-treesame.sh > @@ -23,7 +23,8 @@ note () { > } > > unnote () { > - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" > + git name-rev --tags --annotate-stdin | \ > + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" > } > > test_expect_success setup ' > diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh > index d8af2bb9d2b..9781b92aedd 100755 > --- a/t/t6120-describe.sh > +++ b/t/t6120-describe.sh > @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' > test_cmp expect actual > ' > > -test_expect_success 'name-rev --stdin' ' > +test_expect_success 'name-rev --annotate-stdin' ' > >expect.unsorted && > for rev in $(git rev-list --all) > do > @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' > echo "$rev ($name)" >>expect.unsorted || return 1 > done && > sort <expect.unsorted >expect && > - git rev-list --all | git name-rev --stdin >actual.unsorted && > + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && > sort <actual.unsorted >actual && > test_cmp expect actual > ' > > +test_expect_success 'name-rev --stdin deprecated' " > + git rev-list --all | git name-rev --stdin 2>actual && > + grep -E 'warning: --stdin is deprecated' actual > +" > + > test_expect_success 'describe --contains with the exact tags' ' > echo "A^0" >expect && > tag_object=$(git rev-parse refs/tags/A) && ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2022-01-04 13:25 ` Philip Oakley @ 2022-01-04 19:00 ` Junio C Hamano 2022-01-04 19:38 ` Eric Sunshine 1 sibling, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-04 19:00 UTC (permalink / raw) To: Philip Oakley Cc: John Cai via GitGitGadget, git, Johannes Schindelin, John Cai Philip Oakley <philipoakley@iee.email> writes: >> --stdin:: >> + This option is deprecated in favor of 'git name-rev --annotate-stdin'. >> + They are functionally equivalent. >> + >> +--annotate-stdin:: >> Transform stdin by substituting all the 40-character SHA-1 >> hexes (say $hex) with "$hex ($rev_name)". When used with >> --name-only, substitute with "$rev_name", omitting $hex >> - altogether. Intended for the scripter's use. >> + altogether. > > Is there a preferred order for the old/new variant documentation? If the surrounding list has a natural order of its own, e.g. the list is sorted alphabetically to help people locate an item by name, it is OK to have old and new in that order and older one may appear before the newer one. But otherwise it may make sense to show the newer one first with the mention of the older one as if it were a side note, especially when they can appear next to each other like the one we are looking at, I would think. I do not think we have written preference. It probably would help to have a short paragraph in the coding guidelines document. Thanks. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text 2022-01-04 13:25 ` Philip Oakley 2022-01-04 19:00 ` Junio C Hamano @ 2022-01-04 19:38 ` Eric Sunshine 1 sibling, 0 replies; 43+ messages in thread From: Eric Sunshine @ 2022-01-04 19:38 UTC (permalink / raw) To: Philip Oakley Cc: John Cai via GitGitGadget, Git List, Johannes Schindelin, John Cai On Tue, Jan 4, 2022 at 10:32 AM Philip Oakley <philipoakley@iee.email> wrote: > On 03/01/2022 14:47, John Cai via GitGitGadget wrote: > > From: John Cai <johncai86@gmail.com> > > --stdin:: > > + This option is deprecated in favor of 'git name-rev --annotate-stdin'. > > + They are functionally equivalent. > > + > > +--annotate-stdin:: > > Transform stdin by substituting all the 40-character SHA-1 > > hexes (say $hex) with "$hex ($rev_name)". When used with > > --name-only, substitute with "$rev_name", omitting $hex > > - altogether. Intended for the scripter's use. > > + altogether. > > Is there a preferred order for the old/new variant documentation? > > It struck me that the docs should offer the new (now 'correct') variant > first. > > I didn't see anything about deprecation in the CodingGuidlines or > SubmittingPatches (only a quick search though) In other cases, we've demoted the deprecated option to a tiny blurb at the end of the description of the option which replaces it so that the deprecated option is no longer given a place of prominence but can still be found with a search in case someone runs across it somewhere and wants to learn about it. --annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex altogether. --stdin is a deprecated synonym. ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-03 14:47 ` [PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget @ 2022-01-03 14:47 ` John Cai via GitGitGadget 2022-01-04 2:16 ` Junio C Hamano 2022-01-04 14:49 ` [PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 1 reply; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-03 14:47 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <johncai86@gmail.com> --- builtin/name-rev.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 21370afdaf9..85993bc2b38 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -625,12 +625,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) if (annotate_stdin) { struct strbuf sb = STRBUF_INIT; - while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); - if (!p) - break; - name_rev_line(p, &data); + while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) { + name_rev_line(sb.buf, &data); } + strbuf_release(&sb); } else if (all) { int i, max; -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-03 14:47 ` [PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-04 2:16 ` Junio C Hamano 0 siblings, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-04 2:16 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin, John Cai "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: John Cai <johncai86@gmail.com> > > Using a buffer limited to 2048 is unnecessarily limiting. Switch to > using a string buffer to read in stdin for annotation. > > Signed-off-by: "John Cai" <johncai86@gmail.com> > --- > builtin/name-rev.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/builtin/name-rev.c b/builtin/name-rev.c > index 21370afdaf9..85993bc2b38 100644 > --- a/builtin/name-rev.c > +++ b/builtin/name-rev.c > @@ -625,12 +625,10 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > if (annotate_stdin) { > struct strbuf sb = STRBUF_INIT; > > - while (!feof(stdin)) { > - char *p = fgets(buffer, sizeof(buffer), stdin); > - if (!p) > - break; > - name_rev_line(p, &data); > + while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) { As we are reading text, I wonder if it makes more sense to just use strbuf_getline() that is meant to use the definition of "line" that honors the platform convention (i.e. on Windows, '\r\n' is taken as the EOL marker). > + name_rev_line(sb.buf, &data); > } > + strbuf_release(&sb); > } else if (all) { > int i, max; Other than that, looking good. Thanks. ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-03 14:47 ` [PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-04 14:49 ` John Cai via GitGitGadget 2022-01-04 14:49 ` [PATCH v4 1/2] " John Cai via GitGitGadget ` (2 more replies) 2 siblings, 3 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-04 14:49 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, the goal is to rename it to --annotate-stdin. This is the first step in a process of eventually fully deprecating --stdin. This change also adds a warning to --stdin warning that it will be removed in the future. See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. changes since v3: * use strbuf_getline instead of strbuf_getwholeline (based on Junio's feedback) * fixed commit message s/annotate-text/annotate-stdin (based on Junio's feedback) * since strbuf_getline does not keep the trailing terminator, add back '\n' with strbuf_addchr * reordered documentation blocks based on (Philip Oakley's feedback) * fixed doc typos in example block John Cai (2): name-rev: deprecate --stdin in favor of --annotate-stdin name-rev.c: use strbuf_getline instead of limited size buffer Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 28 ++++++++++++++++---------- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 71 insertions(+), 31 deletions(-) base-commit: c8b2ade48c204690119936ada89cd938c476c5c2 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v4 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v4 Pull-Request: https://github.com/git/git/pull/1171 Range-diff vs v3: 1: 55ec2a5fa3e ! 1: 4e9200922a4 name-rev: deprecate --stdin in favor of --annotate-text @@ Metadata Author: John Cai <johncai86@gmail.com> ## Commit message ## - name-rev: deprecate --stdin in favor of --annotate-text + name-rev: deprecate --stdin in favor of --annotate-stdin - Introduce a --annotate-text that is functionally equivalent of --stdin. + Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can - be a confusing and misleading name, rename it to --annotate-text. + be a confusing and misleading name, rename it to --annotate-stdin. This change adds a warning to --stdin warning that it will be removed in the future. @@ Commit message ## Documentation/git-name-rev.txt ## @@ Documentation/git-name-rev.txt: OPTIONS + --all:: List all commits reachable from all refs - --stdin:: -+ This option is deprecated in favor of 'git name-rev --annotate-stdin'. -+ They are functionally equivalent. -+ +---stdin:: +--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with @@ Documentation/git-name-rev.txt: OPTIONS - altogether. Intended for the scripter's use. + altogether. + -+ For example: -++ ++For example: ++ +---------- +$ cat sample.txt + @@ Documentation/git-name-rev.txt: OPTIONS +$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. -+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 -+(master), ++The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. -+The full name is master, ++The full name after substitution is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +---------- ++ ++--stdin:: ++ This option is deprecated in favor of 'git name-rev --annotate-stdin'. ++ They are functionally equivalent. --name-only:: Instead of printing both the SHA-1 and the name, print only 2: e4bd09ccf75 ! 2: 18f77ab9dde name-rev.c: use strbuf_getline instead of limited size buffer @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr - if (!p) - break; - name_rev_line(p, &data); -+ while (strbuf_getwholeline(&sb, stdin, '\n') != EOF) { ++ while (strbuf_getline(&sb, stdin) != EOF) { ++ strbuf_addch(&sb, '\n'); + name_rev_line(sb.buf, &data); } + strbuf_release(&sb); -- gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-04 14:49 ` [PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget @ 2022-01-04 14:49 ` John Cai via GitGitGadget 2022-01-04 22:12 ` Junio C Hamano 2022-01-05 11:15 ` Phillip Wood 2022-01-04 14:49 ` [PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-05 4:20 ` [PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 2 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-04 14:49 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, rename it to --annotate-stdin. This change adds a warning to --stdin warning that it will be removed in the future. Signed-off-by: "John Cai" <johncai86@gmail.com> --- Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 19 +++++++++++++----- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 67 insertions(+), 26 deletions(-) diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 5cb0eb0855f..96e8fd5ea47 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -42,11 +42,37 @@ OPTIONS --all:: List all commits reachable from all refs ---stdin:: +--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. + +For example: + +---------- +$ cat sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +---------- + +--stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. + They are functionally equivalent. --name-only:: Instead of printing both the SHA-1 and the name, print only diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 27f60153a6c..21370afdaf9 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) init_commit_rev_name(&rev_names); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { + warning("--stdin is deprecated. Please use --annotate-stdin instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); + annotate_stdin = 1; + } + + if (all + annotate_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) + if (all || annotate_stdin) cutoff = 0; for (; argc; argc--, argv++) { @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) for_each_ref(name_ref, &data); name_tips(); - if (transform_stdin) { - char buffer[2048]; + if (annotate_stdin) { + struct strbuf sb = STRBUF_INIT; while (!feof(stdin)) { char *p = fgets(buffer, sizeof(buffer), stdin); diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index 19c6f4acbf6..1e9f7833dd6 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME log_with_names () { git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | - git name-rev --stdin --name-only --refs=refs/heads/$1 + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 } diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 50495598619..dc884107de4 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -659,7 +659,7 @@ EOF test_expect_success 'log --graph with full output' ' git log --graph --date-order --pretty=short | - git name-rev --name-only --stdin | + git name-rev --name-only --annotate-stdin | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && test_cmp expect actual ' diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index aebe4b69e13..6f3e5439771 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -58,7 +58,7 @@ EOF test_expect_success '--left-right' ' git rev-list --left-right B...C > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -78,14 +78,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty' ' git rev-list --left-right --cherry-pick B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'bar does not come up empty' ' git rev-list --left-right B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -97,14 +97,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty (II)' ' git rev-list --left-right --cherry-pick F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev multiple --refs combine inclusive' ' git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ <actual >actual.named && test_cmp expect actual.named ' @@ -116,7 +116,7 @@ EOF test_expect_success 'name-rev --refs excludes non-matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ <actual >actual.named && test_cmp expect actual.named ' @@ -128,14 +128,14 @@ EOF test_expect_success 'name-rev --exclude excludes matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ <actual >actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev --no-refs clears the refs list' ' git rev-list --left-right --cherry-pick F...E -- bar >expect && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ <expect >actual && test_cmp expect actual ' @@ -149,7 +149,7 @@ EOF test_expect_success '--cherry-mark' ' git rev-list --cherry-mark F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -163,7 +163,7 @@ EOF test_expect_success '--cherry-mark --left-right' ' git rev-list --cherry-mark --left-right F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -174,14 +174,14 @@ EOF test_expect_success '--cherry-pick --right-only' ' git rev-list --cherry-pick --right-only F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success '--cherry-pick --left-only' ' git rev-list --cherry-pick --left-only E...F -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -193,7 +193,7 @@ EOF test_expect_success '--cherry' ' git rev-list --cherry F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index 4f7fa8b6c03..4fedc614fa6 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -12,7 +12,7 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" } # diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh index e07b6070e0e..90ff1416400 100755 --- a/t/t6111-rev-list-treesame.sh +++ b/t/t6111-rev-list-treesame.sh @@ -23,7 +23,8 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" + git name-rev --tags --annotate-stdin | \ + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" } test_expect_success setup ' diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index d8af2bb9d2b..9781b92aedd 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' test_cmp expect actual ' -test_expect_success 'name-rev --stdin' ' +test_expect_success 'name-rev --annotate-stdin' ' >expect.unsorted && for rev in $(git rev-list --all) do @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' echo "$rev ($name)" >>expect.unsorted || return 1 done && sort <expect.unsorted >expect && - git rev-list --all | git name-rev --stdin >actual.unsorted && + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && sort <actual.unsorted >actual && test_cmp expect actual ' +test_expect_success 'name-rev --stdin deprecated' " + git rev-list --all | git name-rev --stdin 2>actual && + grep -E 'warning: --stdin is deprecated' actual +" + test_expect_success 'describe --contains with the exact tags' ' echo "A^0" >expect && tag_object=$(git rev-parse refs/tags/A) && -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-04 14:49 ` [PATCH v4 1/2] " John Cai via GitGitGadget @ 2022-01-04 22:12 ` Junio C Hamano 2022-01-05 11:15 ` Phillip Wood 1 sibling, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-04 22:12 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin, John Cai "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > + altogether. > + > +For example: > + > +---------- > +$ cat sample.txt Because this example is a part of description of `--annotate-stdin`, not an example after a list that ends with `--annotate-stdin`, you would want to tweak the above a bit. diff --git i/Documentation/git-name-rev.txt w/Documentation/git-name-rev.txt index 96e8fd5ea4..0f32d74de0 100644 --- i/Documentation/git-name-rev.txt +++ w/Documentation/git-name-rev.txt @@ -47,9 +47,9 @@ OPTIONS hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex altogether. - ++ For example: - ++ ---------- $ cat sample.txt ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-04 14:49 ` [PATCH v4 1/2] " John Cai via GitGitGadget 2022-01-04 22:12 ` Junio C Hamano @ 2022-01-05 11:15 ` Phillip Wood 2022-01-05 19:47 ` Junio C Hamano 2022-01-05 19:52 ` Junio C Hamano 1 sibling, 2 replies; 43+ messages in thread From: Phillip Wood @ 2022-01-05 11:15 UTC (permalink / raw) To: John Cai via GitGitGadget, git Cc: Johannes Schindelin, John Cai, Junio C Hamano Hi John On 04/01/2022 14:49, John Cai via GitGitGadget wrote: > From: John Cai <johncai86@gmail.com> > [...] > diff --git a/builtin/name-rev.c b/builtin/name-rev.c > index 27f60153a6c..21370afdaf9 100644 > --- a/builtin/name-rev.c > +++ b/builtin/name-rev.c > @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) > int cmd_name_rev(int argc, const char **argv, const char *prefix) > { > struct object_array revs = OBJECT_ARRAY_INIT; > - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; > + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; > struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; > struct option opts[] = { > OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), > @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > OPT_GROUP(""), > OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), > OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), If the intention is to deprecate this option then it might be worth marking it as PARSE_OPT_HIDDEN so that it is not shown by 'git name-rev -h'. (You need to change OPT_BOOL to OPT_BOOL_F to pass the flag) > + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), > OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), > OPT_BOOL(0, "always", &always, > N_("show abbreviated commit object as fallback")), > @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > init_commit_rev_name(&rev_names); > git_config(git_default_config, NULL); > argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); > - if (all + transform_stdin + !!argc > 1) { > + > + if (transform_stdin) { > + warning("--stdin is deprecated. Please use --annotate-stdin instead, " > + "which is functionally equivalent.\n" > + "This option will be removed in a future release."); > + annotate_stdin = 1; > + } > + > + if (all + annotate_stdin + !!argc > 1) { > error("Specify either a list, or --all, not both!"); > usage_with_options(name_rev_usage, opts); > } > - if (all || transform_stdin) > + if (all || annotate_stdin) > cutoff = 0; > > for (; argc; argc--, argv++) { > @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > for_each_ref(name_ref, &data); > name_tips(); > > - if (transform_stdin) { > - char buffer[2048]; > + if (annotate_stdin) { > + struct strbuf sb = STRBUF_INIT; I think this hunk belongs in the next patch. Before posting a patch series I find it helpful to run git rebase --keep-base -x'make -j4 git && cd t && prove -j4 <tests I think might fail> :: --root=/dev/shm' to check that the individual patches compile and pass the relevant tests. I've never got round to trying it but git-test[1] also lets you test all the commits in a series Best Wishes Phillip [1] https://github.com/mhagger/git-test > while (!feof(stdin)) { > char *p = fgets(buffer, sizeof(buffer), stdin); > diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh > index 19c6f4acbf6..1e9f7833dd6 100755 > --- a/t/t3412-rebase-root.sh > +++ b/t/t3412-rebase-root.sh > @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME > > log_with_names () { > git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | > - git name-rev --stdin --name-only --refs=refs/heads/$1 > + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 > } > > > diff --git a/t/t4202-log.sh b/t/t4202-log.sh > index 50495598619..dc884107de4 100755 > --- a/t/t4202-log.sh > +++ b/t/t4202-log.sh > @@ -659,7 +659,7 @@ EOF > > test_expect_success 'log --graph with full output' ' > git log --graph --date-order --pretty=short | > - git name-rev --name-only --stdin | > + git name-rev --name-only --annotate-stdin | > sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && > test_cmp expect actual > ' > diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh > index aebe4b69e13..6f3e5439771 100755 > --- a/t/t6007-rev-list-cherry-pick-file.sh > +++ b/t/t6007-rev-list-cherry-pick-file.sh > @@ -58,7 +58,7 @@ EOF > > test_expect_success '--left-right' ' > git rev-list --left-right B...C > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -78,14 +78,14 @@ EOF > > test_expect_success '--cherry-pick bar does not come up empty' ' > git rev-list --left-right --cherry-pick B...C -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'bar does not come up empty' ' > git rev-list --left-right B...C -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -97,14 +97,14 @@ EOF > > test_expect_success '--cherry-pick bar does not come up empty (II)' ' > git rev-list --left-right --cherry-pick F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'name-rev multiple --refs combine inclusive' ' > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ > <actual >actual.named && > test_cmp expect actual.named > ' > @@ -116,7 +116,7 @@ EOF > test_expect_success 'name-rev --refs excludes non-matched patterns' ' > git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/F" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ > <actual >actual.named && > test_cmp expect actual.named > ' > @@ -128,14 +128,14 @@ EOF > test_expect_success 'name-rev --exclude excludes matched patterns' ' > git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ > <actual >actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'name-rev --no-refs clears the refs list' ' > git rev-list --left-right --cherry-pick F...E -- bar >expect && > - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ > <expect >actual && > test_cmp expect actual > ' > @@ -149,7 +149,7 @@ EOF > > test_expect_success '--cherry-mark' ' > git rev-list --cherry-mark F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -163,7 +163,7 @@ EOF > > test_expect_success '--cherry-mark --left-right' ' > git rev-list --cherry-mark --left-right F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -174,14 +174,14 @@ EOF > > test_expect_success '--cherry-pick --right-only' ' > git rev-list --cherry-pick --right-only F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success '--cherry-pick --left-only' ' > git rev-list --cherry-pick --left-only E...F -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -193,7 +193,7 @@ EOF > > test_expect_success '--cherry' ' > git rev-list --cherry F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh > index 4f7fa8b6c03..4fedc614fa6 100755 > --- a/t/t6012-rev-list-simplify.sh > +++ b/t/t6012-rev-list-simplify.sh > @@ -12,7 +12,7 @@ note () { > } > > unnote () { > - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" > + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" > } > > # > diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh > index e07b6070e0e..90ff1416400 100755 > --- a/t/t6111-rev-list-treesame.sh > +++ b/t/t6111-rev-list-treesame.sh > @@ -23,7 +23,8 @@ note () { > } > > unnote () { > - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" > + git name-rev --tags --annotate-stdin | \ > + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" > } > > test_expect_success setup ' > diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh > index d8af2bb9d2b..9781b92aedd 100755 > --- a/t/t6120-describe.sh > +++ b/t/t6120-describe.sh > @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' > test_cmp expect actual > ' > > -test_expect_success 'name-rev --stdin' ' > +test_expect_success 'name-rev --annotate-stdin' ' > >expect.unsorted && > for rev in $(git rev-list --all) > do > @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' > echo "$rev ($name)" >>expect.unsorted || return 1 > done && > sort <expect.unsorted >expect && > - git rev-list --all | git name-rev --stdin >actual.unsorted && > + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && > sort <actual.unsorted >actual && > test_cmp expect actual > ' > > +test_expect_success 'name-rev --stdin deprecated' " > + git rev-list --all | git name-rev --stdin 2>actual && > + grep -E 'warning: --stdin is deprecated' actual > +" > + > test_expect_success 'describe --contains with the exact tags' ' > echo "A^0" >expect && > tag_object=$(git rev-parse refs/tags/A) && > ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 11:15 ` Phillip Wood @ 2022-01-05 19:47 ` Junio C Hamano 2022-01-05 19:52 ` Junio C Hamano 1 sibling, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-05 19:47 UTC (permalink / raw) To: Phillip Wood Cc: John Cai via GitGitGadget, git, Johannes Schindelin, John Cai Phillip Wood <phillip.wood123@gmail.com> writes: >> @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) >> for_each_ref(name_ref, &data); >> name_tips(); >> - if (transform_stdin) { >> - char buffer[2048]; >> + if (annotate_stdin) { >> + struct strbuf sb = STRBUF_INIT; > > I think this hunk belongs in the next patch. Before posting a patch > series I find it helpful to run > > git rebase --keep-base -x'make -j4 git && cd t && prove -j4 <tests > I think might fail> :: --root=/dev/shm' > > to check that the individual patches compile and pass the relevant > tests. I've never got round to trying it but git-test[1] also lets you > test all the commits in a series Ahh, I saw and pointed out exactly the same mistake in an earlier round, but failed to spot it this time around. Thanks for spotting. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v4 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 11:15 ` Phillip Wood 2022-01-05 19:47 ` Junio C Hamano @ 2022-01-05 19:52 ` Junio C Hamano 1 sibling, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-05 19:52 UTC (permalink / raw) To: Phillip Wood Cc: John Cai via GitGitGadget, git, Johannes Schindelin, John Cai Phillip Wood <phillip.wood123@gmail.com> writes: >> @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) >> OPT_GROUP(""), >> OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), >> OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), > > If the intention is to deprecate this option then it might be worth > marking it as PARSE_OPT_HIDDEN so that it is not shown by 'git > name-rev -h'. (You need to change OPT_BOOL to OPT_BOOL_F to pass the > flag) Whether we want to do HIDDEN now or not, it is probably a good idea to update the help text to N_("deprecated synonym to --annotate-stdin") or something like that. ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-04 14:49 ` [PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-04 14:49 ` [PATCH v4 1/2] " John Cai via GitGitGadget @ 2022-01-04 14:49 ` John Cai via GitGitGadget 2022-01-04 14:54 ` John Cai 2022-01-05 4:20 ` [PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 1 reply; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-04 14:49 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <johncai86@gmail.com> --- builtin/name-rev.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 21370afdaf9..d16b4ca0b66 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -625,12 +625,11 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) if (annotate_stdin) { struct strbuf sb = STRBUF_INIT; - while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); - if (!p) - break; - name_rev_line(p, &data); + while (strbuf_getline(&sb, stdin) != EOF) { + strbuf_addch(&sb, '\n'); + name_rev_line(sb.buf, &data); } + strbuf_release(&sb); } else if (all) { int i, max; -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-04 14:49 ` [PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-04 14:54 ` John Cai 0 siblings, 0 replies; 43+ messages in thread From: John Cai @ 2022-01-04 14:54 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Johannes Schindelin > On Jan 4, 2022, at 9:49 AM, John Cai via GitGitGadget <gitgitgadget@gmail.com> wrote: > > From: John Cai <johncai86@gmail.com> > > Using a buffer limited to 2048 is unnecessarily limiting. Switch to > using a string buffer to read in stdin for annotation. > > Signed-off-by: "John Cai" <johncai86@gmail.com> > --- > builtin/name-rev.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/builtin/name-rev.c b/builtin/name-rev.c > index 21370afdaf9..d16b4ca0b66 100644 > --- a/builtin/name-rev.c > +++ b/builtin/name-rev.c > @@ -625,12 +625,11 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > if (annotate_stdin) { > struct strbuf sb = STRBUF_INIT; > > - while (!feof(stdin)) { > - char *p = fgets(buffer, sizeof(buffer), stdin); > - if (!p) > - break; > - name_rev_line(p, &data); > + while (strbuf_getline(&sb, stdin) != EOF) { > + strbuf_addch(&sb, '\n'); I agree strbuf_getline is better since it handles EOF across platforms. However, one trouble I ran into is that it does not retain the line terminator, so I had to add it back in this fashion. It looks a little ugly, but let me know if you think this is preferable to using strbuf_getwholeline. > + name_rev_line(sb.buf, &data); > } > + strbuf_release(&sb); > } else if (all) { > int i, max; > > -- > gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-04 14:49 ` [PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-04 14:49 ` [PATCH v4 1/2] " John Cai via GitGitGadget 2022-01-04 14:49 ` [PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-05 4:20 ` John Cai via GitGitGadget 2022-01-05 4:20 ` [PATCH v5 1/2] " John Cai via GitGitGadget ` (2 more replies) 2 siblings, 3 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 4:20 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, the goal is to rename it to --annotate-stdin. This is the first step in a process of eventually fully deprecating --stdin. This change also adds a warning to --stdin warning that it will be removed in the future. See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. changes since v4: * fixed documentation example indentation changes since v3: * use strbuf_getline instead of strbuf_getwholeline (based on Junio's feedback) * fixed commit message s/annotate-text/annotate-stdin (based on Junio's feedback) * since strbuf_getline does not keep the trailing terminator, add back '\n' with strbuf_addchr * reordered documentation blocks based on (Philip Oakley's feedback) * fixed doc typos in example block John Cai (2): name-rev: deprecate --stdin in favor of --annotate-stdin name-rev.c: use strbuf_getline instead of limited size buffer Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 28 ++++++++++++++++---------- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 71 insertions(+), 31 deletions(-) base-commit: c8b2ade48c204690119936ada89cd938c476c5c2 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v5 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v5 Pull-Request: https://github.com/git/git/pull/1171 Range-diff vs v4: 1: 4e9200922a4 ! 1: 7c5fb10d87c name-rev: deprecate --stdin in favor of --annotate-stdin @@ Documentation/git-name-rev.txt: OPTIONS --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. -+ +++ +For example: +++ ++-- ++ $ cat sample.txt + -+---------- -+$ cat sample.txt -+ -+An abbreviated revision 2ae0a9cb82 will not be substituted. -+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, -+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad ++ An abbreviated revision 2ae0a9cb82 will not be substituted. ++ The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, ++ while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + -+$ git name-rev --annotate-stdin <sample.txt ++ $ git name-rev --annotate-stdin <sample.txt + -+An abbreviated revision 2ae0a9cb82 will not be substituted. -+The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), -+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad ++ An abbreviated revision 2ae0a9cb82 will not be substituted. ++ The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), ++ while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + -+$ git name-rev --name-only --annotate-stdin <sample.txt ++ $ git name-rev --name-only --annotate-stdin <sample.txt + -+An abbreviated revision 2ae0a9cb82 will not be substituted. -+The full name after substitution is master, -+while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad -+---------- ++ An abbreviated revision 2ae0a9cb82 will not be substituted. ++ The full name after substitution is master, ++ while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad ++-- + +--stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. 2: 18f77ab9dde = 2: 2acd70f36e7 name-rev.c: use strbuf_getline instead of limited size buffer -- gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v5 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 4:20 ` [PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget @ 2022-01-05 4:20 ` John Cai via GitGitGadget 2022-01-05 20:07 ` Junio C Hamano 2022-01-05 4:20 ` [PATCH v5 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-05 22:59 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 1 reply; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 4:20 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, rename it to --annotate-stdin. This change adds a warning to --stdin warning that it will be removed in the future. Signed-off-by: "John Cai" <johncai86@gmail.com> --- Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 19 +++++++++++++----- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 67 insertions(+), 26 deletions(-) diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 5cb0eb0855f..f57d4633e3c 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -42,11 +42,37 @@ OPTIONS --all:: List all commits reachable from all refs ---stdin:: +--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. ++ +For example: ++ +-- + $ cat sample.txt + + An abbreviated revision 2ae0a9cb82 will not be substituted. + The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, + while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + + $ git name-rev --annotate-stdin <sample.txt + + An abbreviated revision 2ae0a9cb82 will not be substituted. + The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), + while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + + $ git name-rev --name-only --annotate-stdin <sample.txt + + An abbreviated revision 2ae0a9cb82 will not be substituted. + The full name after substitution is master, + while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +-- + +--stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. + They are functionally equivalent. --name-only:: Instead of printing both the SHA-1 and the name, print only diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 27f60153a6c..21370afdaf9 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ -539,6 +539,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) init_commit_rev_name(&rev_names); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { + warning("--stdin is deprecated. Please use --annotate-stdin instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); + annotate_stdin = 1; + } + + if (all + annotate_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) + if (all || annotate_stdin) cutoff = 0; for (; argc; argc--, argv++) { @@ -613,8 +622,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) for_each_ref(name_ref, &data); name_tips(); - if (transform_stdin) { - char buffer[2048]; + if (annotate_stdin) { + struct strbuf sb = STRBUF_INIT; while (!feof(stdin)) { char *p = fgets(buffer, sizeof(buffer), stdin); diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index 19c6f4acbf6..1e9f7833dd6 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME log_with_names () { git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | - git name-rev --stdin --name-only --refs=refs/heads/$1 + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 } diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 50495598619..dc884107de4 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -659,7 +659,7 @@ EOF test_expect_success 'log --graph with full output' ' git log --graph --date-order --pretty=short | - git name-rev --name-only --stdin | + git name-rev --name-only --annotate-stdin | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && test_cmp expect actual ' diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index aebe4b69e13..6f3e5439771 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -58,7 +58,7 @@ EOF test_expect_success '--left-right' ' git rev-list --left-right B...C > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -78,14 +78,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty' ' git rev-list --left-right --cherry-pick B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'bar does not come up empty' ' git rev-list --left-right B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -97,14 +97,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty (II)' ' git rev-list --left-right --cherry-pick F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev multiple --refs combine inclusive' ' git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ <actual >actual.named && test_cmp expect actual.named ' @@ -116,7 +116,7 @@ EOF test_expect_success 'name-rev --refs excludes non-matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ <actual >actual.named && test_cmp expect actual.named ' @@ -128,14 +128,14 @@ EOF test_expect_success 'name-rev --exclude excludes matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ <actual >actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev --no-refs clears the refs list' ' git rev-list --left-right --cherry-pick F...E -- bar >expect && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ <expect >actual && test_cmp expect actual ' @@ -149,7 +149,7 @@ EOF test_expect_success '--cherry-mark' ' git rev-list --cherry-mark F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -163,7 +163,7 @@ EOF test_expect_success '--cherry-mark --left-right' ' git rev-list --cherry-mark --left-right F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -174,14 +174,14 @@ EOF test_expect_success '--cherry-pick --right-only' ' git rev-list --cherry-pick --right-only F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success '--cherry-pick --left-only' ' git rev-list --cherry-pick --left-only E...F -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -193,7 +193,7 @@ EOF test_expect_success '--cherry' ' git rev-list --cherry F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index 4f7fa8b6c03..4fedc614fa6 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -12,7 +12,7 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" } # diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh index e07b6070e0e..90ff1416400 100755 --- a/t/t6111-rev-list-treesame.sh +++ b/t/t6111-rev-list-treesame.sh @@ -23,7 +23,8 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" + git name-rev --tags --annotate-stdin | \ + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" } test_expect_success setup ' diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index d8af2bb9d2b..9781b92aedd 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' test_cmp expect actual ' -test_expect_success 'name-rev --stdin' ' +test_expect_success 'name-rev --annotate-stdin' ' >expect.unsorted && for rev in $(git rev-list --all) do @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' echo "$rev ($name)" >>expect.unsorted || return 1 done && sort <expect.unsorted >expect && - git rev-list --all | git name-rev --stdin >actual.unsorted && + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && sort <actual.unsorted >actual && test_cmp expect actual ' +test_expect_success 'name-rev --stdin deprecated' " + git rev-list --all | git name-rev --stdin 2>actual && + grep -E 'warning: --stdin is deprecated' actual +" + test_expect_success 'describe --contains with the exact tags' ' echo "A^0" >expect && tag_object=$(git rev-parse refs/tags/A) && -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v5 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 4:20 ` [PATCH v5 1/2] " John Cai via GitGitGadget @ 2022-01-05 20:07 ` Junio C Hamano 0 siblings, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-05 20:07 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin, John Cai "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > + altogether. > ++ > +For example: > ++ > +-- > + $ cat sample.txt > + > + An abbreviated revision 2ae0a9cb82 will not be substituted. > + The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, > + while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > + $ git name-rev --annotate-stdin <sample.txt > + > + An abbreviated revision 2ae0a9cb82 will not be substituted. > + The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), > + while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > + $ git name-rev --name-only --annotate-stdin <sample.txt > + > + An abbreviated revision 2ae0a9cb82 will not be substituted. > + The full name after substitution is master, > + while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > +-- I compared the output from the earlier ones with this one; the way the displayed sample was shown in the previous rounds looked better, at least in HTML pages. The earlier ones used "listingblock" in which the sample is contained in a <pre>formatted <code> block, but this one ends up in a series of one-<div>-per-paragraph. > - if (transform_stdin) { > - char buffer[2048]; > + if (annotate_stdin) { > + struct strbuf sb = STRBUF_INIT; This will break the compilation at this step. ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v5 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-05 4:20 ` [PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-05 4:20 ` [PATCH v5 1/2] " John Cai via GitGitGadget @ 2022-01-05 4:20 ` John Cai via GitGitGadget 2022-01-05 22:59 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2 siblings, 0 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 4:20 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <johncai86@gmail.com> --- builtin/name-rev.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 21370afdaf9..d16b4ca0b66 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -625,12 +625,11 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) if (annotate_stdin) { struct strbuf sb = STRBUF_INIT; - while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); - if (!p) - break; - name_rev_line(p, &data); + while (strbuf_getline(&sb, stdin) != EOF) { + strbuf_addch(&sb, '\n'); + name_rev_line(sb.buf, &data); } + strbuf_release(&sb); } else if (all) { int i, max; -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 4:20 ` [PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-05 4:20 ` [PATCH v5 1/2] " John Cai via GitGitGadget 2022-01-05 4:20 ` [PATCH v5 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-05 22:59 ` John Cai via GitGitGadget 2022-01-05 22:59 ` [PATCH v6 1/2] " John Cai via GitGitGadget ` (3 more replies) 2 siblings, 4 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 22:59 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, the goal is to rename it to --annotate-stdin. This is the first step in a process of eventually fully deprecating --stdin. This change also adds a warning to --stdin warning that it will be removed in the future. See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. changes since v5: * fixed documentation example indentation (again) * moved initialization of strbuf from 1/2 to 2/2 changes since v4: * fixed documentation example indentation changes since v3: * use strbuf_getline instead of strbuf_getwholeline (based on Junio's feedback) * fixed commit message s/annotate-text/annotate-stdin (based on Junio's feedback) * since strbuf_getline does not keep the trailing terminator, add back '\n' with strbuf_addchr * reordered documentation blocks based on (Philip Oakley's feedback) * fixed doc typos in example block John Cai (2): name-rev: deprecate --stdin in favor of --annotate-stdin name-rev.c: use strbuf_getline instead of limited size buffer Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 30 ++++++++++++++++++---------- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 72 insertions(+), 32 deletions(-) base-commit: c8b2ade48c204690119936ada89cd938c476c5c2 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v6 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v6 Pull-Request: https://github.com/git/git/pull/1171 Range-diff vs v5: 1: 7c5fb10d87c ! 1: 3caf254a73e name-rev: deprecate --stdin in favor of --annotate-stdin @@ Documentation/git-name-rev.txt: OPTIONS ++ +For example: ++ -+-- -+ $ cat sample.txt ++----------- ++$ cat sample.txt + -+ An abbreviated revision 2ae0a9cb82 will not be substituted. -+ The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, -+ while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad ++An abbreviated revision 2ae0a9cb82 will not be substituted. ++The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, ++while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + -+ $ git name-rev --annotate-stdin <sample.txt ++$ git name-rev --annotate-stdin <sample.txt + -+ An abbreviated revision 2ae0a9cb82 will not be substituted. -+ The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), -+ while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad ++An abbreviated revision 2ae0a9cb82 will not be substituted. ++The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), ++while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + -+ $ git name-rev --name-only --annotate-stdin <sample.txt ++$ git name-rev --name-only --annotate-stdin <sample.txt + -+ An abbreviated revision 2ae0a9cb82 will not be substituted. -+ The full name after substitution is master, -+ while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad -+-- ++An abbreviated revision 2ae0a9cb82 will not be substituted. ++The full name after substitution is master, ++while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad ++----------- + +--stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. @@ builtin/name-rev.c: static void name_rev_line(char *p, struct name_ref_data *dat struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *prefix) + N_("ignore refs matching <pattern>")), OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), - OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), +- OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), ++ OPT_BOOL_F(0, "stdin", &transform_stdin, N_("deprecated: use annotate-stdin instead"), PARSE_OPT_HIDDEN), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr name_tips(); - if (transform_stdin) { -- char buffer[2048]; + if (annotate_stdin) { -+ struct strbuf sb = STRBUF_INIT; + char buffer[2048]; while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); ## t/t3412-rebase-root.sh ## @@ t/t3412-rebase-root.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 2: 2acd70f36e7 ! 2: 32ad96530b9 name-rev.c: use strbuf_getline instead of limited size buffer @@ Commit message ## builtin/name-rev.c ## @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *prefix) + name_tips(); + if (annotate_stdin) { - struct strbuf sb = STRBUF_INIT; +- char buffer[2048]; ++ struct strbuf sb = STRBUF_INIT; - while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); -- gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v6 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 22:59 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget @ 2022-01-05 22:59 ` John Cai via GitGitGadget 2022-01-05 23:00 ` [PATCH v6 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget ` (2 subsequent siblings) 3 siblings, 0 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 22:59 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, rename it to --annotate-stdin. This change adds a warning to --stdin warning that it will be removed in the future. Signed-off-by: "John Cai" <johncai86@gmail.com> --- Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 19 +++++++++++++----- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 67 insertions(+), 26 deletions(-) diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 5cb0eb0855f..ec8a27ce8bf 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -42,11 +42,37 @@ OPTIONS --all:: List all commits reachable from all refs ---stdin:: +--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. ++ +For example: ++ +----------- +$ cat sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +----------- + +--stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. + They are functionally equivalent. --name-only:: Instead of printing both the SHA-1 and the name, print only diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 27f60153a6c..4941cfb4340 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ -538,7 +538,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) N_("ignore refs matching <pattern>")), OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), - OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), + OPT_BOOL_F(0, "stdin", &transform_stdin, N_("deprecated: use annotate-stdin instead"), PARSE_OPT_HIDDEN), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) init_commit_rev_name(&rev_names); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { + warning("--stdin is deprecated. Please use --annotate-stdin instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); + annotate_stdin = 1; + } + + if (all + annotate_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) + if (all || annotate_stdin) cutoff = 0; for (; argc; argc--, argv++) { @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) for_each_ref(name_ref, &data); name_tips(); - if (transform_stdin) { + if (annotate_stdin) { char buffer[2048]; while (!feof(stdin)) { diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index 19c6f4acbf6..1e9f7833dd6 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME log_with_names () { git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | - git name-rev --stdin --name-only --refs=refs/heads/$1 + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 } diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 50495598619..dc884107de4 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -659,7 +659,7 @@ EOF test_expect_success 'log --graph with full output' ' git log --graph --date-order --pretty=short | - git name-rev --name-only --stdin | + git name-rev --name-only --annotate-stdin | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && test_cmp expect actual ' diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index aebe4b69e13..6f3e5439771 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -58,7 +58,7 @@ EOF test_expect_success '--left-right' ' git rev-list --left-right B...C > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -78,14 +78,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty' ' git rev-list --left-right --cherry-pick B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'bar does not come up empty' ' git rev-list --left-right B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -97,14 +97,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty (II)' ' git rev-list --left-right --cherry-pick F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev multiple --refs combine inclusive' ' git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ <actual >actual.named && test_cmp expect actual.named ' @@ -116,7 +116,7 @@ EOF test_expect_success 'name-rev --refs excludes non-matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ <actual >actual.named && test_cmp expect actual.named ' @@ -128,14 +128,14 @@ EOF test_expect_success 'name-rev --exclude excludes matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ <actual >actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev --no-refs clears the refs list' ' git rev-list --left-right --cherry-pick F...E -- bar >expect && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ <expect >actual && test_cmp expect actual ' @@ -149,7 +149,7 @@ EOF test_expect_success '--cherry-mark' ' git rev-list --cherry-mark F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -163,7 +163,7 @@ EOF test_expect_success '--cherry-mark --left-right' ' git rev-list --cherry-mark --left-right F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -174,14 +174,14 @@ EOF test_expect_success '--cherry-pick --right-only' ' git rev-list --cherry-pick --right-only F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success '--cherry-pick --left-only' ' git rev-list --cherry-pick --left-only E...F -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -193,7 +193,7 @@ EOF test_expect_success '--cherry' ' git rev-list --cherry F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index 4f7fa8b6c03..4fedc614fa6 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -12,7 +12,7 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" } # diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh index e07b6070e0e..90ff1416400 100755 --- a/t/t6111-rev-list-treesame.sh +++ b/t/t6111-rev-list-treesame.sh @@ -23,7 +23,8 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" + git name-rev --tags --annotate-stdin | \ + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" } test_expect_success setup ' diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index d8af2bb9d2b..9781b92aedd 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' test_cmp expect actual ' -test_expect_success 'name-rev --stdin' ' +test_expect_success 'name-rev --annotate-stdin' ' >expect.unsorted && for rev in $(git rev-list --all) do @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' echo "$rev ($name)" >>expect.unsorted || return 1 done && sort <expect.unsorted >expect && - git rev-list --all | git name-rev --stdin >actual.unsorted && + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && sort <actual.unsorted >actual && test_cmp expect actual ' +test_expect_success 'name-rev --stdin deprecated' " + git rev-list --all | git name-rev --stdin 2>actual && + grep -E 'warning: --stdin is deprecated' actual +" + test_expect_success 'describe --contains with the exact tags' ' echo "A^0" >expect && tag_object=$(git rev-parse refs/tags/A) && -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* [PATCH v6 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-05 22:59 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-05 22:59 ` [PATCH v6 1/2] " John Cai via GitGitGadget @ 2022-01-05 23:00 ` John Cai via GitGitGadget 2022-01-05 23:12 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin Junio C Hamano 2022-01-05 23:29 ` [PATCH v7 " John Cai via GitGitGadget 3 siblings, 0 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 23:00 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <johncai86@gmail.com> --- builtin/name-rev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 4941cfb4340..7164b54cb79 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) name_tips(); if (annotate_stdin) { - char buffer[2048]; + struct strbuf sb = STRBUF_INIT; - while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); - if (!p) - break; - name_rev_line(p, &data); + while (strbuf_getline(&sb, stdin) != EOF) { + strbuf_addch(&sb, '\n'); + name_rev_line(sb.buf, &data); } + strbuf_release(&sb); } else if (all) { int i, max; -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 22:59 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-05 22:59 ` [PATCH v6 1/2] " John Cai via GitGitGadget 2022-01-05 23:00 ` [PATCH v6 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-05 23:12 ` Junio C Hamano 2022-01-05 23:29 ` [PATCH v7 " John Cai via GitGitGadget 3 siblings, 0 replies; 43+ messages in thread From: Junio C Hamano @ 2022-01-05 23:12 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin, John Cai "John Cai via GitGitGadget" <gitgitgadget@gmail.com> writes: > Introduce a --annotate-stdin that is functionally equivalent of --stdin. > --stdin does not behave as --stdin in other subcommands, such as > pack-objects whereby it takes one argument per line. Since --stdin can be a > confusing and misleading name, the goal is to rename it to --annotate-stdin. > > This is the first step in a process of eventually fully deprecating --stdin. > This change also adds a warning to --stdin warning that it will be removed > in the future. > > See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. > > changes since v5: > > * fixed documentation example indentation (again) > * moved initialization of strbuf from 1/2 to 2/2 This round looks almost perfect. One I can think of that _may_ be a good idea to change from this version is to undo the HIDDEN thing, so that "git name-rev -h", without "git name-rev --help-all", will prominently say that "--stdin" is deprecated, and make it an hidden option sometime later, but that is not even "I think we should do so", but more like "if other people think it is a good idea, I would be supportive". Thanks. ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v7 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 22:59 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget ` (2 preceding siblings ...) 2022-01-05 23:12 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin Junio C Hamano @ 2022-01-05 23:29 ` John Cai via GitGitGadget 2022-01-05 23:29 ` [PATCH v7 1/2] " John Cai via GitGitGadget 2022-01-05 23:29 ` [PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 3 siblings, 2 replies; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 23:29 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, the goal is to rename it to --annotate-stdin. This is the first step in a process of eventually fully deprecating --stdin. This change also adds a warning to --stdin warning that it will be removed in the future. See https://lore.kernel.org/git/xmqqsfuh1pxz.fsf@gitster.g/ for discussion. changes since v6: * change OPT_BOOL from hidden back to normal mode changes since v5: * fixed documentation example indentation (again) * moved initialization of strbuf from 1/2 to 2/2 changes since v4: * fixed documentation example indentation changes since v3: * use strbuf_getline instead of strbuf_getwholeline (based on Junio's feedback) * fixed commit message s/annotate-text/annotate-stdin (based on Junio's feedback) * since strbuf_getline does not keep the trailing terminator, add back '\n' with strbuf_addchr * reordered documentation blocks based on (Philip Oakley's feedback) * fixed doc typos in example block John Cai (2): name-rev: deprecate --stdin in favor of --annotate-stdin name-rev.c: use strbuf_getline instead of limited size buffer Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 30 ++++++++++++++++++---------- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 72 insertions(+), 32 deletions(-) base-commit: c8b2ade48c204690119936ada89cd938c476c5c2 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1171%2Fjohn-cai%2Fjc%2Fdeprecate-name-rev-stdin-v7 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1171/john-cai/jc/deprecate-name-rev-stdin-v7 Pull-Request: https://github.com/git/git/pull/1171 Range-diff vs v6: 1: 3caf254a73e ! 1: 153f69ea9b6 name-rev: deprecate --stdin in favor of --annotate-stdin @@ builtin/name-rev.c: int cmd_name_rev(int argc, const char **argv, const char *pr OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), - OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), -+ OPT_BOOL_F(0, "stdin", &transform_stdin, N_("deprecated: use annotate-stdin instead"), PARSE_OPT_HIDDEN), ++ OPT_BOOL(0, "stdin", &transform_stdin, N_("deprecated: use annotate-stdin instead")), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, 2: 32ad96530b9 = 2: 19e7bf96557 name-rev.c: use strbuf_getline instead of limited size buffer -- gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 23:29 ` [PATCH v7 " John Cai via GitGitGadget @ 2022-01-05 23:29 ` John Cai via GitGitGadget 2022-01-08 13:47 ` John Cai 2022-01-05 23:29 ` [PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 1 sibling, 1 reply; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 23:29 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Introduce a --annotate-stdin that is functionally equivalent of --stdin. --stdin does not behave as --stdin in other subcommands, such as pack-objects whereby it takes one argument per line. Since --stdin can be a confusing and misleading name, rename it to --annotate-stdin. This change adds a warning to --stdin warning that it will be removed in the future. Signed-off-by: "John Cai" <johncai86@gmail.com> --- Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- builtin/name-rev.c | 19 +++++++++++++----- t/t3412-rebase-root.sh | 2 +- t/t4202-log.sh | 2 +- t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ t/t6012-rev-list-simplify.sh | 2 +- t/t6111-rev-list-treesame.sh | 3 ++- t/t6120-describe.sh | 9 +++++++-- 8 files changed, 67 insertions(+), 26 deletions(-) diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt index 5cb0eb0855f..ec8a27ce8bf 100644 --- a/Documentation/git-name-rev.txt +++ b/Documentation/git-name-rev.txt @@ -42,11 +42,37 @@ OPTIONS --all:: List all commits reachable from all refs ---stdin:: +--annotate-stdin:: Transform stdin by substituting all the 40-character SHA-1 hexes (say $hex) with "$hex ($rev_name)". When used with --name-only, substitute with "$rev_name", omitting $hex - altogether. Intended for the scripter's use. + altogether. ++ +For example: ++ +----------- +$ cat sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad + +$ git name-rev --name-only --annotate-stdin <sample.txt + +An abbreviated revision 2ae0a9cb82 will not be substituted. +The full name after substitution is master, +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad +----------- + +--stdin:: + This option is deprecated in favor of 'git name-rev --annotate-stdin'. + They are functionally equivalent. --name-only:: Instead of printing both the SHA-1 and the name, print only diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 27f60153a6c..8baf5b52d0b 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) int cmd_name_rev(int argc, const char **argv, const char *prefix) { struct object_array revs = OBJECT_ARRAY_INIT; - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; struct option opts[] = { OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), @@ -538,7 +538,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) N_("ignore refs matching <pattern>")), OPT_GROUP(""), OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), - OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), + OPT_BOOL(0, "stdin", &transform_stdin, N_("deprecated: use annotate-stdin instead")), + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), OPT_BOOL(0, "always", &always, N_("show abbreviated commit object as fallback")), @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) init_commit_rev_name(&rev_names); git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); - if (all + transform_stdin + !!argc > 1) { + + if (transform_stdin) { + warning("--stdin is deprecated. Please use --annotate-stdin instead, " + "which is functionally equivalent.\n" + "This option will be removed in a future release."); + annotate_stdin = 1; + } + + if (all + annotate_stdin + !!argc > 1) { error("Specify either a list, or --all, not both!"); usage_with_options(name_rev_usage, opts); } - if (all || transform_stdin) + if (all || annotate_stdin) cutoff = 0; for (; argc; argc--, argv++) { @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) for_each_ref(name_ref, &data); name_tips(); - if (transform_stdin) { + if (annotate_stdin) { char buffer[2048]; while (!feof(stdin)) { diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh index 19c6f4acbf6..1e9f7833dd6 100755 --- a/t/t3412-rebase-root.sh +++ b/t/t3412-rebase-root.sh @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME log_with_names () { git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | - git name-rev --stdin --name-only --refs=refs/heads/$1 + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 } diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 50495598619..dc884107de4 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -659,7 +659,7 @@ EOF test_expect_success 'log --graph with full output' ' git log --graph --date-order --pretty=short | - git name-rev --name-only --stdin | + git name-rev --name-only --annotate-stdin | sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && test_cmp expect actual ' diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index aebe4b69e13..6f3e5439771 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -58,7 +58,7 @@ EOF test_expect_success '--left-right' ' git rev-list --left-right B...C > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -78,14 +78,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty' ' git rev-list --left-right --cherry-pick B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'bar does not come up empty' ' git rev-list --left-right B...C -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -97,14 +97,14 @@ EOF test_expect_success '--cherry-pick bar does not come up empty (II)' ' git rev-list --left-right --cherry-pick F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev multiple --refs combine inclusive' ' git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ <actual >actual.named && test_cmp expect actual.named ' @@ -116,7 +116,7 @@ EOF test_expect_success 'name-rev --refs excludes non-matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/F" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ <actual >actual.named && test_cmp expect actual.named ' @@ -128,14 +128,14 @@ EOF test_expect_success 'name-rev --exclude excludes matched patterns' ' git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && git rev-list --left-right --cherry-pick F...E -- bar >actual && - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ <actual >actual.named && test_cmp expect actual.named ' test_expect_success 'name-rev --no-refs clears the refs list' ' git rev-list --left-right --cherry-pick F...E -- bar >expect && - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ <expect >actual && test_cmp expect actual ' @@ -149,7 +149,7 @@ EOF test_expect_success '--cherry-mark' ' git rev-list --cherry-mark F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -163,7 +163,7 @@ EOF test_expect_success '--cherry-mark --left-right' ' git rev-list --cherry-mark --left-right F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -174,14 +174,14 @@ EOF test_expect_success '--cherry-pick --right-only' ' git rev-list --cherry-pick --right-only F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' test_expect_success '--cherry-pick --left-only' ' git rev-list --cherry-pick --left-only E...F -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' @@ -193,7 +193,7 @@ EOF test_expect_success '--cherry' ' git rev-list --cherry F...E -- bar > actual && - git name-rev --stdin --name-only --refs="*tags/*" \ + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ < actual > actual.named && test_cmp expect actual.named ' diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index 4f7fa8b6c03..4fedc614fa6 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -12,7 +12,7 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" } # diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh index e07b6070e0e..90ff1416400 100755 --- a/t/t6111-rev-list-treesame.sh +++ b/t/t6111-rev-list-treesame.sh @@ -23,7 +23,8 @@ note () { } unnote () { - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" + git name-rev --tags --annotate-stdin | \ + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" } test_expect_success setup ' diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh index d8af2bb9d2b..9781b92aedd 100755 --- a/t/t6120-describe.sh +++ b/t/t6120-describe.sh @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' test_cmp expect actual ' -test_expect_success 'name-rev --stdin' ' +test_expect_success 'name-rev --annotate-stdin' ' >expect.unsorted && for rev in $(git rev-list --all) do @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' echo "$rev ($name)" >>expect.unsorted || return 1 done && sort <expect.unsorted >expect && - git rev-list --all | git name-rev --stdin >actual.unsorted && + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && sort <actual.unsorted >actual && test_cmp expect actual ' +test_expect_success 'name-rev --stdin deprecated' " + git rev-list --all | git name-rev --stdin 2>actual && + grep -E 'warning: --stdin is deprecated' actual +" + test_expect_success 'describe --contains with the exact tags' ' echo "A^0" >expect && tag_object=$(git rev-parse refs/tags/A) && -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-05 23:29 ` [PATCH v7 1/2] " John Cai via GitGitGadget @ 2022-01-08 13:47 ` John Cai 2022-01-10 17:38 ` Junio C Hamano 0 siblings, 1 reply; 43+ messages in thread From: John Cai @ 2022-01-08 13:47 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin Hi Junio, On 5 Jan 2022, at 18:29, John Cai via GitGitGadget wrote: > From: John Cai <johncai86@gmail.com> > > Introduce a --annotate-stdin that is functionally equivalent of --stdin. > --stdin does not behave as --stdin in other subcommands, such as > pack-objects whereby it takes one argument per line. Since --stdin can > be a confusing and misleading name, rename it to --annotate-stdin. > > This change adds a warning to --stdin warning that it will be removed in > the future. > > Signed-off-by: "John Cai" <johncai86@gmail.com> > --- > Documentation/git-name-rev.txt | 30 ++++++++++++++++++++++++++-- > builtin/name-rev.c | 19 +++++++++++++----- > t/t3412-rebase-root.sh | 2 +- > t/t4202-log.sh | 2 +- > t/t6007-rev-list-cherry-pick-file.sh | 26 ++++++++++++------------ > t/t6012-rev-list-simplify.sh | 2 +- > t/t6111-rev-list-treesame.sh | 3 ++- > t/t6120-describe.sh | 9 +++++++-- > 8 files changed, 67 insertions(+), 26 deletions(-) > > diff --git a/Documentation/git-name-rev.txt b/Documentation/git-name-rev.txt > index 5cb0eb0855f..ec8a27ce8bf 100644 > --- a/Documentation/git-name-rev.txt > +++ b/Documentation/git-name-rev.txt > @@ -42,11 +42,37 @@ OPTIONS > --all:: > List all commits reachable from all refs > > ---stdin:: > +--annotate-stdin:: > Transform stdin by substituting all the 40-character SHA-1 > hexes (say $hex) with "$hex ($rev_name)". When used with > --name-only, substitute with "$rev_name", omitting $hex > - altogether. Intended for the scripter's use. > + altogether. > ++ > +For example: > ++ > +----------- > +$ cat sample.txt > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907, > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > +$ git name-rev --annotate-stdin <sample.txt > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name after substitution is 2ae0a9cb8298185a94e5998086f380a355dd8907 (master), > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > + > +$ git name-rev --name-only --annotate-stdin <sample.txt > + > +An abbreviated revision 2ae0a9cb82 will not be substituted. > +The full name after substitution is master, > +while its tree object is 70d105cc79e63b81cfdcb08a15297c23e60b07ad > +----------- > + > +--stdin:: > + This option is deprecated in favor of 'git name-rev --annotate-stdin'. > + They are functionally equivalent. > > --name-only:: > Instead of printing both the SHA-1 and the name, print only > diff --git a/builtin/name-rev.c b/builtin/name-rev.c > index 27f60153a6c..8baf5b52d0b 100644 > --- a/builtin/name-rev.c > +++ b/builtin/name-rev.c > @@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data) > int cmd_name_rev(int argc, const char **argv, const char *prefix) > { > struct object_array revs = OBJECT_ARRAY_INIT; > - int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; > + int all = 0, annotate_stdin = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; > struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP }; > struct option opts[] = { > OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")), > @@ -538,7 +538,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > N_("ignore refs matching <pattern>")), > OPT_GROUP(""), > OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")), > - OPT_BOOL(0, "stdin", &transform_stdin, N_("read from stdin")), > + OPT_BOOL(0, "stdin", &transform_stdin, N_("deprecated: use annotate-stdin instead")), > + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), > OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), I’ve changed this back to a non hidden bool. I believe this should be the last thing needed on this one. Let me know if anything else needs adjustment, thanks! > OPT_BOOL(0, "always", &always, > N_("show abbreviated commit object as fallback")), > @@ -554,11 +555,19 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > init_commit_rev_name(&rev_names); > git_config(git_default_config, NULL); > argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0); > - if (all + transform_stdin + !!argc > 1) { > + > + if (transform_stdin) { > + warning("--stdin is deprecated. Please use --annotate-stdin instead, " > + "which is functionally equivalent.\n" > + "This option will be removed in a future release."); > + annotate_stdin = 1; > + } > + > + if (all + annotate_stdin + !!argc > 1) { > error("Specify either a list, or --all, not both!"); > usage_with_options(name_rev_usage, opts); > } > - if (all || transform_stdin) > + if (all || annotate_stdin) > cutoff = 0; > > for (; argc; argc--, argv++) { > @@ -613,7 +622,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > for_each_ref(name_ref, &data); > name_tips(); > > - if (transform_stdin) { > + if (annotate_stdin) { > char buffer[2048]; > > while (!feof(stdin)) { > diff --git a/t/t3412-rebase-root.sh b/t/t3412-rebase-root.sh > index 19c6f4acbf6..1e9f7833dd6 100755 > --- a/t/t3412-rebase-root.sh > +++ b/t/t3412-rebase-root.sh > @@ -11,7 +11,7 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME > > log_with_names () { > git rev-list --topo-order --parents --pretty="tformat:%s" HEAD | > - git name-rev --stdin --name-only --refs=refs/heads/$1 > + git name-rev --annotate-stdin --name-only --refs=refs/heads/$1 > } > > > diff --git a/t/t4202-log.sh b/t/t4202-log.sh > index 50495598619..dc884107de4 100755 > --- a/t/t4202-log.sh > +++ b/t/t4202-log.sh > @@ -659,7 +659,7 @@ EOF > > test_expect_success 'log --graph with full output' ' > git log --graph --date-order --pretty=short | > - git name-rev --name-only --stdin | > + git name-rev --name-only --annotate-stdin | > sed "s/Merge:.*/Merge: A B/;s/ *\$//" >actual && > test_cmp expect actual > ' > diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh > index aebe4b69e13..6f3e5439771 100755 > --- a/t/t6007-rev-list-cherry-pick-file.sh > +++ b/t/t6007-rev-list-cherry-pick-file.sh > @@ -58,7 +58,7 @@ EOF > > test_expect_success '--left-right' ' > git rev-list --left-right B...C > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -78,14 +78,14 @@ EOF > > test_expect_success '--cherry-pick bar does not come up empty' ' > git rev-list --left-right --cherry-pick B...C -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'bar does not come up empty' ' > git rev-list --left-right B...C -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -97,14 +97,14 @@ EOF > > test_expect_success '--cherry-pick bar does not come up empty (II)' ' > git rev-list --left-right --cherry-pick F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'name-rev multiple --refs combine inclusive' ' > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" \ > <actual >actual.named && > test_cmp expect actual.named > ' > @@ -116,7 +116,7 @@ EOF > test_expect_success 'name-rev --refs excludes non-matched patterns' ' > git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/F" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" \ > <actual >actual.named && > test_cmp expect actual.named > ' > @@ -128,14 +128,14 @@ EOF > test_expect_success 'name-rev --exclude excludes matched patterns' ' > git rev-list --left-right --right-only --cherry-pick F...E -- bar >>expect && > git rev-list --left-right --cherry-pick F...E -- bar >actual && > - git name-rev --stdin --name-only --refs="*tags/*" --exclude="*E" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" --exclude="*E" \ > <actual >actual.named && > test_cmp expect actual.named > ' > > test_expect_success 'name-rev --no-refs clears the refs list' ' > git rev-list --left-right --cherry-pick F...E -- bar >expect && > - git name-rev --stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/F" --refs="*tags/E" --no-refs --refs="*tags/G" \ > <expect >actual && > test_cmp expect actual > ' > @@ -149,7 +149,7 @@ EOF > > test_expect_success '--cherry-mark' ' > git rev-list --cherry-mark F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -163,7 +163,7 @@ EOF > > test_expect_success '--cherry-mark --left-right' ' > git rev-list --cherry-mark --left-right F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -174,14 +174,14 @@ EOF > > test_expect_success '--cherry-pick --right-only' ' > git rev-list --cherry-pick --right-only F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > > test_expect_success '--cherry-pick --left-only' ' > git rev-list --cherry-pick --left-only E...F -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > @@ -193,7 +193,7 @@ EOF > > test_expect_success '--cherry' ' > git rev-list --cherry F...E -- bar > actual && > - git name-rev --stdin --name-only --refs="*tags/*" \ > + git name-rev --annotate-stdin --name-only --refs="*tags/*" \ > < actual > actual.named && > test_cmp expect actual.named > ' > diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh > index 4f7fa8b6c03..4fedc614fa6 100755 > --- a/t/t6012-rev-list-simplify.sh > +++ b/t/t6012-rev-list-simplify.sh > @@ -12,7 +12,7 @@ note () { > } > > unnote () { > - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" > + git name-rev --tags --annotate-stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g" > } > > # > diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh > index e07b6070e0e..90ff1416400 100755 > --- a/t/t6111-rev-list-treesame.sh > +++ b/t/t6111-rev-list-treesame.sh > @@ -23,7 +23,8 @@ note () { > } > > unnote () { > - git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" > + git name-rev --tags --annotate-stdin | \ > + sed -e "s|$OID_REGEX (tags/\([^)]*\))\([ ]\)|\1\2|g" > } > > test_expect_success setup ' > diff --git a/t/t6120-describe.sh b/t/t6120-describe.sh > index d8af2bb9d2b..9781b92aedd 100755 > --- a/t/t6120-describe.sh > +++ b/t/t6120-describe.sh > @@ -270,7 +270,7 @@ test_expect_success 'name-rev --all' ' > test_cmp expect actual > ' > > -test_expect_success 'name-rev --stdin' ' > +test_expect_success 'name-rev --annotate-stdin' ' > >expect.unsorted && > for rev in $(git rev-list --all) > do > @@ -278,11 +278,16 @@ test_expect_success 'name-rev --stdin' ' > echo "$rev ($name)" >>expect.unsorted || return 1 > done && > sort <expect.unsorted >expect && > - git rev-list --all | git name-rev --stdin >actual.unsorted && > + git rev-list --all | git name-rev --annotate-stdin >actual.unsorted && > sort <actual.unsorted >actual && > test_cmp expect actual > ' > > +test_expect_success 'name-rev --stdin deprecated' " > + git rev-list --all | git name-rev --stdin 2>actual && > + grep -E 'warning: --stdin is deprecated' actual > +" > + > test_expect_success 'describe --contains with the exact tags' ' > echo "A^0" >expect && > tag_object=$(git rev-parse refs/tags/A) && > -- > gitgitgadget ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-08 13:47 ` John Cai @ 2022-01-10 17:38 ` Junio C Hamano 2022-01-10 19:01 ` John Cai 0 siblings, 1 reply; 43+ messages in thread From: Junio C Hamano @ 2022-01-10 17:38 UTC (permalink / raw) To: John Cai; +Cc: John Cai via GitGitGadget, git, Johannes Schindelin John Cai <johncai86@gmail.com> writes: > Hi Junio, > > ... Please trim quotes that are irrelevant for understanding what you want to say in your message to save recipient's time to find what you wrote. >> + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), >> OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), > > I’ve changed this back to a non hidden bool. I believe this should be the last thing needed on this one. > Let me know if anything else needs adjustment, thanks! As I said, my mention of hidden vs non-hidden was not my preferrence of non-hidden over hidden, but was soliciting opinions from others, so I was a bit surprised to see a reroll to change only that thing and nothing else so soon. But if it is your preference to leave it unhidden for now, that is fine as well. I have no strong preference over the matter either way. I see only Dscho on the CC list, but I have this feeling that he wasn't the one who suggested to hide the old option. Whoever it was, if we can get an ack from them, that would be nicer. Thanks for working on this. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-10 17:38 ` Junio C Hamano @ 2022-01-10 19:01 ` John Cai 2022-01-10 19:11 ` Junio C Hamano 0 siblings, 1 reply; 43+ messages in thread From: John Cai @ 2022-01-10 19:01 UTC (permalink / raw) To: Junio C Hamano Cc: John Cai via GitGitGadget, git, Johannes Schindelin, phillip.wood123 Cc’ing Phillip, as he was the one who made the suggestion to make it hidden On 10 Jan 2022, at 12:38, Junio C Hamano wrote: > John Cai <johncai86@gmail.com> writes: > >> Hi Junio, >> >> ... > > Please trim quotes that are irrelevant for understanding what you > want to say in your message to save recipient's time to find what > you wrote. > >>> + OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")), >>> OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")), >> >> I’ve changed this back to a non hidden bool. I believe this should be the last thing needed on this one. >> Let me know if anything else needs adjustment, thanks! > > As I said, my mention of hidden vs non-hidden was not my preferrence > of non-hidden over hidden, but was soliciting opinions from others, > so I was a bit surprised to see a reroll to change only that thing > and nothing else so soon. > > But if it is your preference to leave it unhidden for now, that is > fine as well. I have no strong preference over the matter either > way. I think it makes sense in this first iteration to keep it non-hidden for visibility purposes. Maybe in the next release we can make it hidden before we move it altogether. > > I see only Dscho on the CC list, but I have this feeling that he > wasn't the one who suggested to hide the old option. Whoever it > was, if we can get an ack from them, that would be nicer. > > Thanks for working on this. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-10 19:01 ` John Cai @ 2022-01-10 19:11 ` Junio C Hamano 2022-01-11 11:01 ` Phillip Wood 0 siblings, 1 reply; 43+ messages in thread From: Junio C Hamano @ 2022-01-10 19:11 UTC (permalink / raw) To: John Cai Cc: John Cai via GitGitGadget, git, Johannes Schindelin, phillip.wood123 John Cai <johncai86@gmail.com> writes: >> As I said, my mention of hidden vs non-hidden was not my preferrence >> of non-hidden over hidden, but was soliciting opinions from others, >> so I was a bit surprised to see a reroll to change only that thing >> and nothing else so soon. >> >> But if it is your preference to leave it unhidden for now, that is >> fine as well. I have no strong preference over the matter either >> way. > > I think it makes sense in this first iteration to keep it > non-hidden for visibility purposes. Maybe in the next release we > can make it hidden before we move it altogether. I think that is a sensible way forward. ^ permalink raw reply [flat|nested] 43+ messages in thread
* Re: [PATCH v7 1/2] name-rev: deprecate --stdin in favor of --annotate-stdin 2022-01-10 19:11 ` Junio C Hamano @ 2022-01-11 11:01 ` Phillip Wood 0 siblings, 0 replies; 43+ messages in thread From: Phillip Wood @ 2022-01-11 11:01 UTC (permalink / raw) To: Junio C Hamano, John Cai Cc: John Cai via GitGitGadget, git, Johannes Schindelin On 10/01/2022 19:11, Junio C Hamano wrote: > John Cai <johncai86@gmail.com> writes: > >>> As I said, my mention of hidden vs non-hidden was not my preferrence >>> of non-hidden over hidden, but was soliciting opinions from others, >>> so I was a bit surprised to see a reroll to change only that thing >>> and nothing else so soon. >>> >>> But if it is your preference to leave it unhidden for now, that is >>> fine as well. I have no strong preference over the matter either >>> way. >> >> I think it makes sense in this first iteration to keep it >> non-hidden for visibility purposes. Maybe in the next release we >> can make it hidden before we move it altogether. > > I think that is a sensible way forward. I agree Thanks Phillip ^ permalink raw reply [flat|nested] 43+ messages in thread
* [PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-05 23:29 ` [PATCH v7 " John Cai via GitGitGadget 2022-01-05 23:29 ` [PATCH v7 1/2] " John Cai via GitGitGadget @ 2022-01-05 23:29 ` John Cai via GitGitGadget 2022-01-18 16:09 ` Ævar Arnfjörð Bjarmason 1 sibling, 1 reply; 43+ messages in thread From: John Cai via GitGitGadget @ 2022-01-05 23:29 UTC (permalink / raw) To: git; +Cc: Johannes Schindelin, John Cai, John Cai From: John Cai <johncai86@gmail.com> Using a buffer limited to 2048 is unnecessarily limiting. Switch to using a string buffer to read in stdin for annotation. Signed-off-by: "John Cai" <johncai86@gmail.com> --- builtin/name-rev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 8baf5b52d0b..138e3c30a2b 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) name_tips(); if (annotate_stdin) { - char buffer[2048]; + struct strbuf sb = STRBUF_INIT; - while (!feof(stdin)) { - char *p = fgets(buffer, sizeof(buffer), stdin); - if (!p) - break; - name_rev_line(p, &data); + while (strbuf_getline(&sb, stdin) != EOF) { + strbuf_addch(&sb, '\n'); + name_rev_line(sb.buf, &data); } + strbuf_release(&sb); } else if (all) { int i, max; -- gitgitgadget ^ permalink raw reply related [flat|nested] 43+ messages in thread
* Re: [PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer 2022-01-05 23:29 ` [PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget @ 2022-01-18 16:09 ` Ævar Arnfjörð Bjarmason 0 siblings, 0 replies; 43+ messages in thread From: Ævar Arnfjörð Bjarmason @ 2022-01-18 16:09 UTC (permalink / raw) To: John Cai via GitGitGadget; +Cc: git, Johannes Schindelin, John Cai On Wed, Jan 05 2022, John Cai via GitGitGadget wrote: > From: John Cai <johncai86@gmail.com> > > Using a buffer limited to 2048 is unnecessarily limiting. Switch to > using a string buffer to read in stdin for annotation. > > Signed-off-by: "John Cai" <johncai86@gmail.com> > --- > builtin/name-rev.c | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/builtin/name-rev.c b/builtin/name-rev.c > index 8baf5b52d0b..138e3c30a2b 100644 > --- a/builtin/name-rev.c > +++ b/builtin/name-rev.c > @@ -623,14 +623,13 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) > name_tips(); > > if (annotate_stdin) { > - char buffer[2048]; > + struct strbuf sb = STRBUF_INIT; > > - while (!feof(stdin)) { > - char *p = fgets(buffer, sizeof(buffer), stdin); > - if (!p) > - break; > - name_rev_line(p, &data); > + while (strbuf_getline(&sb, stdin) != EOF) { > + strbuf_addch(&sb, '\n'); > + name_rev_line(sb.buf, &data); > } > + strbuf_release(&sb); > } else if (all) { > int i, max; Maybe there's a subtlety with \r in newlines (Windows), but isn't this doing the same thing as: diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 138e3c30a2b..03dbf251450 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -625,10 +625,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) if (annotate_stdin) { struct strbuf sb = STRBUF_INIT; - while (strbuf_getline(&sb, stdin) != EOF) { - strbuf_addch(&sb, '\n'); + while (!strbuf_getwholeline(&sb, stdin, '\n')) name_rev_line(sb.buf, &data); - } strbuf_release(&sb); } else if (all) { int i, max; After writing that I see this was changed on the basis of Junio's feedback in https://lore.kernel.org/git/xmqqr19ofdo5.fsf@gitster.g/ :) FWIW I think it's fine as-is, but it also seems that name_rev_line() really doesn't care about lines per-se, but just that we don't split OIDs across "lines" (as we'll tokenize get_oid() on them). So e.g. splitting by ' ' lines (spaces) also works here, but not 'a' (as that would split a [0-9a-f]. ^ permalink raw reply related [flat|nested] 43+ messages in thread
end of thread, other threads:[~2022-01-18 16:17 UTC | newest] Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-12-26 4:28 [PATCH] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2021-12-27 19:49 ` Junio C Hamano 2021-12-28 5:13 ` John Cai 2021-12-31 8:16 ` Junio C Hamano 2022-01-01 22:59 ` Johannes Schindelin 2021-12-29 6:23 ` [PATCH v2 0/2] name-rev: deprecate --stdin in favor of --anotate-text John Cai via GitGitGadget 2021-12-29 6:23 ` [PATCH v2 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2021-12-30 22:36 ` Junio C Hamano 2021-12-29 6:23 ` [PATCH v2 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-03 14:47 ` [PATCH v3 1/2] name-rev: deprecate --stdin in favor of --annotate-text John Cai via GitGitGadget 2022-01-04 2:36 ` Junio C Hamano 2022-01-04 3:16 ` Junio C Hamano 2022-01-04 13:25 ` Philip Oakley 2022-01-04 19:00 ` Junio C Hamano 2022-01-04 19:38 ` Eric Sunshine 2022-01-03 14:47 ` [PATCH v3 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-04 2:16 ` Junio C Hamano 2022-01-04 14:49 ` [PATCH v4 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-04 14:49 ` [PATCH v4 1/2] " John Cai via GitGitGadget 2022-01-04 22:12 ` Junio C Hamano 2022-01-05 11:15 ` Phillip Wood 2022-01-05 19:47 ` Junio C Hamano 2022-01-05 19:52 ` Junio C Hamano 2022-01-04 14:49 ` [PATCH v4 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-04 14:54 ` John Cai 2022-01-05 4:20 ` [PATCH v5 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-05 4:20 ` [PATCH v5 1/2] " John Cai via GitGitGadget 2022-01-05 20:07 ` Junio C Hamano 2022-01-05 4:20 ` [PATCH v5 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-05 22:59 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin John Cai via GitGitGadget 2022-01-05 22:59 ` [PATCH v6 1/2] " John Cai via GitGitGadget 2022-01-05 23:00 ` [PATCH v6 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-05 23:12 ` [PATCH v6 0/2] name-rev: deprecate --stdin in favor of --annotate-stdin Junio C Hamano 2022-01-05 23:29 ` [PATCH v7 " John Cai via GitGitGadget 2022-01-05 23:29 ` [PATCH v7 1/2] " John Cai via GitGitGadget 2022-01-08 13:47 ` John Cai 2022-01-10 17:38 ` Junio C Hamano 2022-01-10 19:01 ` John Cai 2022-01-10 19:11 ` Junio C Hamano 2022-01-11 11:01 ` Phillip Wood 2022-01-05 23:29 ` [PATCH v7 2/2] name-rev.c: use strbuf_getline instead of limited size buffer John Cai via GitGitGadget 2022-01-18 16:09 ` Ævar Arnfjörð Bjarmason
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.