diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-05-28 13:15:43 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-05-28 23:06:25 +0300 |
commit | 0454220d66581f28b9688bc1b687f52cb9561798 (patch) | |
tree | a05a4bc3c0178898c136fb8f89b890a4c8cbe033 /t/t5150-request-pull.sh | |
parent | 5731dfce06a19f59aa1be2bd2120584864d8983b (diff) |
request-pull: warn if the remote object is not the same as the local one
In some cases, git request-pull might be invoked with remote and
local objects that differ even though they point to the same commit.
For example, the remote object might be a lightweight tag
vs. an annotated tag on the local side; or the user might have
reworded the tag locally and forgotten to push it.
When this happens git-request-pull will not warn, because it only
checks that "git ls-remote" returns an SHA1 that matches the local
commit (known as $headrev in the script). This patch makes
git-request-pull retrieve the tag object SHA1 while processing
the "git ls-remote" output, so that it can be matched against the
local object.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5150-request-pull.sh')
-rwxr-xr-x | t/t5150-request-pull.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index c1a821a549..852dcd913f 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -264,4 +264,39 @@ test_expect_success 'request-pull quotes regex metacharacters properly' ' ' +test_expect_success 'pull request with mismatched object' ' + + rm -fr downstream.git && + git init --bare downstream.git && + ( + cd local && + git checkout initial && + git merge --ff-only master && + git push origin HEAD:refs/tags/full && + test_must_fail git request-pull initial "$downstream_url" tags/full \ + 2>../err + ) && + grep "points to a different object" err && + grep "Are you sure you pushed" err + +' + +test_expect_success 'pull request with stale object' ' + + rm -fr downstream.git && + git init --bare downstream.git && + ( + cd local && + git checkout initial && + git merge --ff-only master && + git push origin refs/tags/full && + git tag -f -m"Thirty-one days" full && + test_must_fail git request-pull initial "$downstream_url" tags/full \ + 2>../err + ) && + grep "points to a different object" err && + grep "Are you sure you pushed" err + +' + test_done |