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