From: John Cai via GitGitGadget <hidden> Date: 2021-12-26 04:28:36
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_text=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
From: John Cai via GitGitGadget <hidden> Date: 2021-12-29 06:23:45
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
From: John Cai via GitGitGadget <hidden> Date: 2021-12-29 06:23:47
From: John Cai <redacted>
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" <redacted>
---
Documentation/git-name-rev.txt | 29 ++++++++++++++++++++++++++++-
builtin/name-rev.c | 19 ++++++++++++++-----
2 files changed, 42 insertions(+), 6 deletions(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
From: John Cai via GitGitGadget <hidden> Date: 2021-12-29 06:23:50
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
From: Junio C Hamano <hidden> Date: 2021-12-30 22:36:53
"John Cai via GitGitGadget" [off-list ref] writes:
From: John Cai <redacted>
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.
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.
quoted hunk
@@ -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);
From: John Cai via GitGitGadget <hidden> Date: 2022-01-03 14:47:47
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
@@ -659,7 +659,7 @@ EOF test_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
From: John Cai via GitGitGadget <hidden> Date: 2022-01-03 14:47:49
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
From: Junio C Hamano <hidden> Date: 2022-01-04 02:16:49
"John Cai via GitGitGadget" [off-list ref] writes:
quoted hunk
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
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;
From: Junio C Hamano <hidden> Date: 2022-01-04 02:36:51
"John Cai via GitGitGadget" [off-list ref] 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.
From: Philip Oakley <hidden> Date: 2022-01-04 13:25:17
On 03/01/2022 14:47, John Cai via GitGitGadget wrote:
quoted hunk
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
quoted hunk
+
+ 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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
@@ -659,7 +659,7 @@ EOF test_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
From: John Cai via GitGitGadget <hidden> Date: 2022-01-04 14:49:40
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 [off-list ref]
## 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
From: John Cai via GitGitGadget <hidden> Date: 2022-01-04 14:49:43
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
@@ -659,7 +659,7 @@ EOF test_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
From: John Cai via GitGitGadget <hidden> Date: 2022-01-04 14:49:44
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
On Jan 4, 2022, at 9:49 AM, John Cai via GitGitGadget [off-list ref] wrote:
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
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
From: Eric Sunshine <hidden> Date: 2022-01-04 19:38:58
On Tue, Jan 4, 2022 at 10:32 AM Philip Oakley [off-list ref] wrote:
On 03/01/2022 14:47, John Cai via GitGitGadget wrote:
quoted
From: John Cai <redacted>
--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.
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 04:20:45
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
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 04:20:45
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 04:20:50
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
@@ -659,7 +659,7 @@ EOF test_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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)
quoted hunk
+ 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
quoted hunk
while (!feof(stdin)) {
char *p = fgets(buffer, sizeof(buffer), stdin);
@@ -659,7 +659,7 @@ EOFtest_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOFtest_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOFtest_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 23:00:11
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
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 23:00:14
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
@@ -659,7 +659,7 @@ EOF test_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 23:00:17
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 23:29:40
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
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 23:29:42
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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++){
@@ -659,7 +659,7 @@ EOF test_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
From: John Cai via GitGitGadget <hidden> Date: 2022-01-05 23:29:46
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
Hi Junio,
On 5 Jan 2022, at 18:29, John Cai via GitGitGadget wrote:
quoted hunk
From: John Cai <redacted>
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" <redacted>
---
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(-)
@@ -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
@@ -527,7 +527,7 @@ static void name_rev_line(char *p, struct name_ref_data *data)intcmd_name_rev(intargc,constchar**argv,constchar*prefix){structobject_arrayrevs=OBJECT_ARRAY_INIT;-intall=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;+intall=0,annotate_stdin=0,transform_stdin=0,allow_undefined=1,always=0,peel_tag=0;structname_ref_datadata={0,0,STRING_LIST_INIT_NODUP,STRING_LIST_INIT_NODUP};structoptionopts[]={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!
quoted hunk
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)) {
@@ -659,7 +659,7 @@ EOF test_expect_success'log --graph with full output''gitlog--graph--date-order--pretty=short|-gitname-rev--name-only--stdin|+gitname-rev--name-only--annotate-stdin|sed"s/Merge:.*/Merge: A B/;s/ *\$//">actual&&test_cmpexpectactual'
@@ -78,14 +78,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty''gitrev-list--left-right--cherry-pickB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'bar does not come up empty''gitrev-list--left-rightB...C--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named'
@@ -97,14 +97,14 @@ EOF test_expect_success'--cherry-pick bar does not come up empty (II)''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/*"\+gitname-rev--annotate-stdin--name-only--refs="*tags/*"\<actual>actual.named&&test_cmpexpectactual.named' test_expect_success'name-rev multiple --refs combine inclusive''gitrev-list--left-right--cherry-pickF...E--bar>actual&&-gitname-rev--stdin--name-only--refs="*tags/F"--refs="*tags/E"\+gitname-rev--annotate-stdin--name-only--refs="*tags/F"--refs="*tags/E"\<actual>actual.named&&test_cmpexpectactual.named'
On Wed, Jan 05 2022, John Cai via GitGitGadget wrote:
quoted hunk
From: John Cai <redacted>
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" <redacted>
---
builtin/name-rev.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
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].