Skip to contentSkip to conversation

Call refresh_cache() when updating the user index for --only commits.

PATCH In review Kristian Høgsberg 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Call refresh_cache() when updating the user index for --only commits.

We're guaranteeing the user that the index will be stat-clean after git commit. Thus, we need to call refresh_cache() for the user index too, in the 'git commit <paths>' case.

---
 builtin-commit.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
builtin-commit.c +1 -0
index 5011b8b..35205ef 100644
@@ -109,6 +109,7 @@ static char *prepare_index(const char **files, const char *prefix)
 
 	/* update the user index file */
 	add_files_to_cache(verbose, prefix, files);
+	refresh_cache(REFRESH_QUIET);
 	if (write_cache(fd, active_cache, active_nr) || close(fd))
 		die("unable to write new_index file");
 
Signature · 1 line
1.5.3.5.1762.g9a09d-dirty
#1 lore raw
Quoted 14 lines · Kristian Høgsberg

We're guaranteeing the user that the index will be stat-clean after git commit. Thus, we need to call refresh_cache() for the user index too, in the 'git commit <paths>' case.

---
 builtin-commit.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
builtin-commit.c +0 -0
index 5011b8b..35205ef 100644

builtin-commit.c static char *prepare_index(const char **files, const char *prefix) · line 115

Quoted 7 lines
builtin-commit.c +1 -0
@@ -109,6 +109,7 @@ static char *prepare_index(const char **files, const char *prefix)
 
 	/* update the user index file */
 	add_files_to_cache(verbose, prefix, files);
+	refresh_cache(REFRESH_QUIET);
 	if (write_cache(fd, active_cache, active_nr) || close(fd))
 		die("unable to write new_index file");
 

Ah. This is the real index file that is left for the user after a partial commit "git-commit <path>" returns.

The other refresh_cache() after this one does not matter if we did not have hook scripts, but it is not very easy to cheaply detect if we are not going to run any hooks so let's leave it there.

Thanks.