-
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.
refs_from_alternate: helper to use refs from alternates
The receiving end of "git push" advertises the objects that the repository itself does not use, but are at the tips of refs in other repositories whose object databases are used as alternates for it. This helps it avoid having to receive (and the pusher having to send) objects that are already available to the receiving repository via the alternates mechanism. Tweak the helper function that implements this feature, and move it to transport.[ch] for future reuse by other programs. The additional test demonstrates how this optimization is helping "git push", and "git fetch" is ignorant about it. Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Shawn O. Pearce <spearce@spearce.org>
- Loading branch information
Junio C Hamano
committed
Mar 17, 2011
1 parent
ea2c69e
commit 36cfda1
Showing
4 changed files
with
106 additions
and
32 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,66 @@ | ||
#!/bin/sh | ||
|
||
test_description='fetch/push involving alternates' | ||
. ./test-lib.sh | ||
|
||
count_objects () { | ||
loose=0 inpack=0 | ||
eval "$( | ||
git count-objects -v | | ||
sed -n -e 's/^count: \(.*\)/loose=\1/p' \ | ||
-e 's/^in-pack: \(.*\)/inpack=\1/p' | ||
)" && | ||
echo $(( $loose + $inpack )) | ||
} | ||
|
||
|
||
test_expect_success setup ' | ||
( | ||
git init original && | ||
cd original && | ||
i=0 && | ||
while test $i -le 100 | ||
do | ||
echo "$i" >count && | ||
git add count && | ||
git commit -m "$i" || exit | ||
i=$(($i + 1)) | ||
done | ||
) && | ||
( | ||
git clone --reference=original "file:///$(pwd)/original" one && | ||
cd one && | ||
echo Z >count && | ||
git add count && | ||
git commit -m Z && | ||
count_objects >../one.count | ||
) && | ||
A=$(pwd)/original/.git/objects && | ||
git init receiver && | ||
echo "$A" >receiver/.git/objects/info/alternates && | ||
git init fetcher && | ||
echo "$A" >fetcher/.git/objects/info/alternates | ||
' | ||
|
||
test_expect_success 'pushing into a repository with the same alternate' ' | ||
( | ||
cd one && | ||
git push ../receiver master:refs/heads/it | ||
) && | ||
( | ||
cd receiver && | ||
count_objects >../receiver.count | ||
) && | ||
test_cmp one.count receiver.count | ||
' | ||
|
||
test_expect_failure 'fetching from a repository with the same alternate' ' | ||
( | ||
cd fetcher && | ||
git fetch ../one master:refs/heads/it && | ||
count_objects >../fetcher.count | ||
) && | ||
test_cmp one.count fetcher.count | ||
' | ||
|
||
test_done |
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