Coverage Report

Created: 2024-09-08 06:23

/src/git/builtin/merge-ours.c
Line
Count
Source (jump to first uncovered line)
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
#include "diff.h"
13
#include "repository.h"
14
15
static const char builtin_merge_ours_usage[] =
16
  "git merge-ours <base>... -- HEAD <remote>...";
17
18
int cmd_merge_ours(int argc, const char **argv, const char *prefix UNUSED)
19
0
{
20
0
  if (argc == 2 && !strcmp(argv[1], "-h"))
21
0
    usage(builtin_merge_ours_usage);
22
23
  /*
24
   * The contents of the current index becomes the tree we
25
   * commit.  The index must match HEAD, or this merge cannot go
26
   * through.
27
   */
28
0
  if (repo_read_index(the_repository) < 0)
29
0
    die_errno("read_cache failed");
30
0
  if (index_differs_from(the_repository, "HEAD", NULL, 0))
31
0
    return 2;
32
0
  return 0;
33
0
}