summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 730f728)
raw | patch | inline | side by side (parent: 730f728)
author | Junio C Hamano <gitster@pobox.com> | |
Mon, 14 Sep 2009 09:22:00 +0000 (02:22 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 7 Jan 2010 23:00:14 +0000 (15:00 -0800) |
A debugging patch.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-read-tree.c | patch | blob | history | |
unpack-trees.c | patch | blob | history | |
unpack-trees.h | patch | blob | history |
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 2a3a32cbfe83a0e0366d04a99bb49606f647f594..0c1f40d10d1846bb187f691ad16d6ed24cc7aa8d 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
return 0;
}
+static void debug_stage(const char *label, struct cache_entry *ce,
+ struct unpack_trees_options *o)
+{
+ printf("%s ", label);
+ if (!ce)
+ printf("(missing)\n");
+ else if (ce == o->df_conflict_entry)
+ printf("(conflict)\n");
+ else
+ printf("%06o #%d %s %.8s\n",
+ ce->ce_mode, ce_stage(ce), ce->name,
+ sha1_to_hex(ce->sha1));
+}
+
+static int debug_merge(struct cache_entry **stages, struct unpack_trees_options *o)
+{
+ int i;
+
+ printf("* %d-way merge\n", o->merge_size);
+ debug_stage("index", stages[0], o);
+ for (i = 1; i <= o->merge_size; i++) {
+ char buf[24];
+ sprintf(buf, "ent#%d", i);
+ debug_stage(buf, stages[i], o);
+ }
+ return 0;
+}
+
static struct lock_file lock_file;
int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
PARSE_OPT_NONEG, exclude_per_directory_cb },
OPT_SET_INT('i', NULL, &opts.index_only,
"don't check the working tree after merging", 1),
+ OPT_SET_INT(0, "debug-unpack", &opts.debug_unpack,
+ "debug unpack-trees", 1),
OPT_END()
};
opts.head_idx = 1;
}
+ if (opts.debug_unpack)
+ opts.fn = debug_merge;
+
cache_tree_free(&active_cache_tree);
for (i = 0; i < nr_trees; i++) {
struct tree *tree = trees[i];
if (unpack_trees(nr_trees, t, &opts))
return 128;
+ if (opts.debug_unpack)
+ return 0; /* do not write the index out */
+
/*
* When reading only one tree (either the most basic form,
* "-m ent" or "--reset ent" form), we can obtain a fully
diff --git a/unpack-trees.c b/unpack-trees.c
index 74cabc36ff09255819558c38b25a38a4e6871418..10e8871a747b0a9519b2397f150517ec671e7ee6 100644 (file)
--- a/unpack-trees.c
+++ b/unpack-trees.c
return NULL;
}
+static void debug_path(struct traverse_info *info)
+{
+ if (info->prev) {
+ debug_path(info->prev);
+ if (*info->prev->name.path)
+ putchar('/');
+ }
+ printf("%s", info->name.path);
+}
+
+static void debug_name_entry(int i, struct name_entry *n)
+{
+ printf("ent#%d %06o %s\n", i,
+ n->path ? n->mode : 0,
+ n->path ? n->path : "(missing)");
+}
+
+static void debug_unpack_callback(int n,
+ unsigned long mask,
+ unsigned long dirmask,
+ struct name_entry *names,
+ struct traverse_info *info)
+{
+ int i;
+ printf("* unpack mask %lu, dirmask %lu, cnt %d ",
+ mask, dirmask, n);
+ debug_path(info);
+ putchar('\n');
+ for (i = 0; i < n; i++)
+ debug_name_entry(i, names + i);
+}
+
static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
{
struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
@@ -511,6 +543,9 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
while (!p->mode)
p++;
+ if (o->debug_unpack)
+ debug_unpack_callback(n, mask, dirmask, names, info);
+
/* Are we supposed to look at the index too? */
if (o->merge) {
while (1) {
diff --git a/unpack-trees.h b/unpack-trees.h
index 9a0733ea8545efd33e1d608255612080afc670e7..701dca59a8e828cae78c394783ff8d6f8404a5f1 100644 (file)
--- a/unpack-trees.h
+++ b/unpack-trees.h
skip_unmerged,
initial_checkout,
diff_index_cached,
+ debug_unpack,
gently;
const char *prefix;
int cache_bottom;