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

Function changed_files

builtin/difftool.c:225–273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225static void changed_files(struct repository *repo,
226 struct hashmap *result, const char *index_path,
227 const char *workdir)
228{
229 struct child_process update_index = CHILD_PROCESS_INIT;
230 struct child_process diff_files = CHILD_PROCESS_INIT;
231 struct strbuf buf = STRBUF_INIT;
232 const char *git_dir = absolute_path(repo_get_git_dir(repo));
233 FILE *fp;
234
235 strvec_pushl(&update_index.args,
236 "--git-dir", git_dir, "--work-tree", workdir,
237 "update-index", "--really-refresh", "-q",
238 "--unmerged", NULL);
239 update_index.no_stdin = 1;
240 update_index.no_stdout = 1;
241 update_index.no_stderr = 1;
242 update_index.git_cmd = 1;
243 update_index.use_shell = 0;
244 update_index.clean_on_exit = 1;
245 update_index.dir = workdir;
246 strvec_pushf(&update_index.env, "GIT_INDEX_FILE=%s", index_path);
247 /* Ignore any errors of update-index */
248 run_command(&update_index);
249
250 strvec_pushl(&diff_files.args,
251 "--git-dir", git_dir, "--work-tree", workdir,
252 "diff-files", "--name-only", "-z", NULL);
253 diff_files.no_stdin = 1;
254 diff_files.git_cmd = 1;
255 diff_files.use_shell = 0;
256 diff_files.clean_on_exit = 1;
257 diff_files.out = -1;
258 diff_files.dir = workdir;
259 strvec_pushf(&diff_files.env, "GIT_INDEX_FILE=%s", index_path);
260 if (start_command(&diff_files))
261 die("could not obtain raw diff");
262 fp = xfdopen(diff_files.out, "r");
263 while (!strbuf_getline_nul(&buf, fp)) {
264 struct path_entry *entry;
265 FLEX_ALLOC_STR(entry, path, buf.buf);
266 hashmap_entry_init(&entry->entry, strhash(buf.buf));
267 hashmap_add(result, &entry->entry);
268 }
269 fclose(fp);
270 if (finish_command(&diff_files))
271 die("diff-files did not exit properly");
272 strbuf_release(&buf);
273}
274
275static int ensure_leading_directories(struct repository *repo, char *path)
276{

Callers 1

run_dir_diffFunction · 0.85

Calls 14

absolute_pathFunction · 0.85
repo_get_git_dirFunction · 0.85
strvec_pushlFunction · 0.85
strvec_pushfFunction · 0.85
run_commandFunction · 0.85
start_commandFunction · 0.85
xfdopenFunction · 0.85
strbuf_getline_nulFunction · 0.85
hashmap_entry_initFunction · 0.85
strhashFunction · 0.85
hashmap_addFunction · 0.85
finish_commandFunction · 0.85

Tested by

no test coverage detected