interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / builtin / merge-ours.c

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