diff options
author | Daniel Barkalow <barkalow@iabervon.org> | 2005-06-06 16:31:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-06 17:09:45 -0700 |
commit | 95fc75129acf14d980bdd56b9b2ee74190f81d91 (patch) | |
tree | d3a6988ffe8b9ae0b554ddb4485ffb0f1cac0dc7 /sha1_file.c | |
parent | git-read-tree: some "final" cleanups (diff) | |
download | tgif-95fc75129acf14d980bdd56b9b2ee74190f81d91.tar.xz |
[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.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c index a2ba4c81db..7cfd43c51b 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) |