summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2019-01-29 12:47:55 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-01-29 12:47:55 -0800
commitd94ade7f1f30409adecf8bdbae74d85cfb9705ef (patch)
treef11dac9428abbcad780ba7b5a9e05c8873c3c2e6 /builtin
parentMerge branch 'bc/sha-256' (diff)
parentrebase: run post-checkout hook on checkout (diff)
downloadtgif-d94ade7f1f30409adecf8bdbae74d85cfb9705ef.tar.xz
Merge branch 'os/rebase-runs-post-checkout-hook'
"git rebase" internally runs "checkout" to switch between branches, and the command used to call the post-checkout hook, but the reimplementation stopped doing so, which is getting fixed. * os/rebase-runs-post-checkout-hook: rebase: run post-checkout hook on checkout t5403: simplify by using a single repository
Diffstat (limited to 'builtin')
-rw-r--r--builtin/rebase.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 26a6d0ea33..774264bae8 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -533,6 +533,7 @@ finished_rebase:
#define RESET_HEAD_DETACH (1<<0)
#define RESET_HEAD_HARD (1<<1)
+#define RESET_HEAD_RUN_POST_CHECKOUT_HOOK (1<<2)
static int reset_head(struct object_id *oid, const char *action,
const char *switch_to_branch, unsigned flags,
@@ -540,6 +541,7 @@ static int reset_head(struct object_id *oid, const char *action,
{
unsigned detach_head = flags & RESET_HEAD_DETACH;
unsigned reset_hard = flags & RESET_HEAD_HARD;
+ unsigned run_hook = flags & RESET_HEAD_RUN_POST_CHECKOUT_HOOK;
struct object_id head_oid;
struct tree_desc desc[2] = { { NULL }, { NULL } };
struct lock_file lock = LOCK_INIT;
@@ -639,6 +641,10 @@ static int reset_head(struct object_id *oid, const char *action,
ret = update_ref(reflog_head, "HEAD", oid, NULL, 0,
UPDATE_REFS_MSG_ON_ERR);
}
+ if (run_hook)
+ run_hook_le(NULL, "post-checkout",
+ oid_to_hex(orig ? orig : &null_oid),
+ oid_to_hex(oid), "1", NULL);
leave_reset_head:
strbuf_release(&msg);
@@ -1506,7 +1512,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
getenv(GIT_REFLOG_ACTION_ENVIRONMENT),
options.switch_to);
if (reset_head(&oid, "checkout",
- options.head_name, 0,
+ options.head_name,
+ RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
NULL, buf.buf) < 0) {
ret = !!error(_("could not switch to "
"%s"),
@@ -1580,7 +1587,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
strbuf_addf(&msg, "%s: checkout %s",
getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name);
if (reset_head(&options.onto->object.oid, "checkout", NULL,
- RESET_HEAD_DETACH, NULL, msg.buf))
+ RESET_HEAD_DETACH | RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
+ NULL, msg.buf))
die(_("Could not detach HEAD"));
strbuf_release(&msg);