summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-10-30 06:43:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-30 06:43:46 (GMT)
commit4c7f5440225aba8f0c7253575e5ffa933a267de7 (patch)
tree498a09bea3303497ac2c101b79371538b188aeae /builtin
parent5742ba504c04420446556a389e5b99e6b228d928 (diff)
parentb072a25fad21b8aecfa29f6ffb813a0a6194a764 (diff)
downloadgit-4c7f5440225aba8f0c7253575e5ffa933a267de7.zip
git-4c7f5440225aba8f0c7253575e5ffa933a267de7.tar.gz
git-4c7f5440225aba8f0c7253575e5ffa933a267de7.tar.bz2
Merge branch 'jc/receive-deny-current-branch-fix'
The receive.denyCurrentBranch=updateInstead codepath kicked in even when the push should have been rejected due to other reasons, such as it does not fast-forward or the update-hook rejects it, which has been corrected. * jc/receive-deny-current-branch-fix: receive: denyCurrentBranch=updateinstead should not blindly update
Diffstat (limited to 'builtin')
-rw-r--r--builtin/receive-pack.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 7f089be..33187bd 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1025,6 +1025,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
const char *ret;
struct object_id *old_oid = &cmd->old_oid;
struct object_id *new_oid = &cmd->new_oid;
+ int do_update_worktree = 0;
/* only refs/... are allowed */
if (!starts_with(name, "refs/") || check_refname_format(name + 5, 0)) {
@@ -1050,9 +1051,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
refuse_unconfigured_deny();
return "branch is currently checked out";
case DENY_UPDATE_INSTEAD:
- ret = update_worktree(new_oid->hash);
- if (ret)
- return ret;
+ /* pass -- let other checks intervene first */
+ do_update_worktree = 1;
break;
}
}
@@ -1117,6 +1117,12 @@ static const char *update(struct command *cmd, struct shallow_info *si)
return "hook declined";
}
+ if (do_update_worktree) {
+ ret = update_worktree(new_oid->hash);
+ if (ret)
+ return ret;
+ }
+
if (is_null_oid(new_oid)) {
struct strbuf err = STRBUF_INIT;
if (!parse_object(the_repository, old_oid)) {