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

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

 



--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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]