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 v2 5/6] setup.c: record the location of .git file
Date: Mon, 18 Jan 2016 18:21:33 +0700 [thread overview]
Message-ID: <1453116094-4987-6-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1453116094-4987-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
cache.h | 1 +
setup.c | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/cache.h b/cache.h
index fbe29ac..c912afb 100644
--- a/cache.h
+++ b/cache.h
@@ -1728,6 +1728,7 @@ const char *split_cmdline_strerror(int cmdline_errno);
struct startup_info {
int have_repository;
const char *prefix;
+ const char *first_gitfile;
};
extern struct startup_info *startup_info;
diff --git a/setup.c b/setup.c
index 8b02429..0489f54 100644
--- a/setup.c
+++ b/setup.c
@@ -550,6 +550,8 @@ static const char *setup_explicit_git_dir(const char *gitdirenv,
gitfile = (char*)read_gitfile(gitdirenv);
if (gitfile) {
gitfile = xstrdup(gitfile);
+ if (startup_info && !startup_info->first_gitfile)
+ startup_info->first_gitfile = real_path_dup(gitdirenv);
gitdirenv = gitfile;
}
@@ -834,9 +836,12 @@ static const char *setup_git_directory_gently_1(int *nongit_ok)
current_device = get_device_or_die(".", NULL, 0);
for (;;) {
gitfile = (char*)read_gitfile(DEFAULT_GIT_DIR_ENVIRONMENT);
- if (gitfile)
+ if (gitfile) {
gitdirenv = gitfile = xstrdup(gitfile);
- else {
+ if (startup_info && !startup_info->first_gitfile)
+ startup_info->first_gitfile =
+ real_path_dup(DEFAULT_GIT_DIR_ENVIRONMENT);
+ } else {
if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
gitdirenv = DEFAULT_GIT_DIR_ENVIRONMENT;
}
@@ -885,6 +890,9 @@ const char *setup_git_directory_gently(int *nongit_ok)
{
const char *prefix;
+ if (startup_info)
+ startup_info->first_gitfile = NULL;
+
prefix = setup_git_directory_gently_1(nongit_ok);
if (prefix)
setenv(GIT_PREFIX_ENVIRONMENT, prefix, 1);
--
2.7.0.96.g5373197
next prev parent reply other threads:[~2016-01-18 11:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-18 11:21 [PATCH v2 0/6] Kill and replace update_linked_gitdir() Nguyễn Thái Ngọc Duy
2016-01-18 11:21 ` [PATCH v2 1/6] worktree.c: fix indentation Nguyễn Thái Ngọc Duy
2016-01-18 11:21 ` [PATCH v2 2/6] worktree: stop supporting moving worktrees manually Nguyễn Thái Ngọc Duy
2016-01-18 18:24 ` Eric Sunshine
2016-01-18 11:21 ` [PATCH v2 3/6] worktree.txt: how to fix up after moving a worktree Nguyễn Thái Ngọc Duy
2016-01-18 18:30 ` Eric Sunshine
2016-01-19 5:20 ` Duy Nguyen
2016-01-18 11:21 ` [PATCH v2 4/6] abspath.c: add and use real_path_dup() Nguyễn Thái Ngọc Duy
2016-01-18 11:21 ` Nguyễn Thái Ngọc Duy [this message]
2016-01-18 11:21 ` [PATCH v2 6/6] worktree: new command to fix up worktree's info after moving Nguyễn Thái Ngọc Duy
2016-01-18 13:07 ` Philip Oakley
2016-01-19 18:25 ` Junio C Hamano
2016-01-22 8:35 ` [PATCH v3 0/2] Kill and replace update_linked_gitdir() Nguyễn Thái Ngọc Duy
2016-01-22 8:35 ` [PATCH v3 1/2] worktree.c: fix indentation Nguyễn Thái Ngọc Duy
2016-01-22 8:35 ` [PATCH v3 2/2] worktree: stop supporting moving worktrees manually 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=1453116094-4987-6-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.