Skip to content
Snippets Groups Projects
Commit 4408116eb73f authored by Dan Villiom Podlaski Christiansen's avatar Dan Villiom Podlaski Christiansen
Browse files

tests: use an intermediate bare repository

This removes the need to set configure `receive.denyCurrentBranch` in
Git, which is in part bad form, and also explicitly covered
`test-push-to-head.t`. Pushing to a checked out branch in a non-bare
repository is confusing, and leads to weird results in Git.

More than anything, this is just a slight simplification.
parent ef59b46865d0
No related branches found
No related tags found
1 merge request!157Some minor test suite tweaks
......@@ -16,6 +16,13 @@
> EOF
#endif
Create a bare upstream repository
$ git init --bare repo.git
Initialized empty Git repository in $TESTTMP/repo.git/
Create a couple of commits from Git
$ git init gitrepo
Initialized empty Git repository in $TESTTMP/gitrepo/.git/
$ cd gitrepo
......@@ -19,7 +26,6 @@
$ git init gitrepo
Initialized empty Git repository in $TESTTMP/gitrepo/.git/
$ cd gitrepo
$ git config receive.denyCurrentBranch ignore
$ echo alpha > alpha
$ git add alpha
$ fn_git_commit -m 'add alpha'
......@@ -23,8 +29,7 @@
$ echo alpha > alpha
$ git add alpha
$ fn_git_commit -m 'add alpha'
$ echo beta > beta
$ git add beta
$ fn_git_commit -m 'add beta'
$ fn_git_tag -a -m 'added tag beta' beta
......@@ -27,6 +32,8 @@
$ echo beta > beta
$ git add beta
$ fn_git_commit -m 'add beta'
$ fn_git_tag -a -m 'added tag beta' beta
$ git remote add origin $TESTTMP/repo.git
$ git push --quiet --tags --set-upstream origin master
Branch 'master' set up to track remote branch 'master' from 'origin'. (?)
$ cd ..
......@@ -32,5 +39,8 @@
$ cd ..
$ hg clone gitrepo hgrepo
Clone it:
$ hg clone repo.git hgrepo
importing 2 git commits
new changesets ff7a2f2d8d70:7fe02317c63d (2 drafts)
updating to bookmark master (hg57 !)
......@@ -120,7 +130,7 @@
$ hg phase -d
#endif
$ hg push
pushing to $TESTTMP/gitrepo
pushing to $TESTTMP/repo.git
searching for changes
adding objects
added 1 commits with 1 trees and 1 blobs
......@@ -152,8 +162,8 @@
beta 1:7fe02317c63d
alpha 0:ff7a2f2d8d70
$ hg push
pushing to $TESTTMP/gitrepo
pushing to $TESTTMP/repo.git
searching for changes
abort: pushing refs/heads/master overwrites 3094b9e8da41
[255]
$ hg push -f
......@@ -156,8 +166,8 @@
searching for changes
abort: pushing refs/heads/master overwrites 3094b9e8da41
[255]
$ hg push -f
pushing to $TESTTMP/gitrepo
pushing to $TESTTMP/repo.git
searching for changes
adding objects
added 1 commits with 1 trees and 1 blobs
......@@ -165,7 +175,7 @@
Now create a tag for the old, obsolete master
$ cd ../gitrepo
$ cd ../repo.git
$ git tag detached $(hg log -R ../hgrepo --hidden -r 2 -T '{gitnode}\n')
$ git tag
alpha
......@@ -173,7 +183,7 @@
detached
$ cd ../hgrepo
$ hg pull
pulling from $TESTTMP/gitrepo
pulling from $TESTTMP/repo.git
no changes found
$ hg log -T shorttags
3:3094b9e8da41 draft default/master tip
......@@ -187,7 +197,7 @@
beta 1:7fe02317c63d
alpha 0:ff7a2f2d8d70
$ hg push
pushing to $TESTTMP/gitrepo
pushing to $TESTTMP/repo.git
searching for changes
no changes found
[1]
......@@ -222,10 +232,10 @@
converting revision 0eb1ab0073a885a498d4ae3dc5cf0c26e750fa3d
saving git map to $TESTTMP/hgrepo/.hg/git-mapfile
$ hg push
pushing to $TESTTMP/gitrepo
pushing to $TESTTMP/repo.git
searching for changes
adding objects
added 1 commits with 1 trees and 1 blobs
updating reference refs/heads/master
adding reference refs/tags/gamma
$ cd ../gitrepo
......@@ -226,9 +236,10 @@
searching for changes
adding objects
added 1 commits with 1 trees and 1 blobs
updating reference refs/heads/master
adding reference refs/tags/gamma
$ cd ../gitrepo
$ git fetch --quiet --tags
$ git tag
alpha
beta
......@@ -256,7 +267,7 @@
$ hg phase -d
#endif
$ hg push
pushing to $TESTTMP/gitrepo
pushing to $TESTTMP/repo.git
warning: not overwriting annotated tag 'beta'
searching for changes
adding objects
......@@ -288,7 +299,7 @@
Test how pulling an explicit branch with an annotated tag:
$ hg clone -r master gitrepo hgrepo-2
$ hg clone -r master repo.git hgrepo-2
importing 5 git commits
new changesets ff7a2f2d8d70:c49682c7cba4 (5 drafts)
updating to branch default
......@@ -299,7 +310,7 @@
4:c49682c7cba4 draft default/master tip
$ rm -rf hgrepo-2
$ hg clone -r master gitrepo hgrepo-2
$ hg clone -r master repo.git hgrepo-2
importing 5 git commits
new changesets ff7a2f2d8d70:c49682c7cba4 (5 drafts)
updating to branch default
......@@ -317,7 +328,7 @@
$ cd hgrepo
$ hg phase -fs gamma detached
$ hg pull
pulling from $TESTTMP/gitrepo
pulling from $TESTTMP/repo.git
no changes found
$ hg log -T shorttags -r gamma -r detached
4:0eb1ab0073a8 draft beta gamma
......
Load commonly used test logic
$ . "$TESTDIR/testutil"
$ git init --bare repo.git
Initialized empty Git repository in $TESTTMP/repo.git/
$ git init gitsubrepo
Initialized empty Git repository in $TESTTMP/gitsubrepo/.git/
$ cd gitsubrepo
......@@ -9,9 +12,11 @@
$ fn_git_commit -m 'add beta'
$ cd ..
$ git init gitrepo1
Initialized empty Git repository in $TESTTMP/gitrepo1/.git/
$ cd gitrepo1
$ git clone repo.git gitrepo
Cloning into 'gitrepo'...
warning: You appear to have cloned an empty repository.
done.
$ cd gitrepo
$ echo alpha > alpha
$ git add alpha
$ fn_git_commit -m 'add alpha'
......@@ -23,8 +28,8 @@
Cloning into '*xyz/subrepo2'... (glob)
done.
$ fn_git_commit -m 'add subrepo2'
we are going to push to this repo from our hg clone,
allow commits despite working copy presense
$ git config receive.denyCurrentBranch ignore
$ git push
To $TESTTMP/repo.git
* [new branch] master -> master
$ cd ..
Ensure gitlinks are transformed to .hgsubstate on hg pull from git
......@@ -29,6 +34,6 @@
$ cd ..
Ensure gitlinks are transformed to .hgsubstate on hg pull from git
$ hg clone -u tip gitrepo1 hgrepo 2>&1 | egrep -v '^(Cloning into|done)'
$ hg clone -u tip repo.git hgrepo 2>&1 | egrep -v '^(Cloning into|done)'
importing 3 git commits
new changesets e532b2bfda10:88c5e06a2a29 (3 drafts)
updating to branch default
......@@ -71,9 +76,9 @@
$ echo xxx >> alpha
$ fn_hg_commit -m 'Update subrepo2 from hg' | grep -v "committing subrepository" || true
$ hg push
pushing to $TESTTMP/gitrepo1
pushing to $TESTTMP/repo.git
searching for changes
adding objects
added 1 commits with 2 trees and 1 blobs
updating reference refs/heads/master
$ cd ..
......@@ -75,9 +80,20 @@
searching for changes
adding objects
added 1 commits with 2 trees and 1 blobs
updating reference refs/heads/master
$ cd ..
$ cd gitrepo1
$ cd gitrepo
$ git pull --ff-only
From $TESTTMP/repo
89c22d7..275b0a5 master -> origin/master
Fetching submodule xyz/subrepo2
From $TESTTMP/gitsubrepo
56f0304..aabf7cd master -> origin/master
Updating 89c22d7..275b0a5
Fast-forward
alpha | 1 +
xyz/subrepo2 | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
there shall be two gitlink entries, with values matching that in .hgsubstate
$ git ls-tree -r HEAD^{tree} | grep 'commit'
160000 commit 56f0304c5250308f14cfbafdc27bd12d40154d17 subrepo1
......@@ -93,8 +109,8 @@
$ echo delta > delta
$ hg add delta
$ fn_hg_commit -m "add delta"
$ echo "`hg tip --template '{node}'` hgsub" > ../gitrepo1/.hgsubstate
$ echo "hgsub = ../hgsub" > ../gitrepo1/.hgsub
$ cd ../gitrepo1
$ echo "`hg tip --template '{node}'` hgsub" > ../gitrepo/.hgsubstate
$ echo "hgsub = ../hgsub" > ../gitrepo/.hgsub
$ cd ../gitrepo
$ git add .hgsubstate .hgsub
$ fn_git_commit -m "Test3. Prepare .hgsub and .hgsubstate sources"
......@@ -99,4 +115,8 @@
$ git add .hgsubstate .hgsub
$ fn_git_commit -m "Test3. Prepare .hgsub and .hgsubstate sources"
$ git push
To $TESTTMP/repo.git
275b0a5..e31d576 master -> master
$ cd ../hgrepo
$ hg pull
......@@ -101,6 +121,6 @@
$ cd ../hgrepo
$ hg pull
pulling from $TESTTMP/gitrepo1
pulling from $TESTTMP/repo.git
importing 1 git commits
updating bookmark master
new changesets [0-9a-f]{12,12} \(1 drafts\) (re)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment