git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Comment -p mode for cat-file
       [not found] <f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com>
@ 2006-12-11 22:13 ` Andy Parkins
  2006-12-11 22:13 ` [PATCH] Comment diff_tree Andy Parkins
  2006-12-11 22:13 ` [PATCH] Add comments to update_tree_entry() Andy Parkins
  2 siblings, 0 replies; 3+ messages in thread
From: Andy Parkins @ 2006-12-11 22:13 UTC (permalink / raw)
  To: git

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 builtin-cat-file.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin-cat-file.c b/builtin-cat-file.c
index 6c16bfa..e7997ee 100644
--- a/builtin-cat-file.c
+++ b/builtin-cat-file.c
@@ -121,12 +121,16 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)
 			die("Not a valid object name %s", argv[2]);
 
 		/* custom pretty-print here */
+		/* Special print tree types using ls-tree
+		 *  git-ls-tree argv[1] */
 		if (!strcmp(type, tree_type))
 			return cmd_ls_tree(2, argv + 1, NULL);
 
+		/* For everything else, read the object itself */
 		buf = read_sha1_file(sha1, type, &size);
 		if (!buf)
 			die("Cannot read object %s", argv[2]);
+		/* if the object is a tag, use pprint_tag() above */
 		if (!strcmp(type, tag_type)) {
 			pprint_tag(sha1, buf, size);
 			return 0;
-- 
1.4.4.1.geeee8

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] Comment diff_tree
       [not found] <f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com>
  2006-12-11 22:13 ` [PATCH] Comment -p mode for cat-file Andy Parkins
@ 2006-12-11 22:13 ` Andy Parkins
  2006-12-11 22:13 ` [PATCH] Add comments to update_tree_entry() Andy Parkins
  2 siblings, 0 replies; 3+ messages in thread
From: Andy Parkins @ 2006-12-11 22:13 UTC (permalink / raw)
  To: git

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] Add comments to update_tree_entry()
       [not found] <f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com>
  2006-12-11 22:13 ` [PATCH] Comment -p mode for cat-file Andy Parkins
  2006-12-11 22:13 ` [PATCH] Comment diff_tree Andy Parkins
@ 2006-12-11 22:13 ` Andy Parkins
  2 siblings, 0 replies; 3+ messages in thread
From: Andy Parkins @ 2006-12-11 22:13 UTC (permalink / raw)
  To: git

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 tree-walk.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/tree-walk.c b/tree-walk.c
index 14cc5ae..5363366 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -37,6 +37,11 @@ static void entry_extract(struct tree_desc *t, struct name_entry *a)
 
 void update_tree_entry(struct tree_desc *desc)
 {
+	/* Each tree is represented by a buffer containing hashes followed
+	 * by space followed by filename; separated with NUL.  To move to the
+	 * next entry we simply move forward by strlen() (which skips the filename)
+	 * then skip the hash and the space. */
+	/* This function should really be called skip_tree_entry() */
 	const void *buf = desc->buf;
 	unsigned long size = desc->size;
 	int len = strlen(buf) + 1 + 20;
-- 
1.4.4.1.geeee8


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-12-11 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com>
2006-12-11 22:13 ` [PATCH] Comment -p mode for cat-file Andy Parkins
2006-12-11 22:13 ` [PATCH] Comment diff_tree Andy Parkins
2006-12-11 22:13 ` [PATCH] Add comments to update_tree_entry() Andy Parkins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).