read-cache: add post-index-change hook
Add a post-index-change hook that is invoked after the index is written in do_write_locked_index(). This hook is meant primarily for notification, and cannot affect the outcome of git commands that trigger the index write. The hook is passed a flag to indicate whether the working directory was updated or not and a flag indicating if a skip-worktree bit could have changed. These flags enable the hook to optimize its response to the index change notification. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8989e1950a
commit
1956ecd0ab
14
read-cache.c
14
read-cache.c
@ -17,6 +17,7 @@
|
||||
#include "commit.h"
|
||||
#include "blob.h"
|
||||
#include "resolve-undo.h"
|
||||
#include "run-command.h"
|
||||
#include "strbuf.h"
|
||||
#include "varint.h"
|
||||
#include "split-index.h"
|
||||
@ -2999,8 +3000,17 @@ static int do_write_locked_index(struct index_state *istate, struct lock_file *l
|
||||
if (ret)
|
||||
return ret;
|
||||
if (flags & COMMIT_LOCK)
|
||||
return commit_locked_index(lock);
|
||||
return close_lock_file_gently(lock);
|
||||
ret = commit_locked_index(lock);
|
||||
else
|
||||
ret = close_lock_file_gently(lock);
|
||||
|
||||
run_hook_le(NULL, "post-index-change",
|
||||
istate->updated_workdir ? "1" : "0",
|
||||
istate->updated_skipworktree ? "1" : "0", NULL);
|
||||
istate->updated_workdir = 0;
|
||||
istate->updated_skipworktree = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int write_split_index(struct index_state *istate,
|
||||
|
Reference in New Issue
Block a user