@@ -369,6 +369,7 @@ static void add_var(struct strbuf *buf, const char *name, const char *value)
369
369
#define RESET_HEAD_DETACH (1<<0)
370
370
#define RESET_HEAD_HARD (1<<1)
371
371
#define RESET_HEAD_REFS_ONLY (1<<2)
372
+ #define RESET_HEAD_RUN_HOOK (1<<3)
372
373
373
374
static int reset_head (struct object_id * oid , const char * action ,
374
375
const char * switch_to_branch , unsigned flags ,
@@ -377,6 +378,7 @@ static int reset_head(struct object_id *oid, const char *action,
377
378
unsigned detach_head = flags & RESET_HEAD_DETACH ;
378
379
unsigned reset_hard = flags & RESET_HEAD_HARD ;
379
380
unsigned refs_only = flags & RESET_HEAD_REFS_ONLY ;
381
+ unsigned run_hook = flags & RESET_HEAD_RUN_HOOK ;
380
382
struct object_id head_oid ;
381
383
struct tree_desc desc [2 ] = { { NULL }, { NULL } };
382
384
struct lock_file lock = LOCK_INIT ;
@@ -481,6 +483,10 @@ static int reset_head(struct object_id *oid, const char *action,
481
483
ret = create_symref ("HEAD" , switch_to_branch ,
482
484
reflog_head );
483
485
}
486
+ if (run_hook )
487
+ run_hook_le (NULL , "post-checkout" ,
488
+ oid_to_hex (orig ? orig : & null_oid ),
489
+ oid_to_hex (oid ), "1" , NULL );
484
490
485
491
leave_reset_head :
486
492
strbuf_release (& msg );
@@ -1729,7 +1735,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix)
1729
1735
strbuf_addf (& msg , "%s: checkout %s" ,
1730
1736
getenv (GIT_REFLOG_ACTION_ENVIRONMENT ), options .onto_name );
1731
1737
if (reset_head (& options .onto -> object .oid , "checkout" , NULL ,
1732
- RESET_HEAD_DETACH , NULL , msg .buf ))
1738
+ RESET_HEAD_DETACH | RESET_HEAD_RUN_HOOK , NULL , msg .buf ))
1733
1739
die (_ ("Could not detach HEAD" ));
1734
1740
strbuf_release (& msg );
1735
1741
0 commit comments