MCPcopy Index your code
hub / github.com/git/git / builtin_diff_b_f

Function builtin_diff_b_f

builtin/diff.c:81–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81static void builtin_diff_b_f(struct rev_info *revs,
82 int argc, const char **argv UNUSED,
83 struct object_array_entry **blob)
84{
85 /* Blob vs file in the working tree*/
86 struct stat st;
87 const char *path;
88
89 if (argc > 1)
90 usage(builtin_diff_usage);
91
92 GUARD_PATHSPEC(&revs->prune_data, PATHSPEC_FROMTOP | PATHSPEC_LITERAL);
93 path = revs->prune_data.items[0].match;
94
95 if (lstat(path, &st))
96 die_errno(_("failed to stat '%s'"), path);
97 if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
98 die(_("'%s': not a regular file or symlink"), path);
99
100 diff_set_mnemonic_prefix(&revs->diffopt, "o/", "w/");
101
102 if (blob[0]->mode == S_IFINVALID)
103 blob[0]->mode = canon_mode(st.st_mode);
104
105 stuff_change(&revs->diffopt,
106 blob[0]->mode, canon_mode(st.st_mode),
107 &blob[0]->item->oid, null_oid(the_hash_algo),
108 1, 0,
109 blob[0]->path ? blob[0]->path : path,
110 path);
111 diffcore_std(&revs->diffopt);
112 diff_flush(&revs->diffopt);
113}
114
115static void builtin_diff_blobs(struct rev_info *revs,
116 int argc, const char **argv UNUSED,

Callers 1

cmd_diffFunction · 0.85

Calls 9

die_errnoFunction · 0.85
diff_set_mnemonic_prefixFunction · 0.85
canon_modeFunction · 0.85
stuff_changeFunction · 0.85
null_oidFunction · 0.85
diffcore_stdFunction · 0.85
diff_flushFunction · 0.85
usageFunction · 0.50
dieFunction · 0.50

Tested by

no test coverage detected