summaryrefslogtreecommitdiff
path: root/commit.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2009-07-23 15:33:49 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-07-24 16:10:16 (GMT)
commit7f3140cd23f126e578ccaaea8c2cebe36824a7ac (patch)
treed195e6f3e3002fdd55ef93ed10c087f22514cca3 /commit.c
parent1ec648278e3a3e5a04dfaac916f68e2f675ff9ea (diff)
downloadgit-7f3140cd23f126e578ccaaea8c2cebe36824a7ac.zip
git-7f3140cd23f126e578ccaaea8c2cebe36824a7ac.tar.gz
git-7f3140cd23f126e578ccaaea8c2cebe36824a7ac.tar.bz2
git repack: keep commits hidden by a graft
When you have grafts that pretend that a given commit has different parents than the ones recorded in the commit object, it is dangerous to let 'git repack' remove those hidden parents, as you can easily remove the graft and end up with a broken repository. So let's play it safe and keep those parent objects and everything that is reachable by them, in addition to the grafted parents. As this behavior can only be triggered by git pack-objects, and as that command handles duplicate parents gracefully, we do not bother to cull duplicated parents that may result by using both true and grafted parents. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/commit.c b/commit.c
index aa3b35b..f69525a 100644
--- a/commit.c
+++ b/commit.c
@@ -266,7 +266,11 @@ int parse_commit_buffer(struct commit *item, void *buffer, unsigned long size)
bufptr[47] != '\n')
return error("bad parents in commit %s", sha1_to_hex(item->object.sha1));
bufptr += 48;
- if (graft)
+ /*
+ * The clone is shallow if nr_parent < 0, and we must
+ * not traverse its real parents even when we unhide them.
+ */
+ if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
continue;
new_parent = lookup_commit(parent);
if (new_parent)