[PATCH] Comment diff_tree
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
tree-diff.c | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
Show changes to tree-diff.c +14 −3
diff --git a/tree-diff.c b/tree-diff.c
index 37d235e..009dd17 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -160,33 +160,44 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree
int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)
{
+ /* While there are entries left in t1 or t2... */
while (t1->size | t2->size) {
if (opt->nr_paths && t1->size && !interesting(t1, base, opt)) {
+ /* If there are paths left in t1, and the current path is
+ * not interesting, skip it and try the next path in t1 */
update_tree_entry(t1);
continue;
}
if (opt->nr_paths && t2->size && !interesting(t2, base, opt)) {
+ /* If there are paths left in t2, and the current path is
+ * not interesting, skip it and try the next path in t2 */
update_tree_entry(t2);
continue;
}
+ /* Here if either
+ * - Either t1 or t2 path is available and interesting
+ * - No paths available */
if (!t1->size) {
+ /* If there is no path left in t1, then t2 is a new path */
show_entry(opt, "+", t2, base);
update_tree_entry(t2);
continue;
}
if (!t2->size) {
+ /* If there is no path left in t2, then t1 is a remed path */
show_entry(opt, "-", t1, base);
update_tree_entry(t1);
continue;
}
+ /* If both paths are available and interesting then it is a change */
switch (compare_tree_entry(t1, t2, base, opt)) {
- case -1:
+ case -1: /* Finished with the path in t1 */
update_tree_entry(t1);
continue;
- case 0:
+ case 0: /* Finished with both paths */
update_tree_entry(t1);
/* Fallthrough */
- case 1:
+ case 1: /* Finished with the path in t2 */
update_tree_entry(t2);
continue;
}
--
1.4.4.1.geeee8