Thread (23 messages) 23 messages, 3 authors, 2016-06-15

[WIP PATCH 01/18] rev-parse: add --internal-cwd and --internal-git-dir for tests

flat view
DORMANTno replies

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:49:52
Subsystem: the rest · Maintainer: Linus Torvalds

--internal-cwd is obvious, no way else to expose it for testing.

--internal-git-dir is introduced because --git-dir prepares its output
suitable for scripting. For tests, it must be exactly what git stores.
---
 builtin/rev-parse.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index a5a1c86..454a25c 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -642,6 +642,17 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 				putchar('\n');
 				continue;
 			}
+			if (!strcmp(arg, "--internal-cwd")) {
+				static char cwd[PATH_MAX];
+				if (!getcwd(cwd, PATH_MAX))
+					die_errno("unable to get current working directory");
+				puts(cwd);
+				continue;
+			}
+			if (!strcmp(arg, "--internal-git-dir")) {
+				puts(get_git_dir());
+				continue;
+			}
 			if (!strcmp(arg, "--git-dir")) {
 				const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
 				static char cwd[PATH_MAX];
-- 
1.7.0.2.445.gcbdb3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help