Skip to content

Commit

Permalink
Update the virtualfilesystem support
Browse files Browse the repository at this point in the history
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 <benpeart@microsoft.com>
  • Loading branch information
benpeart authored and dscho committed May 25, 2019
1 parent 21e3d4b commit 238057e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions virtualfilesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,14 @@ static int vfs_hashmap_cmp(const void *unused_cmp_data,
static void get_virtual_filesystem_data(struct strbuf *vfs_data)
{
struct child_process cp = CHILD_PROCESS_INIT;
char ver[64];
const char *argv[3];
int err;

strbuf_init(vfs_data, 0);

snprintf(ver, sizeof(ver), "%d", HOOK_INTERFACE_VERSION);
argv[0] = core_virtualfilesystem;
argv[1] = ver;
argv[2] = NULL;
cp.argv = argv;
argv_array_push(&cp.args, core_virtualfilesystem);
argv_array_pushf(&cp.args, "%d", HOOK_INTERFACE_VERSION);
cp.use_shell = 1;
cp.dir = get_git_work_tree();

err = capture_command(&cp, vfs_data, 1024);
if (err)
Expand Down

0 comments on commit 238057e

Please sign in to comment.