summaryrefslogtreecommitdiff
path: root/read-cache.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-10-07 11:32:53 +0900
committerJunio C Hamano <gitster@pobox.com>2019-10-07 11:32:53 +0900
commitba2d45112224a0bd5ba0f10ba180c88d148cec36 (patch)
treec4824e0fa57f40c49904807f9913aa4c2160b6bb /read-cache.c
parentc90b652afd68364640009a52fa6bf6f5fd245186 (diff)
parent34933d0eff5d4c91fae6ad6f71a6e6a69a496ced (diff)
downloadgit-ba2d45112224a0bd5ba0f10ba180c88d148cec36.tar.gz
Merge branch 'tg/stash-refresh-index'
"git stash" learned to write refreshed index back to disk. * tg/stash-refresh-index: stash: make sure to write refreshed cache merge: use refresh_and_write_cache factor out refresh_and_write_cache function
Diffstat (limited to 'read-cache.c')
-rw-r--r--read-cache.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/read-cache.c b/read-cache.c
index cff1280975..2c1409491d 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1472,6 +1472,27 @@ static void show_file(const char * fmt, const char * name, int in_porcelain,
printf(fmt, name);
}
+int repo_refresh_and_write_index(struct repository *repo,
+ unsigned int refresh_flags,
+ unsigned int write_flags,
+ int gentle,
+ const struct pathspec *pathspec,
+ char *seen, const char *header_msg)
+{
+ struct lock_file lock_file = LOCK_INIT;
+ int fd, ret = 0;
+
+ fd = repo_hold_locked_index(repo, &lock_file, 0);
+ if (!gentle && fd < 0)
+ return -1;
+ if (refresh_index(repo->index, refresh_flags, pathspec, seen, header_msg))
+ ret = 1;
+ if (0 <= fd && write_locked_index(repo->index, &lock_file, COMMIT_LOCK | write_flags))
+ ret = -1;
+ return ret;
+}
+
+
int refresh_index(struct index_state *istate, unsigned int flags,
const struct pathspec *pathspec,
char *seen, const char *header_msg)