shallow: fix leak when unregistering last shallow root
[alt-git.git] / builtin / merge-ours.c
blob1fcf53f0054e94e413aedd062189e3bc57079dcf
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 #define USE_THE_REPOSITORY_VARIABLE
11 #include "git-compat-util.h"
12 #include "builtin.h"
13 #include "diff.h"
16 static const char builtin_merge_ours_usage[] =
17 "git merge-ours <base>... -- HEAD <remote>...";
19 int cmd_merge_ours(int argc,
20 const char **argv,
21 const char *prefix UNUSED,
22 struct repository *repo UNUSED)
24 if (argc == 2 && !strcmp(argv[1], "-h"))
25 usage(builtin_merge_ours_usage);
28 * The contents of the current index becomes the tree we
29 * commit. The index must match HEAD, or this merge cannot go
30 * through.
32 if (repo_read_index(the_repository) < 0)
33 die_errno("read_cache failed");
34 if (index_differs_from(the_repository, "HEAD", NULL, 0))
35 return 2;
36 return 0;