Thread (6 messages) flat view 6 messages, 3 authors, 2016-06-15

Re: [PATCH v2 1/2] rev-parse: add option --is-well-formed-git-dir [path]

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:51:47

Fredrik Gustafsson [off-list ref] writes:
quoted hunk ↗ jump to hunk
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 4c19f84..82342b3 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -455,6 +455,14 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 	unsigned char sha1[20];
 	const char *name = NULL;
 
+	if (argc > 2 && !strcmp(argv[1], "--is-well-formed-git-dir")) {
+		const char *gitdir = resolve_gitdir(argv[2]);
+		if(!gitdir)
(style) SP immediately after "if".
+			die("not a gitdir");
die("not a gitdir '%s'", argv[2]) perhaps?
+		puts(gitdir);
+		return 0;
+	}
+
 	if (argc > 1 && !strcmp("--parseopt", argv[1]))
 		return cmd_parseopt(argc - 1, argv + 1, prefix);
When adding a new element to existing list of other similar things, I
would prefer to see it added at the end (in this case, just before "-h",
which is kind of special), unless there is a good justification not to
(e.g. the list is sorted alphabetically).
quoted hunk ↗ jump to hunk
diff --git a/setup.c b/setup.c
index 5ea5502..15bc305 100644
--- a/setup.c
+++ b/setup.c
@@ -808,3 +808,10 @@ const char *setup_git_directory(void)
 {
 	return setup_git_directory_gently(NULL);
 }
+
+const char *resolve_gitdir(const char *suspect)
+{
+	if(is_git_directory(suspect))
(style) SP immediately after "if".
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help