[GSoC RFC PATCH v2 4/7] repo-info: add the --allow-empty flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a flag --allow-empty, which will force the output data to be empty
when no field is requested.

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
 '
 
-- 
2.39.5 (Apple Git-154)





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux