2018-03-24 07:44:45 +00:00
|
|
|
#include "test-tool.h"
|
2023-02-24 00:09:27 +00:00
|
|
|
#include "hex.h"
|
2023-04-22 20:17:15 +00:00
|
|
|
#include "match-trees.h"
|
2023-04-11 07:41:49 +00:00
|
|
|
#include "object-name.h"
|
2023-04-22 20:17:20 +00:00
|
|
|
#include "repository.h"
|
2023-03-21 06:26:05 +00:00
|
|
|
#include "setup.h"
|
2007-02-16 00:32:45 +00:00
|
|
|
#include "tree.h"
|
|
|
|
|
2023-03-28 20:57:25 +00:00
|
|
|
int cmd__match_trees(int ac UNUSED, const char **av)
|
2007-02-16 00:32:45 +00:00
|
|
|
{
|
2016-04-17 23:10:37 +00:00
|
|
|
struct object_id hash1, hash2, shifted;
|
2007-02-16 00:32:45 +00:00
|
|
|
struct tree *one, *two;
|
|
|
|
|
2016-03-05 22:16:50 +00:00
|
|
|
setup_git_directory();
|
|
|
|
|
2023-03-28 13:58:46 +00:00
|
|
|
if (repo_get_oid(the_repository, av[1], &hash1))
|
2007-02-16 00:32:45 +00:00
|
|
|
die("cannot parse %s as an object name", av[1]);
|
2023-03-28 13:58:46 +00:00
|
|
|
if (repo_get_oid(the_repository, av[2], &hash2))
|
2007-02-16 00:32:45 +00:00
|
|
|
die("cannot parse %s as an object name", av[2]);
|
2017-05-06 22:10:37 +00:00
|
|
|
one = parse_tree_indirect(&hash1);
|
2007-02-16 00:32:45 +00:00
|
|
|
if (!one)
|
2013-09-04 19:04:30 +00:00
|
|
|
die("not a tree-ish %s", av[1]);
|
2017-05-06 22:10:37 +00:00
|
|
|
two = parse_tree_indirect(&hash2);
|
2007-02-16 00:32:45 +00:00
|
|
|
if (!two)
|
2013-09-04 19:04:30 +00:00
|
|
|
die("not a tree-ish %s", av[2]);
|
2007-02-16 00:32:45 +00:00
|
|
|
|
2019-06-27 09:28:51 +00:00
|
|
|
shift_tree(the_repository, &one->object.oid, &two->object.oid, &shifted, -1);
|
2016-04-17 23:10:37 +00:00
|
|
|
printf("shifted: %s\n", oid_to_hex(&shifted));
|
2007-02-16 00:32:45 +00:00
|
|
|
|
2021-06-08 10:48:03 +00:00
|
|
|
return 0;
|
2007-02-16 00:32:45 +00:00
|
|
|
}
|