2006-09-23 12:40:17 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright (c) 2006, Junio C Hamano.
|
|
|
|
|
|
|
|
test_description='Per branch config variables affects "git fetch".
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
D=`pwd`
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
echo >file original &&
|
|
|
|
git add file &&
|
|
|
|
git commit -a -m original'
|
|
|
|
|
|
|
|
test_expect_success "clone and setup child repos" '
|
|
|
|
git clone . one &&
|
|
|
|
cd one &&
|
|
|
|
echo >file updated by one &&
|
|
|
|
git commit -a -m "updated by one" &&
|
|
|
|
cd .. &&
|
|
|
|
git clone . two &&
|
|
|
|
cd two &&
|
2007-01-29 01:16:53 +01:00
|
|
|
git config branch.master.remote one &&
|
|
|
|
git config remote.one.url ../one/.git/ &&
|
|
|
|
git config remote.one.fetch refs/heads/master:refs/heads/one &&
|
2006-09-23 22:55:35 +02:00
|
|
|
cd .. &&
|
|
|
|
git clone . three &&
|
|
|
|
cd three &&
|
2007-01-29 01:16:53 +01:00
|
|
|
git config branch.master.remote two &&
|
|
|
|
git config branch.master.merge refs/heads/one &&
|
2006-12-19 10:50:37 +01:00
|
|
|
mkdir -p .git/remotes &&
|
2006-09-23 22:55:35 +02:00
|
|
|
{
|
|
|
|
echo "URL: ../two/.git/"
|
|
|
|
echo "Pull: refs/heads/master:refs/heads/two"
|
|
|
|
echo "Pull: refs/heads/one:refs/heads/one"
|
Add git-bundle: move objects and references by archive
Some workflows require use of repositories on machines that cannot be
connected, preventing use of git-fetch / git-push to transport objects and
references between the repositories.
git-bundle provides an alternate transport mechanism, effectively allowing
git-fetch and git-pull to operate using sneakernet transport. `git-bundle
create` allows the user to create a bundle containing one or more branches
or tags, but with specified basis assumed to exist on the target
repository. At the receiving end, git-bundle acts like git-fetch-pack,
allowing the user to invoke git-fetch or git-pull using the bundle file as
the URL. git-fetch and git-ls-remote determine they have a bundle URL by
checking that the URL points to a file, but are otherwise unchanged in
operation with bundles.
The original patch was done by Mark Levedahl <mdl123@verizon.net>.
It was updated to make git-bundle a builtin, and get rid of the tar
format: now, the first line is supposed to say "# v2 git bundle", the next
lines either contain a prerequisite ("-" followed by the hash of the
needed commit), or a ref (the hash of a commit, followed by the name of
the ref), and finally the pack. As a result, the bundle argument can be
"-" now.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-22 01:59:14 +01:00
|
|
|
} >.git/remotes/two &&
|
|
|
|
cd .. &&
|
|
|
|
git clone . bundle
|
2006-09-23 12:40:17 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "fetch test" '
|
|
|
|
cd "$D" &&
|
|
|
|
echo >file updated by origin &&
|
|
|
|
git commit -a -m "updated by origin" &&
|
|
|
|
cd two &&
|
|
|
|
git fetch &&
|
|
|
|
test -f .git/refs/heads/one &&
|
|
|
|
mine=`git rev-parse refs/heads/one` &&
|
|
|
|
his=`cd ../one && git rev-parse refs/heads/master` &&
|
|
|
|
test "z$mine" = "z$his"
|
|
|
|
'
|
|
|
|
|
2006-09-23 22:55:35 +02:00
|
|
|
test_expect_success "fetch test for-merge" '
|
|
|
|
cd "$D" &&
|
|
|
|
cd three &&
|
|
|
|
git fetch &&
|
|
|
|
test -f .git/refs/heads/two &&
|
|
|
|
test -f .git/refs/heads/one &&
|
|
|
|
master_in_two=`cd ../two && git rev-parse master` &&
|
|
|
|
one_in_two=`cd ../two && git rev-parse one` &&
|
|
|
|
{
|
|
|
|
echo "$master_in_two not-for-merge"
|
|
|
|
echo "$one_in_two "
|
|
|
|
} >expected &&
|
|
|
|
cut -f -2 .git/FETCH_HEAD >actual &&
|
|
|
|
diff expected actual'
|
|
|
|
|
2006-11-19 06:39:17 +01:00
|
|
|
test_expect_success 'fetch following tags' '
|
|
|
|
|
|
|
|
cd "$D" &&
|
|
|
|
git tag -a -m 'annotated' anno HEAD &&
|
|
|
|
git tag light HEAD &&
|
|
|
|
|
|
|
|
mkdir four &&
|
|
|
|
cd four &&
|
2007-01-12 22:01:46 +01:00
|
|
|
git init &&
|
2006-11-19 06:39:17 +01:00
|
|
|
|
|
|
|
git fetch .. :track &&
|
|
|
|
git show-ref --verify refs/tags/anno &&
|
|
|
|
git show-ref --verify refs/tags/light
|
|
|
|
|
|
|
|
'
|
|
|
|
|
Add git-bundle: move objects and references by archive
Some workflows require use of repositories on machines that cannot be
connected, preventing use of git-fetch / git-push to transport objects and
references between the repositories.
git-bundle provides an alternate transport mechanism, effectively allowing
git-fetch and git-pull to operate using sneakernet transport. `git-bundle
create` allows the user to create a bundle containing one or more branches
or tags, but with specified basis assumed to exist on the target
repository. At the receiving end, git-bundle acts like git-fetch-pack,
allowing the user to invoke git-fetch or git-pull using the bundle file as
the URL. git-fetch and git-ls-remote determine they have a bundle URL by
checking that the URL points to a file, but are otherwise unchanged in
operation with bundles.
The original patch was done by Mark Levedahl <mdl123@verizon.net>.
It was updated to make git-bundle a builtin, and get rid of the tar
format: now, the first line is supposed to say "# v2 git bundle", the next
lines either contain a prerequisite ("-" followed by the hash of the
needed commit), or a ref (the hash of a commit, followed by the name of
the ref), and finally the pack. As a result, the bundle argument can be
"-" now.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-22 01:59:14 +01:00
|
|
|
test_expect_success 'create bundle 1' '
|
|
|
|
cd "$D" &&
|
|
|
|
echo >file updated again by origin &&
|
|
|
|
git commit -a -m "tip" &&
|
|
|
|
git bundle create bundle1 master^..master
|
|
|
|
'
|
|
|
|
|
2007-03-06 22:57:07 +01:00
|
|
|
test_expect_success 'header of bundle looks right' '
|
|
|
|
head -n 1 "$D"/bundle1 | grep "^#" &&
|
|
|
|
head -n 2 "$D"/bundle1 | grep "^-[0-9a-f]\{40\} " &&
|
|
|
|
head -n 3 "$D"/bundle1 | grep "^[0-9a-f]\{40\} " &&
|
|
|
|
head -n 4 "$D"/bundle1 | grep "^$"
|
|
|
|
'
|
|
|
|
|
Add git-bundle: move objects and references by archive
Some workflows require use of repositories on machines that cannot be
connected, preventing use of git-fetch / git-push to transport objects and
references between the repositories.
git-bundle provides an alternate transport mechanism, effectively allowing
git-fetch and git-pull to operate using sneakernet transport. `git-bundle
create` allows the user to create a bundle containing one or more branches
or tags, but with specified basis assumed to exist on the target
repository. At the receiving end, git-bundle acts like git-fetch-pack,
allowing the user to invoke git-fetch or git-pull using the bundle file as
the URL. git-fetch and git-ls-remote determine they have a bundle URL by
checking that the URL points to a file, but are otherwise unchanged in
operation with bundles.
The original patch was done by Mark Levedahl <mdl123@verizon.net>.
It was updated to make git-bundle a builtin, and get rid of the tar
format: now, the first line is supposed to say "# v2 git bundle", the next
lines either contain a prerequisite ("-" followed by the hash of the
needed commit), or a ref (the hash of a commit, followed by the name of
the ref), and finally the pack. As a result, the bundle argument can be
"-" now.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-22 01:59:14 +01:00
|
|
|
test_expect_success 'create bundle 2' '
|
|
|
|
cd "$D" &&
|
|
|
|
git bundle create bundle2 master~2..master
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_failure 'unbundle 1' '
|
|
|
|
cd "$D/bundle" &&
|
|
|
|
git checkout -b some-branch &&
|
|
|
|
git fetch "$D/bundle1" master:master
|
|
|
|
'
|
|
|
|
|
2007-03-06 22:57:07 +01:00
|
|
|
test_expect_success 'bundle 1 has only 3 files ' '
|
|
|
|
cd "$D" &&
|
|
|
|
(
|
|
|
|
while read x && test -n "$x"
|
|
|
|
do
|
|
|
|
:;
|
|
|
|
done
|
|
|
|
cat
|
|
|
|
) <bundle1 >bundle.pack &&
|
|
|
|
git index-pack bundle.pack &&
|
|
|
|
verify=$(git verify-pack -v bundle.pack) &&
|
|
|
|
test 4 = $(echo "$verify" | wc -l)
|
|
|
|
'
|
|
|
|
|
Add git-bundle: move objects and references by archive
Some workflows require use of repositories on machines that cannot be
connected, preventing use of git-fetch / git-push to transport objects and
references between the repositories.
git-bundle provides an alternate transport mechanism, effectively allowing
git-fetch and git-pull to operate using sneakernet transport. `git-bundle
create` allows the user to create a bundle containing one or more branches
or tags, but with specified basis assumed to exist on the target
repository. At the receiving end, git-bundle acts like git-fetch-pack,
allowing the user to invoke git-fetch or git-pull using the bundle file as
the URL. git-fetch and git-ls-remote determine they have a bundle URL by
checking that the URL points to a file, but are otherwise unchanged in
operation with bundles.
The original patch was done by Mark Levedahl <mdl123@verizon.net>.
It was updated to make git-bundle a builtin, and get rid of the tar
format: now, the first line is supposed to say "# v2 git bundle", the next
lines either contain a prerequisite ("-" followed by the hash of the
needed commit), or a ref (the hash of a commit, followed by the name of
the ref), and finally the pack. As a result, the bundle argument can be
"-" now.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-02-22 01:59:14 +01:00
|
|
|
test_expect_success 'unbundle 2' '
|
|
|
|
cd "$D/bundle" &&
|
|
|
|
git fetch ../bundle2 master:master &&
|
|
|
|
test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
|
|
|
|
'
|
|
|
|
|
2007-03-08 00:43:05 +01:00
|
|
|
test_expect_success 'bundle does not prerequisite objects' '
|
|
|
|
cd "$D" &&
|
|
|
|
touch file2 &&
|
|
|
|
git add file2 &&
|
|
|
|
git commit -m add.file2 file2 &&
|
|
|
|
git bundle create bundle3 -1 HEAD &&
|
2007-03-12 23:59:16 +01:00
|
|
|
(
|
|
|
|
while read x && test -n "$x"
|
|
|
|
do
|
|
|
|
:;
|
|
|
|
done
|
|
|
|
cat
|
|
|
|
) <bundle3 >bundle.pack &&
|
2007-03-08 00:43:05 +01:00
|
|
|
git index-pack bundle.pack &&
|
|
|
|
test 4 = $(git verify-pack -v bundle.pack | wc -l)
|
|
|
|
'
|
|
|
|
|
2006-09-23 12:40:17 +02:00
|
|
|
test_done
|