-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pack-objects: Allow missing base objects when creating thin packs
If we are building a thin pack and one of the base objects we would consider for deltification is missing its OK, the other side already has that base object. We may be able to get a delta from another object, or we can simply send the new object whole (no delta). This change allows a shallow clone to store only the objects which are unique to it, as well as the boundary commit and its trees, but avoids storing the boundary blobs. This special form of a shallow clone is able to represent just the difference between two trees. Pack objects change suggested by Nicolas Pitre. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Acked-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Shawn O. Pearce
authored and
Junio C Hamano
committed
Aug 12, 2008
1 parent
04c6e9e
commit 6d6f9cd
Showing
2 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright (c) 2008 Google Inc. | ||
# | ||
|
||
test_description='git-pack-object with missing base | ||
' | ||
. ./test-lib.sh | ||
|
||
# Create A-B chain | ||
# | ||
test_expect_success \ | ||
'setup base' \ | ||
'for a in a b c d e f g h i; do echo $a >>text; done && | ||
echo side >side && | ||
git update-index --add text side && | ||
A=$(echo A | git commit-tree $(git write-tree)) && | ||
echo m >>text && | ||
git update-index text && | ||
B=$(echo B | git commit-tree $(git write-tree) -p $A) && | ||
git update-ref HEAD $B | ||
' | ||
|
||
# Create repository with C whose parent is B. | ||
# Repository contains C, C^{tree}, C:text, B, B^{tree}. | ||
# Repository is missing B:text (best delta base for C:text). | ||
# Repository is missing A (parent of B). | ||
# Repository is missing A:side. | ||
# | ||
test_expect_success \ | ||
'setup patch_clone' \ | ||
'base_objects=$(pwd)/.git/objects && | ||
(mkdir patch_clone && | ||
cd patch_clone && | ||
git init && | ||
echo "$base_objects" >.git/objects/info/alternates && | ||
echo q >>text && | ||
git read-tree $B && | ||
git update-index text && | ||
git update-ref HEAD $(echo C | git commit-tree $(git write-tree) -p $B) && | ||
rm .git/objects/info/alternates && | ||
git --git-dir=../.git cat-file commit $B | | ||
git hash-object -t commit -w --stdin && | ||
git --git-dir=../.git cat-file tree "$B^{tree}" | | ||
git hash-object -t tree -w --stdin | ||
) && | ||
C=$(git --git-dir=patch_clone/.git rev-parse HEAD) | ||
' | ||
|
||
# Clone patch_clone indirectly by cloning base and fetching. | ||
# | ||
test_expect_success \ | ||
'indirectly clone patch_clone' \ | ||
'(mkdir user_clone && | ||
cd user_clone && | ||
git init && | ||
git pull ../.git && | ||
test $(git rev-parse HEAD) = $B && | ||
git pull ../patch_clone/.git && | ||
test $(git rev-parse HEAD) = $C | ||
) | ||
' | ||
|
||
# Cloning the patch_clone directly should fail. | ||
# | ||
test_expect_success \ | ||
'clone of patch_clone is incomplete' \ | ||
'(mkdir user_direct && | ||
cd user_direct && | ||
git init && | ||
test_must_fail git fetch ../patch_clone/.git | ||
) | ||
' | ||
|
||
test_done |