From 5da5c8f4cf4fb4e1cbccca4e7cebe70b77cf0b00 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 30 Jul 2005 00:58:28 -0700 Subject: Teach parse_commit_buffer about grafting. Introduce a new file $GIT_DIR/info/grafts (or $GIT_GRAFT_FILE) which is a list of "fake commit parent records". Each line of this file is a commit ID, followed by parent commit IDs, all 40-byte hex SHA1 separated by a single SP in between. The records override the parent information we would normally read from the commit objects, allowing both adding "fake" parents (i.e. grafting), and pretending as if a commit is not a child of some of its real parents (i.e. cauterizing). Signed-off-by: Junio C Hamano --- sha1_file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'sha1_file.c') diff --git a/sha1_file.c b/sha1_file.c index eba5a36f2..8d3a65f5f 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -61,7 +61,8 @@ 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, *git_refs_dir; +static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir, + *git_graft_file; static void setup_git_env(void) { git_dir = gitenv(GIT_DIR_ENVIRONMENT); @@ -79,6 +80,9 @@ static void setup_git_env(void) git_index_file = xmalloc(strlen(git_dir) + 7); sprintf(git_index_file, "%s/index", git_dir); } + git_graft_file = gitenv(GRAFT_ENVIRONMENT); + if (!git_graft_file) + git_graft_file = strdup(git_path("info/grafts")); } char *get_object_directory(void) @@ -102,6 +106,13 @@ char *get_index_file(void) return git_index_file; } +char *get_graft_file(void) +{ + if (!git_graft_file) + setup_git_env(); + return git_graft_file; +} + int safe_create_leading_directories(char *path) { char *pos = path; -- cgit v1.2.1