MCPcopy Create free account
hub / github.com/libgit2/pygit2 / Tree_diff_to_tree

Function Tree_diff_to_tree

src/tree.c:352–388  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350 " Instead of diffing a to b. Diff b to a.\n");
351
352PyObject *
353Tree_diff_to_tree(Tree *self, PyObject *args, PyObject *kwds)
354{
355 git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
356 git_diff *diff;
357 git_tree *from, *to = NULL, *tmp;
358 int err, swap = 0;
359 char *keywords[] = {"obj", "flags", "context_lines", "interhunk_lines", "swap", NULL};
360
361 Tree *other = NULL;
362
363 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!IHHi", keywords,
364 &TreeType, &other, &opts.flags,
365 &opts.context_lines,
366 &opts.interhunk_lines, &swap))
367 return NULL;
368
369 if (Object__load((Object*)self) == NULL) { return NULL; } // Lazy load
370 from = self->tree;
371
372 if (other) {
373 if (Object__load((Object*)other) == NULL) { return NULL; } // Lazy load
374 to = other->tree;
375 }
376
377 if (swap > 0) {
378 tmp = from;
379 from = to;
380 to = tmp;
381 }
382
383 err = git_diff_tree_to_tree(&diff, self->repo->repo, from, to, &opts);
384 if (err < 0)
385 return Error_set(err);
386
387 return wrap_diff(diff, self->repo);
388}
389
390
391PySequenceMethods Tree_as_sequence = {

Callers

nothing calls this directly

Calls 3

Object__loadFunction · 0.85
Error_setFunction · 0.85
wrap_diffFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…