i18n: do not leak 'encoding' header even when we cheat the conversion.
[git/git-svn.git] / merge-base.c
blob385f4ba386ada3e43f962d9051cf4b651320fcd3
1 #include "cache.h"
2 #include "commit.h"
4 static int show_all;
6 static int merge_base(struct commit *rev1, struct commit *rev2)
8 struct commit_list *result = get_merge_bases(rev1, rev2, 0);
10 if (!result)
11 return 1;
13 while (result) {
14 printf("%s\n", sha1_to_hex(result->item->object.sha1));
15 if (!show_all)
16 return 0;
17 result = result->next;
20 return 0;
23 static const char merge_base_usage[] =
24 "git-merge-base [--all] <commit-id> <commit-id>";
26 int main(int argc, char **argv)
28 struct commit *rev1, *rev2;
29 unsigned char rev1key[20], rev2key[20];
31 setup_git_directory();
32 git_config(git_default_config);
34 while (1 < argc && argv[1][0] == '-') {
35 char *arg = argv[1];
36 if (!strcmp(arg, "-a") || !strcmp(arg, "--all"))
37 show_all = 1;
38 else
39 usage(merge_base_usage);
40 argc--; argv++;
42 if (argc != 3)
43 usage(merge_base_usage);
44 if (get_sha1(argv[1], rev1key))
45 die("Not a valid object name %s", argv[1]);
46 if (get_sha1(argv[2], rev2key))
47 die("Not a valid object name %s", argv[2]);
48 rev1 = lookup_commit_reference(rev1key);
49 rev2 = lookup_commit_reference(rev2key);
50 if (!rev1 || !rev2)
51 return 1;
52 return merge_base(rev1, rev2);