Skip to content

Commit 9ed4682

Browse files
benpeartdscho
authored andcommitted
Merge pull request #15 from benpeart/difftool
virtualfilesystem: don't run the virtual file system hook if the index has been redirected
2 parents 198de10 + 1fa9497 commit 9ed4682

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

config.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,10 +2324,24 @@ int git_config_get_virtualfilesystem(void)
23242324
if (core_virtualfilesystem && !*core_virtualfilesystem)
23252325
core_virtualfilesystem = NULL;
23262326

2327-
/* virtual file system relies on the sparse checkout logic so force it on */
23282327
if (core_virtualfilesystem) {
2329-
core_apply_sparse_checkout = 1;
2330-
return 1;
2328+
/*
2329+
* Some git commands spawn helpers and redirect the index to a different
2330+
* location. These include "difftool -d" and the sequencer
2331+
* (i.e. `git rebase -i`, `git cherry-pick` and `git revert`) and others.
2332+
* In those instances we don't want to update their temporary index with
2333+
* our virtualization data.
2334+
*/
2335+
char *default_index_file = xstrfmt("%s/%s", the_repository->gitdir, "index");
2336+
int should_run_hook = !strcmp(default_index_file, the_repository->index_file);
2337+
2338+
free(default_index_file);
2339+
if (should_run_hook) {
2340+
/* virtual file system relies on the sparse checkout logic so force it on */
2341+
core_apply_sparse_checkout = 1;
2342+
return 1;
2343+
}
2344+
core_virtualfilesystem = NULL;
23312345
}
23322346

23332347
return 0;

0 commit comments

Comments
 (0)