Skip to content

Commit c8e13a2

Browse files
benpeartdscho
authored andcommitted
Update the virtualfilesystem support
We now specify that it needs to be run from the root of the git work tree. This enables the hook to be found even if the current working directory is not the root of the repo (like when running 'git diff' with Beyond Compare configured as the diff tool. Also simpify how argv[] parameter is created. Signed-off-by: Ben Peart <[email protected]>
1 parent de8bdd7 commit c8e13a2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

virtualfilesystem.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,14 @@ static int vfs_hashmap_cmp(const void *unused_cmp_data,
3636
static void get_virtual_filesystem_data(struct strbuf *vfs_data)
3737
{
3838
struct child_process cp = CHILD_PROCESS_INIT;
39-
char ver[64];
40-
const char *argv[3];
4139
int err;
4240

4341
strbuf_init(vfs_data, 0);
4442

45-
snprintf(ver, sizeof(ver), "%d", HOOK_INTERFACE_VERSION);
46-
argv[0] = core_virtualfilesystem;
47-
argv[1] = ver;
48-
argv[2] = NULL;
49-
cp.argv = argv;
43+
strvec_push(&cp.args, core_virtualfilesystem);
44+
strvec_pushf(&cp.args, "%d", HOOK_INTERFACE_VERSION);
5045
cp.use_shell = 1;
46+
cp.dir = get_git_work_tree();
5147

5248
err = capture_command(&cp, vfs_data, 1024);
5349
if (err)

0 commit comments

Comments
 (0)