Skip to content

Commit 591ee79

Browse files
benpeartKevin Willford
authored and
Kevin Willford
committed
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 0bbac43 commit 591ee79

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
@@ -32,18 +32,14 @@ static int vfs_hashmap_cmp(const void *unused_cmp_data,
3232
static void get_virtual_filesystem_data(struct strbuf *vfs_data)
3333
{
3434
struct child_process cp = CHILD_PROCESS_INIT;
35-
char ver[64];
36-
const char *argv[3];
3735
int err;
3836

3937
strbuf_init(vfs_data, 0);
4038

41-
snprintf(ver, sizeof(ver), "%d", HOOK_INTERFACE_VERSION);
42-
argv[0] = core_virtualfilesystem;
43-
argv[1] = ver;
44-
argv[2] = NULL;
45-
cp.argv = argv;
39+
argv_array_push(&cp.args, core_virtualfilesystem);
40+
argv_array_pushf(&cp.args, "%d", HOOK_INTERFACE_VERSION);
4641
cp.use_shell = 1;
42+
cp.dir = get_git_work_tree();
4743

4844
err = capture_command(&cp, vfs_data, 1024);
4945
if (err)

0 commit comments

Comments
 (0)