Merge branch 'js/msgfmt-on-windows' of ../git-gui into js/git-gui-msgfmt-on-windows
[git] / builtin / merge-ours.c
1 /*
2  * Implementation of git-merge-ours.sh as builtin
3  *
4  * Copyright (c) 2007 Thomas Harning Jr
5  * Original:
6  * Original Copyright (c) 2005 Junio C Hamano
7  *
8  * Pretend we resolved the heads, but declare our tree trumps everybody else.
9  */
10 #include "git-compat-util.h"
11 #include "builtin.h"
12
13 static const char builtin_merge_ours_usage[] =
14         "git merge-ours <base>... -- HEAD <remote>...";
15
16 static const char *diff_index_args[] = {
17         "diff-index", "--quiet", "--cached", "HEAD", "--", NULL
18 };
19 #define NARGS (ARRAY_SIZE(diff_index_args) - 1)
20
21 int cmd_merge_ours(int argc, const char **argv, const char *prefix)
22 {
23         if (argc == 2 && !strcmp(argv[1], "-h"))
24                 usage(builtin_merge_ours_usage);
25
26         /*
27          * We need to exit with 2 if the index does not match our HEAD tree,
28          * because the current index is what we will be committing as the
29          * merge result.
30          */
31         if (cmd_diff_index(NARGS, diff_index_args, prefix))
32                 exit(2);
33         exit(0);
34 }