git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Comment diff_tree

From
APAndy Parkins <andyparkins@gmail.com>
Date
Dec 11, 2006, 22:13 UTC
Message-ID
<200612112213.06547.andyparkins@gmail.com>
In-Reply-To
<f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com>
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 tree-diff.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
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
Previous: Andy ParkinsNext: Andy Parkins
Message 2 of 3 in “Comment -p mode for cat-file”
  1. Comment -p mode for cat-fileAndy Parkins, Dec 11, 2006
  2. Comment diff_treeAndy Parkins, Dec 11, 2006
  3. Add comments to update_tree_entry()Andy Parkins, Dec 11, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.