[PATCH 1/7] setup: support setting GIT_DIR=.git file

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

 



---
 setup.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/setup.c b/setup.c
index a3b76de..2e7387d 100644
--- a/setup.c
+++ b/setup.c
@@ -317,17 +317,20 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
 				const char *work_tree_env, int *nongit_ok)
 {
 	static char buffer[1024 + 1];
-	const char *retval;
+	const char *retval, *gitfile;
 
 	if (PATH_MAX - 40 < strlen(gitdirenv))
 		die("'$%s' too big", GIT_DIR_ENVIRONMENT);
-	if (!is_git_directory(gitdirenv)) {
+	gitfile = read_gitfile_gently(gitdirenv);
+	if (!gitfile && !is_git_directory(gitdirenv)) {
 		if (nongit_ok) {
 			*nongit_ok = 1;
 			return NULL;
 		}
 		die("Not a git repository: '%s'", gitdirenv);
 	}
+	if (gitfile)
+		set_git_dir(gitfile);
 	if (!work_tree_env) {
 		retval = set_work_tree(gitdirenv);
 		/* config may override worktree */
@@ -341,7 +344,8 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
 			get_git_work_tree());
 	if (!retval || !*retval)
 		return NULL;
-	set_git_dir(make_absolute_path(gitdirenv));
+	if (!gitfile)
+		set_git_dir(make_absolute_path(gitdirenv));
 	if (chdir(work_tree_env) < 0)
 		die_errno ("Could not chdir to '%s'", work_tree_env);
 	strcat(buffer, "/");
-- 
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]