Lucas Seiki Oshiro <lucasseikioshiro@xxxxxxxxx> writes: > Add a flag --allow-empty, which will force the output data to be empty > when no field is requested. I still think we should flip the polarity of the option and give "--all" to iterate over all variables, and by default show nothing. > Mentored-by: Karthik Nayak <karthik.188@xxxxxxxxx> > Mentored-by Patrick Steinhardt <ps@xxxxxx> > Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@xxxxxxxxx> > --- > builtin/repo-info.c | 3 +++ > t/t1900-repo-info.sh | 5 +++-- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/builtin/repo-info.c b/builtin/repo-info.c > index cd7c110f47..6499be0eae 100644 > --- a/builtin/repo-info.c > +++ b/builtin/repo-info.c > @@ -68,9 +68,12 @@ int cmd_repo_info(int argc, > }; > struct repo_info repo_info; > char *format = NULL; > + int allow_empty = 0; > struct option options[] = { > OPT_STRING(0, "format", &format, N_("format"), > N_("output format")), > + OPT_BOOL(0, "allow-empty", &allow_empty, > + "when set, it will use an empty set of fields if no field is requested"), > OPT_END() > }; > > diff --git a/t/t1900-repo-info.sh b/t/t1900-repo-info.sh > index 998c835795..db4a6aad17 100755 > --- a/t/t1900-repo-info.sh > +++ b/t/t1900-repo-info.sh > @@ -15,11 +15,12 @@ test_lazy_prereq PERLJSON ' > ' > > test_expect_success PERLJSON 'json: returns empty output with allow-empty' ' > - git repo-info --format=json >output && > + git repo-info --allow-empty --format=json >output && > test_line_count = 2 output > ' > + > test_expect_success 'plaintext: returns empty output with allow-empty' ' > - git repo-info --format=plaintext >output && > + git repo-info --allow-empty --format=plaintext >output && > test_line_count = 0 output > '