Git fork
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
11#define USE_THE_REPOSITORY_VARIABLE
12
13#include "git-compat-util.h"
14#include "builtin.h"
15#include "diff.h"
16
17
18static const char builtin_merge_ours_usage[] =
19 "git merge-ours <base>... -- HEAD <remote>...";
20
21int cmd_merge_ours(int argc,
22 const char **argv,
23 const char *prefix UNUSED,
24 struct repository *repo UNUSED)
25{
26 show_usage_if_asked(argc, argv, builtin_merge_ours_usage);
27
28 /*
29 * The contents of the current index becomes the tree we
30 * commit. The index must match HEAD, or this merge cannot go
31 * through.
32 */
33 if (repo_read_index(the_repository) < 0)
34 die_errno("read_cache failed");
35 if (index_differs_from(the_repository, "HEAD", NULL, 0))
36 return 2;
37 return 0;
38}