2018-03-24 10:44:45 +03:00
|
|
|
#include "test-tool.h"
|
2007-02-16 03:32:45 +03:00
|
|
|
#include "cache.h"
|
|
|
|
#include "tree.h"
|
|
|
|
|
2018-03-24 10:44:45 +03:00
|
|
|
int cmd__match_trees(int ac, const char **av)
|
2007-02-16 03:32:45 +03:00
|
|
|
{
|
2016-04-18 02:10:37 +03:00
|
|
|
struct object_id hash1, hash2, shifted;
|
2007-02-16 03:32:45 +03:00
|
|
|
struct tree *one, *two;
|
|
|
|
|
2016-03-06 01:16:50 +03:00
|
|
|
setup_git_directory();
|
|
|
|
|
2016-04-18 02:10:37 +03:00
|
|
|
if (get_oid(av[1], &hash1))
|
2007-02-16 03:32:45 +03:00
|
|
|
die("cannot parse %s as an object name", av[1]);
|
2016-04-18 02:10:37 +03:00
|
|
|
if (get_oid(av[2], &hash2))
|
2007-02-16 03:32:45 +03:00
|
|
|
die("cannot parse %s as an object name", av[2]);
|
2017-05-07 01:10:37 +03:00
|
|
|
one = parse_tree_indirect(&hash1);
|
2007-02-16 03:32:45 +03:00
|
|
|
if (!one)
|
2013-09-04 23:04:30 +04:00
|
|
|
die("not a tree-ish %s", av[1]);
|
2017-05-07 01:10:37 +03:00
|
|
|
two = parse_tree_indirect(&hash2);
|
2007-02-16 03:32:45 +03:00
|
|
|
if (!two)
|
2013-09-04 23:04:30 +04:00
|
|
|
die("not a tree-ish %s", av[2]);
|
2007-02-16 03:32:45 +03:00
|
|
|
|
2019-06-27 12:28:51 +03:00
|
|
|
shift_tree(the_repository, &one->object.oid, &two->object.oid, &shifted, -1);
|
2016-04-18 02:10:37 +03:00
|
|
|
printf("shifted: %s\n", oid_to_hex(&shifted));
|
2007-02-16 03:32:45 +03:00
|
|
|
|
2021-06-08 13:48:03 +03:00
|
|
|
return 0;
|
2007-02-16 03:32:45 +03:00
|
|
|
}
|