summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorDaniel Barkalow <barkalow@iabervon.org>2005-06-06 20:31:29 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-07 00:09:45 (GMT)
commit95fc75129acf14d980bdd56b9b2ee74190f81d91 (patch)
treed3a6988ffe8b9ae0b554ddb4485ffb0f1cac0dc7 /sha1_file.c
parent451322512f2f72fe07461a8aeae0df4cfce7fda1 (diff)
downloadgit-95fc75129acf14d980bdd56b9b2ee74190f81d91.zip
git-95fc75129acf14d980bdd56b9b2ee74190f81d91.tar.gz
git-95fc75129acf14d980bdd56b9b2ee74190f81d91.tar.bz2
[PATCH] Operations on refs
This patch adds code to read a hash out of a specified file under {GIT_DIR}/refs/, and to write such files atomically and optionally with an compare and lock. Signed-off-by: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index a2ba4c8..7cfd43c 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -58,7 +58,7 @@ static int get_sha1_file(const char *path, unsigned char *result)
return get_sha1_hex(buffer, result);
}
-static char *git_dir, *git_object_dir, *git_index_file;
+static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir;
static void setup_git_env(void)
{
git_dir = gitenv(GIT_DIR_ENVIRONMENT);
@@ -69,6 +69,8 @@ static void setup_git_env(void)
git_object_dir = xmalloc(strlen(git_dir) + 9);
sprintf(git_object_dir, "%s/objects", git_dir);
}
+ git_refs_dir = xmalloc(strlen(git_dir) + 6);
+ sprintf(git_refs_dir, "%s/refs", git_dir);
git_index_file = gitenv(INDEX_ENVIRONMENT);
if (!git_index_file) {
git_index_file = xmalloc(strlen(git_dir) + 7);
@@ -83,6 +85,13 @@ char *get_object_directory(void)
return git_object_dir;
}
+char *get_refs_directory(void)
+{
+ if (!git_refs_dir)
+ setup_git_env();
+ return git_refs_dir;
+}
+
char *get_index_file(void)
{
if (!git_index_file)