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

Function emit_path

tree-diff.c:203–318  ·  view source on GitHub ↗

* new path should be added to combine diff * * 3 cases on how/when it should be called and behaves: * * t, !tp -> path added, all parents lack it * !t, tp -> path removed from all parents * t, tp -> path modified/added * (M for tp[i]=tp[imin], A otherwise) */

Source from the content-addressed store, hash-verified

201 * (M for tp[i]=tp[imin], A otherwise)
202 */
203static void emit_path(struct combine_diff_path ***tail,
204 struct strbuf *base, struct diff_options *opt,
205 int nparent, struct tree_desc *t, struct tree_desc *tp,
206 int imin, int depth)
207{
208 unsigned short mode;
209 const char *path;
210 const struct object_id *oid;
211 int pathlen;
212 int old_baselen = base->len;
213 int i, isdir, recurse = 0, emitthis = 1;
214
215 /* at least something has to be valid */
216 assert(t || tp);
217
218 if (t) {
219 /* path present in resulting tree */
220 oid = tree_entry_extract(t, &path, &mode);
221 pathlen = tree_entry_len(&t->entry);
222 isdir = S_ISDIR(mode);
223 } else {
224 /*
225 * a path was removed - take path from imin parent. Also take
226 * mode from that parent, to decide on recursion(1).
227 *
228 * 1) all modes for tp[i]=tp[imin] should be the same wrt
229 * S_ISDIR, thanks to base_name_compare().
230 */
231 tree_entry_extract(&tp[imin], &path, &mode);
232 pathlen = tree_entry_len(&tp[imin].entry);
233
234 isdir = S_ISDIR(mode);
235 oid = NULL;
236 mode = 0;
237 }
238
239 if (isdir) {
240 strbuf_add(base, path, pathlen);
241 if (should_recurse(base, opt)) {
242 recurse = 1;
243 emitthis = opt->flags.tree_in_recursive;
244 }
245 strbuf_setlen(base, old_baselen);
246 }
247
248 if (emitthis) {
249 int keep;
250 struct combine_diff_path *p;
251
252 strbuf_add(base, path, pathlen);
253 p = combine_diff_path_new(base->buf, base->len, mode,
254 oid ? oid : null_oid(opt->repo->hash_algo),
255 nparent);
256 strbuf_setlen(base, old_baselen);
257
258 for (i = 0; i < nparent; ++i) {
259 /*
260 * tp[i] is valid, if present and if tp[i]==tp[imin] -

Callers 1

ll_diff_tree_pathsFunction · 0.85

Calls 10

tree_entry_extractFunction · 0.85
tree_entry_lenFunction · 0.85
strbuf_addFunction · 0.85
should_recurseFunction · 0.85
strbuf_setlenFunction · 0.85
combine_diff_path_newFunction · 0.85
null_oidFunction · 0.85
oidcpyFunction · 0.85
strbuf_addchFunction · 0.85
ll_diff_tree_pathsFunction · 0.85

Tested by

no test coverage detected