summaryrefslogtreecommitdiff
path: root/builtin/merge-ours.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-03-10 23:25:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-10 23:25:18 (GMT)
commit2e0e8b68e3ba8ea87f001c45c78f9b7ce549c61f (patch)
tree12363fe88e40f042c24583e829a696505fcb9b7c /builtin/merge-ours.c
parente007240cb940811a6e075d35f5c3a93a44c54f5a (diff)
parent81b50f3ce40bfdd66e5d967bf82be001039a9a98 (diff)
downloadgit-2e0e8b68e3ba8ea87f001c45c78f9b7ce549c61f.zip
git-2e0e8b68e3ba8ea87f001c45c78f9b7ce549c61f.tar.gz
git-2e0e8b68e3ba8ea87f001c45c78f9b7ce549c61f.tar.bz2
Merge branch 'lt/deepen-builtin-source'
* lt/deepen-builtin-source: Move 'builtin-*' into a 'builtin/' subdirectory Conflicts: Makefile
Diffstat (limited to 'builtin/merge-ours.c')
-rw-r--r--builtin/merge-ours.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
new file mode 100644
index 0000000..6844116
--- /dev/null
+++ b/builtin/merge-ours.c
@@ -0,0 +1,34 @@
+/*
+ * Implementation of git-merge-ours.sh as builtin
+ *
+ * Copyright (c) 2007 Thomas Harning Jr
+ * Original:
+ * Original Copyright (c) 2005 Junio C Hamano
+ *
+ * Pretend we resolved the heads, but declare our tree trumps everybody else.
+ */
+#include "git-compat-util.h"
+#include "builtin.h"
+
+static const char builtin_merge_ours_usage[] =
+ "git merge-ours <base>... -- HEAD <remote>...";
+
+static const char *diff_index_args[] = {
+ "diff-index", "--quiet", "--cached", "HEAD", "--", NULL
+};
+#define NARGS (ARRAY_SIZE(diff_index_args) - 1)
+
+int cmd_merge_ours(int argc, const char **argv, const char *prefix)
+{
+ if (argc == 2 && !strcmp(argv[1], "-h"))
+ usage(builtin_merge_ours_usage);
+
+ /*
+ * We need to exit with 2 if the index does not match our HEAD tree,
+ * because the current index is what we will be committing as the
+ * merge result.
+ */
+ if (cmd_diff_index(NARGS, diff_index_args, prefix))
+ exit(2);
+ exit(0);
+}