git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 1/7] setup: support setting GIT_DIR=.git file
Date: Wed, 27 Oct 2010 21:58:10 +0700	[thread overview]
Message-ID: <1288191496-31176-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1288190977-30875-1-git-send-email-pclouds@gmail.com>

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

  parent reply	other threads:[~2010-10-27 14:58 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27 14:49 [PATCH 00/34] repo setup test cases Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 01/34] builtins: print setup info if repo is found Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 02/34] Add t1510 and basic rules that run repo setup Nguyễn Thái Ngọc Duy
2010-10-27 15:37   ` Nguyen Thai Ngoc Duy
2010-10-27 16:30     ` Jonathan Nieder
2010-10-28  0:16       ` Nguyen Thai Ngoc Duy
2010-10-27 14:49 ` [PATCH 03/34] t1510: setup case #0 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 04/34] t1510: setup case #1 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 05/34] t1510: setup case #2 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 06/34] t1510: setup case #3 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 07/34] t1510: setup case #4 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 08/34] t1510: setup case #5 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 09/34] t1510: setup case #6 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 10/34] t1510: setup case #7 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 11/34] t1510: setup case #8 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 12/34] t1510: setup case #9 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 13/34] t1510: setup case #10 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 14/34] t1510: setup case #11 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 15/34] t1510: setup case #12 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 16/34] t1510: setup case #13 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 17/34] t1510: setup case #14 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 18/34] t1510: setup case #15 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 19/34] t1510: setup case #16 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 20/34] t1510: setup case #17 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 21/34] t1510: setup case #18 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 22/34] t1510: setup case #19 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 23/34] t1510: setup case #20 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 24/34] t1510: setup case #21 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 25/34] t1510: setup case #22 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 26/34] t1510: setup case #23 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 27/34] t1510: setup case #24 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 28/34] t1510: setup case #25 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 29/34] t1510: setup case #26 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 30/34] t1510: setup case #27 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 31/34] t1510: setup case #28 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 32/34] t1510: setup case #29 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 33/34] t1510: setup case #30 Nguyễn Thái Ngọc Duy
2010-10-27 14:49 ` [PATCH 34/34] t1510: setup case #31 Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` Nguyễn Thái Ngọc Duy [this message]
2010-10-27 14:58 ` [PATCH 2/7] unset: discard GIT_WORK_TREE if GIT_DIR is not set Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 3/7] setup: do not allow core.{bare,worktree} set at the same time Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 4/7] setup: skip core.worktree if GIT_DIR is not set Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 5/7] setup: rework core.worktree Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 6/7] get_git_work_tree: core.worktree relative to git_dir Nguyễn Thái Ngọc Duy
2010-10-27 14:58 ` [PATCH 7/7] new failures Nguyễn Thái Ngọc Duy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288191496-31176-1-git-send-email-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).