MCPcopy Create free account
hub / github.com/git/git / run_dir_diff

Function run_dir_diff

builtin/difftool.c:372–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372static int run_dir_diff(struct repository *repo,
373 struct difftool_options *dt_options,
374 const char *extcmd, const char *prefix,
375 struct child_process *child)
376{
377 struct strbuf info = STRBUF_INIT, lpath = STRBUF_INIT;
378 struct strbuf rpath = STRBUF_INIT, buf = STRBUF_INIT;
379 struct strbuf ldir = STRBUF_INIT, rdir = STRBUF_INIT;
380 struct strbuf wtdir = STRBUF_INIT;
381 struct strbuf tmpdir = STRBUF_INIT;
382 char *lbase_dir = NULL, *rbase_dir = NULL;
383 size_t ldir_len, rdir_len, wtdir_len;
384 const char *workdir, *tmp;
385 int ret = 0;
386 size_t i;
387 FILE *fp = NULL;
388 struct hashmap working_tree_dups = HASHMAP_INIT(working_tree_entry_cmp,
389 NULL);
390 struct hashmap submodules = HASHMAP_INIT(pair_cmp, NULL);
391 struct hashmap symlinks2 = HASHMAP_INIT(pair_cmp, NULL);
392 struct hashmap_iter iter;
393 struct pair_entry *entry;
394 struct index_state wtindex = INDEX_STATE_INIT(repo);
395 struct checkout lstate, rstate;
396 int err = 0;
397 struct child_process cmd = CHILD_PROCESS_INIT;
398 struct hashmap wt_modified = HASHMAP_INIT(path_entry_cmp, NULL);
399 struct hashmap tmp_modified = HASHMAP_INIT(path_entry_cmp, NULL);
400 int indices_loaded = 0;
401
402 workdir = repo_get_work_tree(repo);
403
404 /* Setup temp directories */
405 tmp = getenv("TMPDIR");
406 strbuf_add_absolute_path(&tmpdir, tmp ? tmp : "/tmp");
407 strbuf_trim_trailing_dir_sep(&tmpdir);
408 strbuf_addstr(&tmpdir, "/git-difftool.XXXXXX");
409 if (!mkdtemp(tmpdir.buf)) {
410 ret = error("could not create '%s'", tmpdir.buf);
411 goto finish;
412 }
413 strbuf_addf(&ldir, "%s/left/", tmpdir.buf);
414 strbuf_addf(&rdir, "%s/right/", tmpdir.buf);
415 strbuf_addstr(&wtdir, workdir);
416 if (!wtdir.len || !is_dir_sep(wtdir.buf[wtdir.len - 1]))
417 strbuf_addch(&wtdir, '/');
418 mkdir(ldir.buf, 0700);
419 mkdir(rdir.buf, 0700);
420
421 memset(&lstate, 0, sizeof(lstate));
422 lstate.base_dir = lbase_dir = xstrdup(ldir.buf);
423 lstate.base_dir_len = ldir.len;
424 lstate.force = 1;
425 memset(&rstate, 0, sizeof(rstate));
426 rstate.base_dir = rbase_dir = xstrdup(rdir.buf);
427 rstate.base_dir_len = rdir.len;
428 rstate.force = 1;
429

Callers 1

cmd_difftoolFunction · 0.85

Calls 15

repo_get_work_treeFunction · 0.85
strbuf_add_absolute_pathFunction · 0.85
strbuf_addstrFunction · 0.85
errorFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_addchFunction · 0.85
xstrdupFunction · 0.85
start_commandFunction · 0.85
xfdopenFunction · 0.85
strbuf_getline_nulFunction · 0.85
starts_withFunction · 0.85

Tested by

no test coverage detected