aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJohn Keeping <john@keeping.me.uk>2013-04-07 22:07:51 +0100
committerJunio C Hamano <gitster@pobox.com>2013-04-08 10:50:52 -0700
commitaacecc3b36a6cd4d2707e3f1cbd7bb4122477c64 (patch)
tree077c3536de6dc869f8de4f6e1bacd0d8bbef9990 /builtin
parent187c00c6c58ba8916a37011b56cb0cb8f2dd1805 (diff)
downloadgit-aacecc3b36a6cd4d2707e3f1cbd7bb4122477c64.tar.gz
git-aacecc3b36a6cd4d2707e3f1cbd7bb4122477c64.tar.xz
merge-tree: don't print entries that match "local"
The documentation says: the output from the command omits entries that match the <branch1> tree. But currently "added in branch1" and "removed in branch1" (both while unchanged in branch2) do print output. Change this so that the behaviour matches the documentation. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/merge-tree.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index bc912e399..ed25d81b8 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -155,6 +155,11 @@ static int same_entry(struct name_entry *a, struct name_entry *b)
a->mode == b->mode;
}
+static int both_empty(struct name_entry *a, struct name_entry *b)
+{
+ return !(a->sha1 || b->sha1);
+}
+
static struct merge_list *create_entry(unsigned stage, unsigned mode, const unsigned char *sha1, const char *path)
{
struct merge_list *res = xcalloc(1, sizeof(*res));
@@ -297,13 +302,10 @@ static void unresolved(const struct traverse_info *info, struct name_entry n[3])
static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *info)
{
/* Same in both? */
- if (same_entry(entry+1, entry+2)) {
- if (entry[0].sha1) {
- /* Modified identically */
- resolve(info, NULL, entry+1);
- return mask;
- }
- /* "Both added the same" is left unresolved */
+ if (same_entry(entry+1, entry+2) || both_empty(entry+0, entry+2)) {
+ /* Modified, added or removed identically */
+ resolve(info, NULL, entry+1);
+ return mask;
}
if (same_entry(entry+0, entry+1)) {
@@ -319,12 +321,10 @@ static int threeway_callback(int n, unsigned long mask, unsigned long dirmask, s
*/
}
- if (same_entry(entry+0, entry+2)) {
- if (entry[1].sha1 && !S_ISDIR(entry[1].mode)) {
- /* We modified, they did not touch -- take ours */
- resolve(info, NULL, entry+1);
- return mask;
- }
+ if (same_entry(entry+0, entry+2) || both_empty(entry+0, entry+2)) {
+ /* We added, modified or removed, they did not touch -- take ours */
+ resolve(info, NULL, entry+1);
+ return mask;
}
unresolved(info, entry);