{"thread":{"id":"43537","subject":"[PATCH 2/2] Make left-right automatic.","startedAt":"2006-12-17T00:12:55Z","lastAt":"2006-12-17T00:12:55Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"295357","messageId":"7vlkl78jnc.fsf@assigned-by-dhcp.cox.net","threadId":"43537","inReplyTo":null,"subject":"[PATCH 2/2] Make left-right automatic.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-17T00:12:55Z","receivedAt":"2006-12-17T00:12:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When using symmetric differences, I think the user almost always\nwould want to know which side of the symmetry each commit came\nfrom.  So this removes --left-right option from the command\nline, and turns it on automatically when a symmetric difference\nis used (\"git log --merge\" counts as a symmetric difference\nbetween HEAD and MERGE_HEAD).\n\nJust in case, a new option --no-left-right is provided to defeat\nthis, but I do not know if it would be useful.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * I think this would make life easier for merge-heavy people.\n   I'd push this out on 'next' soonish.\n\n revision.c |   13 ++++++++++---\n revision.h |    1 +\n 2 files changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex d84f46e..56819f8 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -853,8 +853,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t\trevs->boundary = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (!strcmp(arg, \"--left-right\")) {\n-\t\t\t\trevs->left_right = 1;\n+\t\t\tif (!strcmp(arg, \"--no-left-right\")) {\n+\t\t\t\trevs->no_left_right = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(arg, \"--objects\")) {\n@@ -1055,13 +1055,18 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n void prepare_revision_walk(struct rev_info *revs)\n {\n \tint nr = revs->pending.nr;\n+\tint has_symmetric = 0;\n \tstruct object_array_entry *list = revs->pending.objects;\n \n \trevs->pending.nr = 0;\n \trevs->pending.alloc = 0;\n \trevs->pending.objects = NULL;\n \twhile (--nr >= 0) {\n-\t\tstruct commit *commit = handle_commit(revs, list->item, list->name);\n+\t\tstruct commit *commit;\n+\n+\t\tif (list->item->flags & SYMMETRIC_LEFT)\n+\t\t\thas_symmetric = 1;\n+\t\tcommit = handle_commit(revs, list->item, list->name);\n \t\tif (commit) {\n \t\t\tif (!(commit->object.flags & SEEN)) {\n \t\t\t\tcommit->object.flags |= SEEN;\n@@ -1073,6 +1078,8 @@ void prepare_revision_walk(struct rev_info *revs)\n \n \tif (revs->no_walk)\n \t\treturn;\n+\tif (!revs->no_left_right && has_symmetric)\n+\t\trevs->left_right = 1;\n \tif (revs->limited)\n \t\tlimit_list(revs);\n \tif (revs->topo_order)\ndiff --git a/revision.h b/revision.h\nindex 4585463..b2ab814 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -41,6 +41,7 @@ struct rev_info {\n \t\t\tlimited:1,\n \t\t\tunpacked:1, /* see also ignore_packed below */\n \t\t\tboundary:1,\n+\t\t\tno_left_right:1,\n \t\t\tleft_right:1,\n \t\t\tparents:1;\n \n-- \n1.4.4.2.g83c5\n\n"}]}