{"thread":{"id":"43375","subject":"[PATCH] Comment -p mode for cat-file","startedAt":"2006-12-11T22:13:00Z","lastAt":"2006-12-11T22:13:11Z","messageCount":3,"participants":["Andy Parkins"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"294550","messageId":"200612112213.00737.andyparkins@gmail.com","threadId":"43375","inReplyTo":"f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com","subject":"[PATCH] Comment -p mode for cat-file","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-11T22:13:00Z","receivedAt":"2006-12-11T22:13:00Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n builtin-cat-file.c |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-cat-file.c b/builtin-cat-file.c\nindex 6c16bfa..e7997ee 100644\n--- a/builtin-cat-file.c\n+++ b/builtin-cat-file.c\n@@ -121,12 +121,16 @@ int cmd_cat_file(int argc, const char **argv, const char *prefix)\n \t\t\tdie(\"Not a valid object name %s\", argv[2]);\n \n \t\t/* custom pretty-print here */\n+\t\t/* Special print tree types using ls-tree\n+\t\t *  git-ls-tree argv[1] */\n \t\tif (!strcmp(type, tree_type))\n \t\t\treturn cmd_ls_tree(2, argv + 1, NULL);\n \n+\t\t/* For everything else, read the object itself */\n \t\tbuf = read_sha1_file(sha1, type, &size);\n \t\tif (!buf)\n \t\t\tdie(\"Cannot read object %s\", argv[2]);\n+\t\t/* if the object is a tag, use pprint_tag() above */\n \t\tif (!strcmp(type, tag_type)) {\n \t\t\tpprint_tag(sha1, buf, size);\n \t\t\treturn 0;\n-- \n1.4.4.1.geeee8\n"},{"id":"296109","messageId":"200612112213.06547.andyparkins@gmail.com","threadId":"43375","inReplyTo":"f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com","subject":"[PATCH] Comment diff_tree","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-11T22:13:06Z","receivedAt":"2006-12-11T22:13:06Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n tree-diff.c |   17 ++++++++++++++---\n 1 files changed, 14 insertions(+), 3 deletions(-)\n\ndiff --git a/tree-diff.c b/tree-diff.c\nindex 37d235e..009dd17 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -160,33 +160,44 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree\n \n int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)\n {\n+\t/* While there are entries left in t1 or t2... */\n \twhile (t1->size | t2->size) {\n \t\tif (opt->nr_paths && t1->size && !interesting(t1, base, opt)) {\n+\t\t\t/* If there are paths left in t1, and the current path is\n+\t\t\t * not interesting, skip it and try the next path in t1 */\n \t\t\tupdate_tree_entry(t1);\n \t\t\tcontinue;\n \t\t}\n \t\tif (opt->nr_paths && t2->size && !interesting(t2, base, opt)) {\n+\t\t\t/* If there are paths left in t2, and the current path is\n+\t\t\t * not interesting, skip it and try the next path in t2 */\n \t\t\tupdate_tree_entry(t2);\n \t\t\tcontinue;\n \t\t}\n+\t\t/* Here if either\n+\t\t *  - Either t1 or t2 path is available and interesting\n+\t\t *  - No paths available */\n \t\tif (!t1->size) {\n+\t\t\t/* If there is no path left in t1, then t2 is a new path */\n \t\t\tshow_entry(opt, \"+\", t2, base);\n \t\t\tupdate_tree_entry(t2);\n \t\t\tcontinue;\n \t\t}\n \t\tif (!t2->size) {\n+\t\t\t/* If there is no path left in t2, then t1 is a remed path */\n \t\t\tshow_entry(opt, \"-\", t1, base);\n \t\t\tupdate_tree_entry(t1);\n \t\t\tcontinue;\n \t\t}\n+\t\t/* If both paths are available and interesting then it is a change */\n \t\tswitch (compare_tree_entry(t1, t2, base, opt)) {\n-\t\tcase -1:\n+\t\tcase -1: /* Finished with the path in t1 */\n \t\t\tupdate_tree_entry(t1);\n \t\t\tcontinue;\n-\t\tcase 0:\n+\t\tcase 0:  /* Finished with both paths */\n \t\t\tupdate_tree_entry(t1);\n \t\t\t/* Fallthrough */\n-\t\tcase 1:\n+\t\tcase 1: /* Finished with the path in t2 */\n \t\t\tupdate_tree_entry(t2);\n \t\t\tcontinue;\n \t\t}\n-- \n1.4.4.1.geeee8\n\n"},{"id":"296982","messageId":"200612112213.11829.andyparkins@gmail.com","threadId":"43375","inReplyTo":"f323e83a37efd3b913004666f2fc104578a92833.1165875140.git.andyparkins@gmail.com","subject":"[PATCH] Add comments to update_tree_entry()","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-12-11T22:13:11Z","receivedAt":"2006-12-11T22:13:11Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n tree-walk.c |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/tree-walk.c b/tree-walk.c\nindex 14cc5ae..5363366 100644\n--- a/tree-walk.c\n+++ b/tree-walk.c\n@@ -37,6 +37,11 @@ static void entry_extract(struct tree_desc *t, struct name_entry *a)\n \n void update_tree_entry(struct tree_desc *desc)\n {\n+\t/* Each tree is represented by a buffer containing hashes followed\n+\t * by space followed by filename; separated with NUL.  To move to the\n+\t * next entry we simply move forward by strlen() (which skips the filename)\n+\t * then skip the hash and the space. */\n+\t/* This function should really be called skip_tree_entry() */\n \tconst void *buf = desc->buf;\n \tunsigned long size = desc->size;\n \tint len = strlen(buf) + 1 + 20;\n-- \n1.4.4.1.geeee8\n\n"}]}