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 <junkio@cox.net>
This commit is contained in:
Junio C Hamano
2005-07-30 00:58:28 -07:00
parent 60036a41e1
commit 5da5c8f4cf
3 changed files with 127 additions and 2 deletions

View File

@ -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;