push: require force for refs under refs/tags/
References are allowed to update from one commit-ish to another if the former is an ancestor of the latter. This behavior is oriented to branches which are expected to move with commits. Tag references are expected to be static in a repository, though, thus an update to something under refs/tags/ should be rejected unless the update is forced. Signed-off-by: Chris Rorvick <chris@rorvick.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
8c5f6f717d
commit
dbfeddb12e
@@ -368,7 +368,7 @@ test_expect_success 'push with colon-less refspec (2)' '
|
||||
git branch -D frotz
|
||||
fi &&
|
||||
git tag -f frotz &&
|
||||
git push testrepo frotz &&
|
||||
git push -f testrepo frotz &&
|
||||
check_push_result $the_commit tags/frotz &&
|
||||
check_push_result $the_first_commit heads/frotz
|
||||
|
||||
@@ -929,6 +929,27 @@ test_expect_success 'push into aliased refs (inconsistent)' '
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'push requires --force to update lightweight tag' '
|
||||
mk_test heads/master &&
|
||||
mk_child child1 &&
|
||||
mk_child child2 &&
|
||||
(
|
||||
cd child1 &&
|
||||
git tag Tag &&
|
||||
git push ../child2 Tag &&
|
||||
git push ../child2 Tag &&
|
||||
>file1 &&
|
||||
git add file1 &&
|
||||
git commit -m "file1" &&
|
||||
git tag -f Tag &&
|
||||
test_must_fail git push ../child2 Tag &&
|
||||
git push --force ../child2 Tag &&
|
||||
git tag -f Tag &&
|
||||
test_must_fail git push ../child2 Tag HEAD~ &&
|
||||
git push --force ../child2 Tag
|
||||
)
|
||||
'
|
||||
|
||||
test_expect_success 'push --porcelain' '
|
||||
mk_empty &&
|
||||
echo >.git/foo "To testrepo" &&
|
||||
|
||||
Reference in New Issue
Block a user