From: pclouds@gmail.com
To: git@vger.kernel.org, judge.packham@gmail.co
Cc: Jens.Lehmann@web.de, "Junio C Hamano" <gitster@pobox.com>,
jrnieder@gmail.com, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 1/2] setup.c: add enter_work_tree()
Date: Thu, 7 Oct 2010 11:46:52 +0700 [thread overview]
Message-ID: <4cad50cc.0626730a.5616.673d@mx.google.com> (raw)
In-Reply-To: <y>
From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
This function, apart from chdir() to worktree topdir, also invalidates
inside_work_tree so is_inside_work_tree() should reflect the new
situation correctly.
This function may be used when cwd is outside worktree and the running
command supports this case.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
To be used by builtin/grep.c when cwd is outside worktree.
More explanation in the next patch.
cache.h | 1 +
setup.c | 7 +++++++
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/cache.h b/cache.h
index 2ef2fa3..e71db23 100644
--- a/cache.h
+++ b/cache.h
@@ -414,6 +414,7 @@ extern int set_git_dir(const char *path);
extern const char *get_git_work_tree(void);
extern const char *read_gitfile_gently(const char *path);
extern void set_git_work_tree(const char *tree);
+extern void enter_work_tree();
#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
diff --git a/setup.c b/setup.c
index a3b76de..3fbe928 100644
--- a/setup.c
+++ b/setup.c
@@ -208,6 +208,13 @@ int is_inside_work_tree(void)
return inside_work_tree;
}
+void enter_work_tree(void)
+{
+ if (chdir(get_git_work_tree()))
+ die("Could not chdir to %s", get_git_work_tree());
+ inside_work_tree = -1;
+}
+
/*
* set_work_tree() is only ever called if you set GIT_DIR explicitly.
* The old behaviour (which we retain here) is to set the work tree root
--
1.7.1.rc1.70.g788ca
reply other threads:[~2010-10-07 4:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4cad50cc.0626730a.5616.673d@mx.google.com \
--to=pclouds@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.com \
--cc=judge.packham@gmail.co \
/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.