Merge branch 'zh/push-to-delete-onelevel-ref'
"git push" has been taught to allow deletion of refs with one-level names to help repairing a repository who acquired such a ref by mistake. In general, we don't encourage use of such a ref, and creation or update to such a ref is rejected as before. * zh/push-to-delete-onelevel-ref: push: allow delete single-level ref receive-pack: fix funny ref error messsage
This commit is contained in:
@ -1460,8 +1460,10 @@ static const char *update(struct command *cmd, struct shallow_info *si)
|
|||||||
find_shared_symref(worktrees, "HEAD", name);
|
find_shared_symref(worktrees, "HEAD", name);
|
||||||
|
|
||||||
/* only refs/... are allowed */
|
/* only refs/... are allowed */
|
||||||
if (!starts_with(name, "refs/") || check_refname_format(name + 5, 0)) {
|
if (!starts_with(name, "refs/") ||
|
||||||
rp_error("refusing to create funny ref '%s' remotely", name);
|
check_refname_format(name + 5, is_null_oid(new_oid) ?
|
||||||
|
REFNAME_ALLOW_ONELEVEL : 0)) {
|
||||||
|
rp_error("refusing to update funny ref '%s' remotely", name);
|
||||||
ret = "funny refname";
|
ret = "funny refname";
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@ static int check_ref(const char *name, unsigned int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* REF_NORMAL means that we don't want the magic fake tag refs */
|
/* REF_NORMAL means that we don't want the magic fake tag refs */
|
||||||
if ((flags & REF_NORMAL) && check_refname_format(name, 0))
|
if ((flags & REF_NORMAL) && check_refname_format(name,
|
||||||
|
REFNAME_ALLOW_ONELEVEL))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* REF_HEADS means that we want regular branch heads */
|
/* REF_HEADS means that we want regular branch heads */
|
||||||
|
@ -401,6 +401,11 @@ test_expect_success 'push with ambiguity' '
|
|||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'push with onelevel ref' '
|
||||||
|
mk_test testrepo heads/main &&
|
||||||
|
test_must_fail git push testrepo HEAD:refs/onelevel
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'push with colon-less refspec (1)' '
|
test_expect_success 'push with colon-less refspec (1)' '
|
||||||
|
|
||||||
mk_test testrepo heads/frotz tags/frotz &&
|
mk_test testrepo heads/frotz tags/frotz &&
|
||||||
@ -898,6 +903,13 @@ test_expect_success 'push --delete refuses empty string' '
|
|||||||
test_must_fail git push testrepo --delete ""
|
test_must_fail git push testrepo --delete ""
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'push --delete onelevel refspecs' '
|
||||||
|
mk_test testrepo heads/main &&
|
||||||
|
git -C testrepo update-ref refs/onelevel refs/heads/main &&
|
||||||
|
git push testrepo --delete refs/onelevel &&
|
||||||
|
test_must_fail git -C testrepo rev-parse --verify refs/onelevel
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'warn on push to HEAD of non-bare repository' '
|
test_expect_success 'warn on push to HEAD of non-bare repository' '
|
||||||
mk_test testrepo heads/main &&
|
mk_test testrepo heads/main &&
|
||||||
(
|
(
|
||||||
|
Reference in New Issue
Block a user