]> git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-match-trees.c
notes: avoid potential use-after-free during insertion
[thirdparty/git.git] / t / helper / test-match-trees.c
1 #include "test-tool.h"
2 #include "cache.h"
3 #include "tree.h"
4
5 int cmd__match_trees(int ac, const char **av)
6 {
7 struct object_id hash1, hash2, shifted;
8 struct tree *one, *two;
9
10 setup_git_directory();
11
12 if (get_oid(av[1], &hash1))
13 die("cannot parse %s as an object name", av[1]);
14 if (get_oid(av[2], &hash2))
15 die("cannot parse %s as an object name", av[2]);
16 one = parse_tree_indirect(&hash1);
17 if (!one)
18 die("not a tree-ish %s", av[1]);
19 two = parse_tree_indirect(&hash2);
20 if (!two)
21 die("not a tree-ish %s", av[2]);
22
23 shift_tree(&one->object.oid, &two->object.oid, &shifted, -1);
24 printf("shifted: %s\n", oid_to_hex(&shifted));
25
26 exit(0);
27 }