mirror of
https://github.com/git/git.git
synced 2024-12-11 10:54:21 +08:00
3235b7053c
Currently git-svn assumes that two tags created from the same revision will have the same repo url, so it uses a ref to the tag without checking that its url matches the current url. This causes issues when fetching an svn repo where a tag was created, deleted, and then recreated under the following circumstances: - Both tags were copied from the same revision. - Both tags had the same name. - Both tags had different repository paths. - [Optional] Both tags have a file with the same name but different content. When all four conditions are met, a checksum mismatch error occurs because the content of two files with the same path differs (see t/t9155--git-svn-fetch-deleted-tag.sh): Checksum mismatch: ChangeLog 065854.... expected: ce771b.... got: 9563fd.... When only the first three conditions are met, no error occurs but the tag in git matches the first (deleted) tag instead of the last (most recent) tag (see t/t9156-git-svn-fetch-deleted-tag-2.sh). The fix is to verify that the repo url for the ref matches the current url. If the urls do not match, then a "tail" is grown on the tag name by appending a dash and rechecking the new ref's repo url until either a matching repo url is found or a new tag is created. Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net> Acked-by: Eric Wong <normalperson@yhbt.net>
45 lines
1.4 KiB
Bash
Executable File
45 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='git svn fetch deleted tag 2'
|
|
|
|
. ./lib-git-svn.sh
|
|
|
|
test_expect_success 'setup svn repo' '
|
|
mkdir -p import/branches &&
|
|
mkdir -p import/tags &&
|
|
mkdir -p import/trunk/subdir1 &&
|
|
mkdir -p import/trunk/subdir2 &&
|
|
mkdir -p import/trunk/subdir3 &&
|
|
echo "file1" >import/trunk/subdir1/file &&
|
|
echo "file2" >import/trunk/subdir2/file &&
|
|
echo "file3" >import/trunk/subdir3/file &&
|
|
svn_cmd import -m "import for git svn" import "$svnrepo" &&
|
|
rm -rf import &&
|
|
|
|
svn_cmd co "$svnrepo/trunk" svn_project &&
|
|
(cd svn_project &&
|
|
echo "change1" >>subdir1/file &&
|
|
echo "change2" >>subdir2/file &&
|
|
echo "change3" >>subdir3/file &&
|
|
svn_cmd ci -m "change" .
|
|
) &&
|
|
|
|
svn_cmd cp -m "create mytag 1" -r2 "$svnrepo/trunk/subdir1" "$svnrepo/tags/mytag" &&
|
|
svn_cmd rm -m "delete mytag 1" "$svnrepo/tags/mytag" &&
|
|
svn_cmd cp -m "create mytag 2" -r2 "$svnrepo/trunk/subdir2" "$svnrepo/tags/mytag" &&
|
|
svn_cmd rm -m "delete mytag 2" "$svnrepo/tags/mytag" &&
|
|
svn_cmd cp -m "create mytag 3" -r2 "$svnrepo/trunk/subdir3" "$svnrepo/tags/mytag"
|
|
'
|
|
|
|
test_expect_success 'fetch deleted tags from same revision with no checksum error' '
|
|
git svn init --stdlayout "$svnrepo" git_project &&
|
|
cd git_project &&
|
|
git svn fetch &&
|
|
|
|
git diff --exit-code master:subdir3/file tags/mytag:file &&
|
|
git diff --exit-code master:subdir2/file tags/mytag^:file &&
|
|
git diff --exit-code master:subdir1/file tags/mytag^^:file
|
|
'
|
|
|
|
test_done
|