2006-11-16 20:47:22 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='pulling into void'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2010-08-13 03:50:49 +02:00
|
|
|
modify () {
|
|
|
|
sed -e "$1" <"$2" >"$2.x" &&
|
|
|
|
mv "$2.x" "$2"
|
|
|
|
}
|
|
|
|
|
2006-11-16 20:47:22 +01:00
|
|
|
D=`pwd`
|
|
|
|
|
|
|
|
test_expect_success setup '
|
|
|
|
|
|
|
|
echo file >file &&
|
|
|
|
git add file &&
|
|
|
|
git commit -a -m original
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'pulling into void' '
|
|
|
|
mkdir cloned &&
|
|
|
|
cd cloned &&
|
2007-01-12 22:01:46 +01:00
|
|
|
git init &&
|
2006-11-16 20:47:22 +01:00
|
|
|
git pull ..
|
|
|
|
'
|
|
|
|
|
|
|
|
cd "$D"
|
|
|
|
|
|
|
|
test_expect_success 'checking the results' '
|
|
|
|
test -f file &&
|
|
|
|
test -f cloned/file &&
|
|
|
|
diff file cloned/file
|
|
|
|
'
|
|
|
|
|
2008-10-15 00:32:20 +02:00
|
|
|
test_expect_success 'pulling into void using master:master' '
|
|
|
|
mkdir cloned-uho &&
|
|
|
|
(
|
|
|
|
cd cloned-uho &&
|
|
|
|
git init &&
|
|
|
|
git pull .. master:master
|
|
|
|
) &&
|
|
|
|
test -f file &&
|
|
|
|
test -f cloned-uho/file &&
|
|
|
|
test_cmp file cloned-uho/file
|
|
|
|
'
|
|
|
|
|
git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like
[remote "local"]
url = .
fetch = refs/heads/*:refs/heads/*
Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names. The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.
To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'. In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations. In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.
The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created. Finally, it fixes a typo in git-checkout.sh.
Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-15 09:23:20 +01:00
|
|
|
test_expect_success 'test . as a remote' '
|
|
|
|
|
|
|
|
git branch copy master &&
|
|
|
|
git config branch.copy.remote . &&
|
|
|
|
git config branch.copy.merge refs/heads/master &&
|
|
|
|
echo updated >file &&
|
|
|
|
git commit -a -m updated &&
|
|
|
|
git checkout copy &&
|
|
|
|
test `cat file` = file &&
|
|
|
|
git pull &&
|
|
|
|
test `cat file` = updated
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'the default remote . should not break explicit pull' '
|
|
|
|
git checkout -b second master^ &&
|
|
|
|
echo modified >file &&
|
|
|
|
git commit -a -m modified &&
|
|
|
|
git checkout copy &&
|
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
test `cat file` = file &&
|
|
|
|
git pull . second &&
|
|
|
|
test `cat file` = modified
|
|
|
|
'
|
|
|
|
|
2007-11-28 14:11:07 +01:00
|
|
|
test_expect_success '--rebase' '
|
|
|
|
git branch to-rebase &&
|
|
|
|
echo modified again > file &&
|
|
|
|
git commit -m file file &&
|
|
|
|
git checkout to-rebase &&
|
|
|
|
echo new > file2 &&
|
|
|
|
git add file2 &&
|
|
|
|
git commit -m "new file" &&
|
|
|
|
git tag before-rebase &&
|
|
|
|
git pull --rebase . copy &&
|
|
|
|
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
|
|
|
|
test new = $(git show HEAD:file2)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'branch.to-rebase.rebase' '
|
|
|
|
git reset --hard before-rebase &&
|
|
|
|
git config branch.to-rebase.rebase 1 &&
|
|
|
|
git pull . copy &&
|
2008-01-26 19:04:37 +01:00
|
|
|
git config branch.to-rebase.rebase 0 &&
|
2007-11-28 14:11:07 +01:00
|
|
|
test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
|
|
|
|
test new = $(git show HEAD:file2)
|
|
|
|
'
|
|
|
|
|
2008-01-26 19:04:37 +01:00
|
|
|
test_expect_success '--rebase with rebased upstream' '
|
|
|
|
|
|
|
|
git remote add -f me . &&
|
|
|
|
git checkout copy &&
|
2009-06-12 00:39:19 +02:00
|
|
|
git tag copy-orig &&
|
2008-01-26 19:04:37 +01:00
|
|
|
git reset --hard HEAD^ &&
|
|
|
|
echo conflicting modification > file &&
|
|
|
|
git commit -m conflict file &&
|
|
|
|
git checkout to-rebase &&
|
|
|
|
echo file > file2 &&
|
|
|
|
git commit -m to-rebase file2 &&
|
2009-06-12 00:39:19 +02:00
|
|
|
git tag to-rebase-orig &&
|
2008-01-26 19:04:37 +01:00
|
|
|
git pull --rebase me copy &&
|
|
|
|
test "conflicting modification" = "$(cat file)" &&
|
|
|
|
test file = $(cat file2)
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-06-12 00:39:19 +02:00
|
|
|
test_expect_success '--rebase with rebased default upstream' '
|
|
|
|
|
|
|
|
git update-ref refs/remotes/me/copy copy-orig &&
|
|
|
|
git checkout --track -b to-rebase2 me/copy &&
|
|
|
|
git reset --hard to-rebase-orig &&
|
|
|
|
git pull --rebase &&
|
|
|
|
test "conflicting modification" = "$(cat file)" &&
|
|
|
|
test file = $(cat file2)
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-07-19 09:45:16 +02:00
|
|
|
test_expect_success 'rebased upstream + fetch + pull --rebase' '
|
2009-07-16 02:09:14 +02:00
|
|
|
|
|
|
|
git update-ref refs/remotes/me/copy copy-orig &&
|
|
|
|
git reset --hard to-rebase-orig &&
|
|
|
|
git checkout --track -b to-rebase3 me/copy &&
|
|
|
|
git reset --hard to-rebase-orig &&
|
|
|
|
git fetch &&
|
2009-07-19 09:45:16 +02:00
|
|
|
git pull --rebase &&
|
2009-07-16 02:09:14 +02:00
|
|
|
test "conflicting modification" = "$(cat file)" &&
|
|
|
|
test file = "$(cat file2)"
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-05-21 13:32:16 +02:00
|
|
|
test_expect_success 'pull --rebase dies early with dirty working directory' '
|
|
|
|
|
2009-06-12 00:39:19 +02:00
|
|
|
git checkout to-rebase &&
|
2008-05-21 13:32:16 +02:00
|
|
|
git update-ref refs/remotes/me/copy copy^ &&
|
|
|
|
COPY=$(git rev-parse --verify me/copy) &&
|
|
|
|
git rebase --onto $COPY copy &&
|
|
|
|
git config branch.to-rebase.remote me &&
|
|
|
|
git config branch.to-rebase.merge refs/heads/copy &&
|
|
|
|
git config branch.to-rebase.rebase true &&
|
|
|
|
echo dirty >> file &&
|
|
|
|
git add file &&
|
|
|
|
test_must_fail git pull &&
|
|
|
|
test $COPY = $(git rev-parse --verify me/copy) &&
|
|
|
|
git checkout HEAD -- file &&
|
|
|
|
git pull &&
|
|
|
|
test $COPY != $(git rev-parse --verify me/copy)
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-08-12 05:27:40 +02:00
|
|
|
test_expect_success 'pull --rebase works on branch yet to be born' '
|
|
|
|
git rev-parse master >expect &&
|
|
|
|
mkdir empty_repo &&
|
|
|
|
(cd empty_repo &&
|
|
|
|
git init &&
|
|
|
|
git pull --rebase .. master &&
|
|
|
|
git rev-parse HEAD >../actual
|
|
|
|
) &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2010-08-13 03:50:49 +02:00
|
|
|
test_expect_success 'setup for detecting upstreamed changes' '
|
|
|
|
mkdir src &&
|
|
|
|
(cd src &&
|
|
|
|
git init &&
|
|
|
|
printf "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n" > stuff &&
|
|
|
|
git add stuff &&
|
|
|
|
git commit -m "Initial revision"
|
|
|
|
) &&
|
|
|
|
git clone src dst &&
|
|
|
|
(cd src &&
|
|
|
|
modify s/5/43/ stuff &&
|
|
|
|
git commit -a -m "5->43" &&
|
|
|
|
modify s/6/42/ stuff &&
|
|
|
|
git commit -a -m "Make it bigger"
|
|
|
|
) &&
|
|
|
|
(cd dst &&
|
|
|
|
modify s/5/43/ stuff &&
|
|
|
|
git commit -a -m "Independent discovery of 5->43"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_failure 'git pull --rebase detects upstreamed changes' '
|
|
|
|
(cd dst &&
|
|
|
|
git pull --rebase &&
|
|
|
|
test -z "$(git ls-files -u)"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup for avoiding reapplying old patches' '
|
|
|
|
(cd dst &&
|
|
|
|
test_might_fail git rebase --abort &&
|
|
|
|
git reset --hard origin/master
|
|
|
|
) &&
|
|
|
|
git clone --bare src src-replace.git &&
|
|
|
|
rm -rf src &&
|
|
|
|
mv src-replace.git src &&
|
|
|
|
(cd dst &&
|
|
|
|
modify s/2/22/ stuff &&
|
|
|
|
git commit -a -m "Change 2" &&
|
|
|
|
modify s/3/33/ stuff &&
|
|
|
|
git commit -a -m "Change 3" &&
|
|
|
|
modify s/4/44/ stuff &&
|
|
|
|
git commit -a -m "Change 4" &&
|
|
|
|
git push &&
|
|
|
|
|
|
|
|
modify s/44/55/ stuff &&
|
|
|
|
git commit --amend -a -m "Modified Change 4"
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_failure 'git pull --rebase does not reapply old patches' '
|
|
|
|
(cd dst &&
|
|
|
|
test_must_fail git pull --rebase &&
|
|
|
|
test 1 = $(find .git/rebase-apply -name "000*" | wc -l)
|
|
|
|
)
|
|
|
|
'
|
|
|
|
|
2006-11-16 20:47:22 +01:00
|
|
|
test_done
|