[PATCH] Add debugging help for case #16 to read-tree.c
This will help us detect if real-world example merges have multiple merge-base candidates and one of them matches one head while another matches the other head. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
2ab706a38f
commit
4d3fe0c5f3
36
read-tree.c
36
read-tree.c
@ -3,6 +3,8 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) Linus Torvalds, 2005
|
* Copyright (C) Linus Torvalds, 2005
|
||||||
*/
|
*/
|
||||||
|
#define DBRT_DEBUG 1
|
||||||
|
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
|
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
@ -47,8 +49,6 @@ static int entcmp(char *name1, int dir1, char *name2, int dir2)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DBRT_DEBUG 0
|
|
||||||
|
|
||||||
static int unpack_trees_rec(struct tree_entry_list **posns, int len,
|
static int unpack_trees_rec(struct tree_entry_list **posns, int len,
|
||||||
const char *base, merge_fn_t fn, int *indpos)
|
const char *base, merge_fn_t fn, int *indpos)
|
||||||
{
|
{
|
||||||
@ -101,14 +101,14 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DBRT_DEBUG
|
#if DBRT_DEBUG > 1
|
||||||
if (first)
|
if (first)
|
||||||
printf("index %s\n", first);
|
printf("index %s\n", first);
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
if (!posns[i] || posns[i] == &df_conflict_list)
|
if (!posns[i] || posns[i] == &df_conflict_list)
|
||||||
continue;
|
continue;
|
||||||
#if DBRT_DEBUG
|
#if DBRT_DEBUG > 1
|
||||||
printf("%d %s\n", i + 1, posns[i]->name);
|
printf("%d %s\n", i + 1, posns[i]->name);
|
||||||
#endif
|
#endif
|
||||||
if (!first || entcmp(first, firstdir,
|
if (!first || entcmp(first, firstdir,
|
||||||
@ -188,7 +188,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
|
|||||||
if (merge) {
|
if (merge) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#if DBRT_DEBUG
|
#if DBRT_DEBUG > 1
|
||||||
printf("%s:\n", first);
|
printf("%s:\n", first);
|
||||||
for (i = 0; i < src_size; i++) {
|
for (i = 0; i < src_size; i++) {
|
||||||
printf(" %d ", i);
|
printf(" %d ", i);
|
||||||
@ -200,7 +200,7 @@ static int unpack_trees_rec(struct tree_entry_list **posns, int len,
|
|||||||
#endif
|
#endif
|
||||||
ret = fn(src);
|
ret = fn(src);
|
||||||
|
|
||||||
#if DBRT_DEBUG
|
#if DBRT_DEBUG > 1
|
||||||
printf("Added %d entries\n", ret);
|
printf("Added %d entries\n", ret);
|
||||||
#endif
|
#endif
|
||||||
*indpos += ret;
|
*indpos += ret;
|
||||||
@ -353,6 +353,19 @@ static int keep_entry(struct cache_entry *ce)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DBRT_DEBUG
|
||||||
|
static void show_stage_entry(FILE *o,
|
||||||
|
const char *label, const struct cache_entry *ce)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s%06o %s %d\t%s\n",
|
||||||
|
label,
|
||||||
|
ntohl(ce->ce_mode),
|
||||||
|
sha1_to_hex(ce->sha1),
|
||||||
|
ce_stage(ce),
|
||||||
|
ce->name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int threeway_merge(struct cache_entry **stages)
|
static int threeway_merge(struct cache_entry **stages)
|
||||||
{
|
{
|
||||||
struct cache_entry *index;
|
struct cache_entry *index;
|
||||||
@ -392,10 +405,10 @@ static int threeway_merge(struct cache_entry **stages)
|
|||||||
if (!same(remote, head)) {
|
if (!same(remote, head)) {
|
||||||
for (i = 1; i < head_idx; i++) {
|
for (i = 1; i < head_idx; i++) {
|
||||||
if (same(stages[i], head)) {
|
if (same(stages[i], head)) {
|
||||||
head_match = 1;
|
head_match = i;
|
||||||
}
|
}
|
||||||
if (same(stages[i], remote)) {
|
if (same(stages[i], remote)) {
|
||||||
remote_match = 1;
|
remote_match = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,6 +463,13 @@ static int threeway_merge(struct cache_entry **stages)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if DBRT_DEBUG
|
||||||
|
else {
|
||||||
|
fprintf(stderr, "read-tree: warning #16 detected\n");
|
||||||
|
show_stage_entry(stderr, "head ", stages[head_match]);
|
||||||
|
show_stage_entry(stderr, "remote ", stages[remote_match]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (head) { count += keep_entry(head); }
|
if (head) { count += keep_entry(head); }
|
||||||
if (remote) { count += keep_entry(remote); }
|
if (remote) { count += keep_entry(remote); }
|
||||||
return count;
|
return count;
|
||||||
|
@ -218,6 +218,9 @@ currently implemented.
|
|||||||
or (2) match B.
|
or (2) match B.
|
||||||
------------------------------------------------------------------
|
------------------------------------------------------------------
|
||||||
15 exists O==A O==B take B must match A if exists.
|
15 exists O==A O==B take B must match A if exists.
|
||||||
|
------------------------------------------------------------------
|
||||||
|
16 exists O==A O==B barf must match A if exists.
|
||||||
|
*multi* in one in another
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
Note: if we want to implement 2ALT and 3ALT we need to be careful.
|
Note: if we want to implement 2ALT and 3ALT we need to be careful.
|
||||||
@ -514,4 +517,17 @@ test_expect_failure \
|
|||||||
git-update-index --add NN &&
|
git-update-index --add NN &&
|
||||||
git-read-tree -m $tree_O $tree_A $tree_B"
|
git-read-tree -m $tree_O $tree_A $tree_B"
|
||||||
|
|
||||||
|
# #16
|
||||||
|
test_expect_success \
|
||||||
|
'16 - A matches in one and B matches in another.' \
|
||||||
|
'rm -f .git/index F16 &&
|
||||||
|
echo F16 >F16 &&
|
||||||
|
git-update-index --add F16 &&
|
||||||
|
tree0=`git-write-tree` &&
|
||||||
|
echo E16 >F16 &&
|
||||||
|
git-update-index F16 &&
|
||||||
|
tree1=`git-write-tree` &&
|
||||||
|
git-read-tree -m $tree0 $tree1 $tree1 $tree0 &&
|
||||||
|
git-ls-files --stage'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Loading…
Reference in New Issue
Block a user