summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-07-30 07:58:28 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-07-31 18:58:49 (GMT)
commit5da5c8f4cf4fb4e1cbccca4e7cebe70b77cf0b00 (patch)
tree329b5863cdb047fec0633d13bebfdfeb19c21a69 /sha1_file.c
parent60036a41e1f25ee3e89142fa92e203dbbc6145cc (diff)
downloadgit-5da5c8f4cf4fb4e1cbccca4e7cebe70b77cf0b00.zip
git-5da5c8f4cf4fb4e1cbccca4e7cebe70b77cf0b00.tar.gz
git-5da5c8f4cf4fb4e1cbccca4e7cebe70b77cf0b00.tar.bz2
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>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index eba5a36..8d3a65f 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;