Merge branch 'maint-1.6.6' into maint
[tgit.git] / builtin-merge-ours.c
blob684411694f64ca216fb03430df2d2a0ec9ea93ff
1 /*
2 * Implementation of git-merge-ours.sh as builtin
4 * Copyright (c) 2007 Thomas Harning Jr
5 * Original:
6 * Original Copyright (c) 2005 Junio C Hamano
8 * Pretend we resolved the heads, but declare our tree trumps everybody else.
9 */
10 #include "git-compat-util.h"
11 #include "builtin.h"
13 static const char builtin_merge_ours_usage[] =
14 "git merge-ours <base>... -- HEAD <remote>...";
16 static const char *diff_index_args[] = {
17 "diff-index", "--quiet", "--cached", "HEAD", "--", NULL
19 #define NARGS (ARRAY_SIZE(diff_index_args) - 1)
21 int cmd_merge_ours(int argc, const char **argv, const char *prefix)
23 if (argc == 2 && !strcmp(argv[1], "-h"))
24 usage(builtin_merge_ours_usage);
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.
31 if (cmd_diff_index(NARGS, diff_index_args, prefix))
32 exit(2);
33 exit(0);