mirror of
https://github.com/git/git
synced 2024-09-12 21:04:12 +00:00
Merge branch 'aw/push-force-with-lease-reporting' into maint
"git push --force-with-lease" has been taught to report if the push needed to force (or fast-forwarded). * aw/push-force-with-lease-reporting: push: fix ref status reporting for --force-with-lease
This commit is contained in:
commit
0eefe108ec
15
remote.c
15
remote.c
|
@ -1545,11 +1545,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bypass the usual "must fast-forward" check but
|
* If the remote ref has moved and is now different
|
||||||
* replace it with a weaker "the old value must be
|
* from what we expect, reject any push.
|
||||||
* this value we observed". If the remote ref has
|
|
||||||
* moved and is now different from what we expect,
|
|
||||||
* reject any push.
|
|
||||||
*
|
*
|
||||||
* It also is an error if the user told us to check
|
* It also is an error if the user told us to check
|
||||||
* with the remote-tracking branch to find the value
|
* with the remote-tracking branch to find the value
|
||||||
|
@ -1560,10 +1557,14 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
|
||||||
if (ref->expect_old_no_trackback ||
|
if (ref->expect_old_no_trackback ||
|
||||||
oidcmp(&ref->old_oid, &ref->old_oid_expect))
|
oidcmp(&ref->old_oid, &ref->old_oid_expect))
|
||||||
reject_reason = REF_STATUS_REJECT_STALE;
|
reject_reason = REF_STATUS_REJECT_STALE;
|
||||||
|
else
|
||||||
|
/* If the ref isn't stale then force the update. */
|
||||||
|
force_ref_update = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The usual "must fast-forward" rules.
|
* If the update isn't already rejected then check
|
||||||
|
* the usual "must fast-forward" rules.
|
||||||
*
|
*
|
||||||
* Decide whether an individual refspec A:B can be
|
* Decide whether an individual refspec A:B can be
|
||||||
* pushed. The push will succeed if any of the
|
* pushed. The push will succeed if any of the
|
||||||
|
@ -1582,7 +1583,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
|
||||||
* passing the --force argument
|
* passing the --force argument
|
||||||
*/
|
*/
|
||||||
|
|
||||||
else if (!ref->deletion && !is_null_oid(&ref->old_oid)) {
|
if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) {
|
||||||
if (starts_with(ref->name, "refs/tags/"))
|
if (starts_with(ref->name, "refs/tags/"))
|
||||||
reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
|
reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS;
|
||||||
else if (!has_object_file(&ref->old_oid))
|
else if (!has_object_file(&ref->old_oid))
|
||||||
|
|
|
@ -25,7 +25,8 @@ test_expect_success 'push to update (protected)' '
|
||||||
(
|
(
|
||||||
cd dst &&
|
cd dst &&
|
||||||
test_commit D &&
|
test_commit D &&
|
||||||
test_must_fail git push --force-with-lease=master:master origin master
|
test_must_fail git push --force-with-lease=master:master origin master 2>err &&
|
||||||
|
grep "stale info" err
|
||||||
) &&
|
) &&
|
||||||
git ls-remote . refs/heads/master >expect &&
|
git ls-remote . refs/heads/master >expect &&
|
||||||
git ls-remote src refs/heads/master >actual &&
|
git ls-remote src refs/heads/master >actual &&
|
||||||
|
@ -37,7 +38,8 @@ test_expect_success 'push to update (protected, forced)' '
|
||||||
(
|
(
|
||||||
cd dst &&
|
cd dst &&
|
||||||
test_commit D &&
|
test_commit D &&
|
||||||
git push --force --force-with-lease=master:master origin master
|
git push --force --force-with-lease=master:master origin master 2>err &&
|
||||||
|
grep "forced update" err
|
||||||
) &&
|
) &&
|
||||||
git ls-remote dst refs/heads/master >expect &&
|
git ls-remote dst refs/heads/master >expect &&
|
||||||
git ls-remote src refs/heads/master >actual &&
|
git ls-remote src refs/heads/master >actual &&
|
||||||
|
@ -101,7 +103,8 @@ test_expect_success 'push to update (allowed, tracking)' '
|
||||||
(
|
(
|
||||||
cd dst &&
|
cd dst &&
|
||||||
test_commit D &&
|
test_commit D &&
|
||||||
git push --force-with-lease=master origin master
|
git push --force-with-lease=master origin master 2>err &&
|
||||||
|
! grep "forced update" err
|
||||||
) &&
|
) &&
|
||||||
git ls-remote dst refs/heads/master >expect &&
|
git ls-remote dst refs/heads/master >expect &&
|
||||||
git ls-remote src refs/heads/master >actual &&
|
git ls-remote src refs/heads/master >actual &&
|
||||||
|
@ -114,7 +117,8 @@ test_expect_success 'push to update (allowed even though no-ff)' '
|
||||||
cd dst &&
|
cd dst &&
|
||||||
git reset --hard HEAD^ &&
|
git reset --hard HEAD^ &&
|
||||||
test_commit D &&
|
test_commit D &&
|
||||||
git push --force-with-lease=master origin master
|
git push --force-with-lease=master origin master 2>err &&
|
||||||
|
grep "forced update" err
|
||||||
) &&
|
) &&
|
||||||
git ls-remote dst refs/heads/master >expect &&
|
git ls-remote dst refs/heads/master >expect &&
|
||||||
git ls-remote src refs/heads/master >actual &&
|
git ls-remote src refs/heads/master >actual &&
|
||||||
|
@ -147,7 +151,8 @@ test_expect_success 'push to delete (allowed)' '
|
||||||
setup_srcdst_basic &&
|
setup_srcdst_basic &&
|
||||||
(
|
(
|
||||||
cd dst &&
|
cd dst &&
|
||||||
git push --force-with-lease=master origin :master
|
git push --force-with-lease=master origin :master 2>err &&
|
||||||
|
grep deleted err
|
||||||
) &&
|
) &&
|
||||||
>expect &&
|
>expect &&
|
||||||
git ls-remote src refs/heads/master >actual &&
|
git ls-remote src refs/heads/master >actual &&
|
||||||
|
|
Loading…
Reference in a new issue