summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven Verdoolaege <skimo@kotnet.org>2005-09-26 20:54:01 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-09-27 07:16:39 (GMT)
commit5da1606d0bf5b970fadfa0ca91618a1e871f6755 (patch)
tree559dd6786b16a653f9e2544f4b4ab627da6a6702
parentedde7a8b5324d88f07fcb8204da313c19b4988fa (diff)
downloadgit-5da1606d0bf5b970fadfa0ca91618a1e871f6755.zip
git-5da1606d0bf5b970fadfa0ca91618a1e871f6755.tar.gz
git-5da1606d0bf5b970fadfa0ca91618a1e871f6755.tar.bz2
[PATCH] Provide access to git_dir through get_git_dir().
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
-rw-r--r--cache.h1
-rw-r--r--fsck-objects.c5
-rw-r--r--path.c4
-rw-r--r--sha1_file.c7
4 files changed, 10 insertions, 7 deletions
diff --git a/cache.h b/cache.h
index 6f3d39d..52a45f9 100644
--- a/cache.h
+++ b/cache.h
@@ -136,6 +136,7 @@ extern unsigned int active_nr, active_alloc, active_cache_changed;
#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
+extern char *get_git_dir(void);
extern char *get_object_directory(void);
extern char *get_refs_directory(void);
extern char *get_index_file(void);
diff --git a/fsck-objects.c b/fsck-objects.c
index 6cb0f29..b82685f 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -406,10 +406,7 @@ static int fsck_head_link(void)
char hex[40];
unsigned char sha1[20];
static char path[PATH_MAX], link[PATH_MAX];
- const char *git_dir;
-
- git_dir = getenv(GIT_DIR_ENVIRONMENT);
- if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
+ const char *git_dir = get_git_dir();
snprintf(path, sizeof(path), "%s/HEAD", git_dir);
if (readlink(path, link, sizeof(link)) < 0)
diff --git a/path.c b/path.c
index f788028..495d17c 100644
--- a/path.c
+++ b/path.c
@@ -41,12 +41,10 @@ char *mkpath(const char *fmt, ...)
char *git_path(const char *fmt, ...)
{
- const char *git_dir;
+ const char *git_dir = get_git_dir();
va_list args;
unsigned len;
- git_dir = getenv(GIT_DIR_ENVIRONMENT);
- if (!git_dir) git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
len = strlen(git_dir);
if (len > PATH_MAX-100)
return bad_path;
diff --git a/sha1_file.c b/sha1_file.c
index 6638202..fe374c6 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -70,6 +70,13 @@ static void setup_git_env(void)
git_graft_file = strdup(git_path("info/grafts"));
}
+char *get_git_dir(void)
+{
+ if (!git_dir)
+ setup_git_env();
+ return git_dir;
+}
+
char *get_object_directory(void)
{
if (!git_object_dir)