{"thread":{"id":"4187","subject":"Make git-rev-list understand --tags/--branches/--remotes","startedAt":"2006-05-17T21:44:52Z","lastAt":"2006-05-17T21:44:52Z","messageCount":1,"participants":["Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"20188","messageId":"Pine.LNX.4.64.0605171439371.10823@g5.osdl.org","threadId":"4187","inReplyTo":null,"subject":"Make git-rev-list understand --tags/--branches/--remotes","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-05-17T21:44:52Z","receivedAt":"2006-05-17T21:44:52Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nWe shouldn't add stuff to git-rev-parse without teaching git-rev-list and \nall the other tools to do the same.\n\nIn fact, these days there is much less reason for git-rev-parse in the \nfirst place: it's usually used to verify a particular reference, or to \njust split the different argument types up from each other. Most tools \ndon't need or use it any more (eg \"gitk\" will just pass its arguments \ndirectly to git-rev-list).\n\nWith this, you can now do (for example)\n\n\tgitk HEAD --not --tags\n\nto see all the work on all the main branch that hasn't been included in a \ntagged version (replace HEAD with \"--branches\" to show all branches, of \ncourse).\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\n\ndiff --git a/revision.c b/revision.c\nindex 2294b16..1fc6725 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -470,11 +470,13 @@ static int handle_one_ref(const char *pa\n \treturn 0;\n }\n \n-static void handle_all(struct rev_info *revs, unsigned flags)\n+typedef int (*ref_fn_t)(int (*)(const char *, const unsigned char *));\n+\n+static void handle_ref(ref_fn_t fn, struct rev_info *revs, unsigned flags)\n {\n \tall_revs = revs;\n \tall_flags = flags;\n-\tfor_each_ref(handle_one_ref);\n+\tfn(handle_one_ref);\n }\n \n static int add_parents_only(struct rev_info *revs, const char *arg, int flags)\n@@ -614,7 +616,19 @@ int setup_revisions(int argc, const char\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--all\")) {\n-\t\t\t\thandle_all(revs, flags);\n+\t\t\t\thandle_ref(for_each_ref, revs, flags);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tif (!strcmp(arg, \"--branches\")) {\n+\t\t\t\thandle_ref(for_each_branch_ref, revs, flags);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tif (!strcmp(arg, \"--tags\")) {\n+\t\t\t\thandle_ref(for_each_tag_ref, revs, flags);\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\t\t\tif (!strcmp(arg, \"--remotes\")) {\n+\t\t\t\thandle_ref(for_each_remote_ref, revs, flags);\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--not\")) {\n"}]}