{"thread":{"id":"32642","subject":"--simplify-merges returns too many references","startedAt":"2013-01-15T23:12:59Z","lastAt":"2013-01-17T22:23:03Z","messageCount":3,"participants":["Phil Hord","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"206989","messageId":"CABURp0q0nhka+ivrs3+m+3C1N+FfTq2zJ=1rWp34tfGNQ3b30g@mail.gmail.com","threadId":"32642","inReplyTo":null,"subject":"--simplify-merges returns too many references","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-01-15T23:12:59Z","receivedAt":"2013-01-15T23:12:59Z","isPatch":false,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"I thought I understood the intent of the various history\nsimplification switches, but maybe I am still confused.\n\nIn git.git, I see three commits which touch stripspace.c:\n\n$ git log  --oneline -- builtin/stripspace.c\n497215d Update documentation for stripspace\nc2857fb stripspace: fix outdated comment\n81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory\n\n\nWith --full-history and also with --dense, I see the same three commits:\n\n$ git log  --full-history --oneline -- builtin/stripspace.c\n497215d Update documentation for stripspace\nc2857fb stripspace: fix outdated comment\n81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory\n\n$ git log  --dense --oneline -- builtin/stripspace.c\n497215d Update documentation for stripspace\nc2857fb stripspace: fix outdated comment\n81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory\n\n\nBut with --simplify-merges, I see _more_ commits.\n\n$ git log  --simplify-merges --oneline -- builtin/stripspace.c\n634392b Add 'contrib/subtree/' from commit ...\n497215d Update documentation for stripspace\nc2857fb stripspace: fix outdated comment\n81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory\n610f043 Import branch 'git-p4' of git://repo.or.cz/fast-export\nb4d2b04 Merge git-gui\n0a8f4f0 Merge git://git.kernel.org/pub/scm/git/gitweb\n98e031f Merge git-tools repository under \"tools\" subdirectory\n5569bf9 Do a cross-project merge of Paul Mackerras' gitk visualizer\n\n\nNone of the \"new\" commits touches this file.  The man page suggests\nthat simplify-merges should result in fewer commits than full-history.\n\n\"       --simplify-merges\n       Additional option to --full-history to remove some needless merges from\n       the resulting history, as there are no selected commits contributing to\n       this merge.\"\n\n\nAm I confused or is git?\n\nPhil\n"},{"id":"206992","messageId":"7vk3re0zyt.fsf@alter.siamese.dyndns.org","threadId":"32642","inReplyTo":"CABURp0q0nhka+ivrs3+m+3C1N+FfTq2zJ=1rWp34tfGNQ3b30g@mail.gmail.com","subject":"Re: --simplify-merges returns too many references","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-15T23:48:58Z","receivedAt":"2013-01-15T23:48:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <phil.hord@gmail.com> writes:\n\n> But with --simplify-merges, I see _more_ commits.\n>\n> $ git log  --simplify-merges --oneline -- builtin/stripspace.c\n> 634392b Add 'contrib/subtree/' from commit ...\n\t> 497215d Update documentation for stripspace\n\t> c2857fb stripspace: fix outdated comment\n\t> 81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory\n> 610f043 Import branch 'git-p4' of git://repo.or.cz/fast-export\n> b4d2b04 Merge git-gui\n> 0a8f4f0 Merge git://git.kernel.org/pub/scm/git/gitweb\n> 98e031f Merge git-tools repository under \"tools\" subdirectory\n> 5569bf9 Do a cross-project merge of Paul Mackerras' gitk visualizer\n\nAfter indenting away what should be shown, I notice all these extra\nare merges without any common ancestors.\n\nJust an observation; I didn't think things through.\n"},{"id":"207176","messageId":"7va9s7tpo8.fsf_-_@alter.siamese.dyndns.org","threadId":"32642","inReplyTo":"7vk3re0zyt.fsf@alter.siamese.dyndns.org","subject":"[PATCH] simplify-merges: drop merge from irrelevant side branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-17T22:23:03Z","receivedAt":"2013-01-17T22:23:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The merge simplification rule stated in 6546b59 (revision traversal:\nshow full history with merge simplification, 2008-07-31) still\ntreated merge commits too specially.  Namely, in a history with this\nshape:\n\n\t---o---o---M\n\t          /\n         x---x---x\n\nwhere three 'x' were on a history completely unrelated to the main\nhistory 'o' and do not touch any of the paths we are following, we\nstill said that after simplifying all of the parents of M, 'x'\n(which is the leftmost 'x' that rightmost 'x simplifies down to) and\n'o' (which would be the last commit on the main history that touches\nthe paths we are following) are independent from each other, and\nboth need to be kept.\n\nThat is incorrect; when the side branch 'x' never touches the paths,\nit should be removed to allow M to simplify down to the last commit\non the main history that touches the paths.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * The old test vector had a history ending at I; the updates to it\n   adds an unrelated side branch rooted at J, merge of I and J which\n   is K, and then an extra commit L on top.\n\n\tA---(some merge mess)---I---K---L\n                                   /\n                                  J\n\n revision.c                   | 19 +++++++++++++++++++\n t/t6012-rev-list-simplify.sh | 26 +++++++++++++++++++++-----\n 2 files changed, 40 insertions(+), 5 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 33cb207..532611b 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1424,6 +1424,22 @@ static struct merge_simplify_state *locate_simplify_state(struct rev_info *revs,\n \treturn st;\n }\n \n+static void remove_treesame_parents(struct commit *commit)\n+{\n+\tstruct commit_list **pp, *p;\n+\n+\tpp = &commit->parents;\n+\twhile ((p = *pp) != NULL) {\n+\t\tstruct commit *parent = p->item;\n+\t\tif (parent->object.flags & TREESAME) {\n+\t\t\t*pp = p->next;\n+\t\t\tfree(p);\n+\t\t\tcontinue;\n+\t\t}\n+\t\tpp = &p->next;\n+\t}\n+}\n+\n static struct commit_list **simplify_one(struct rev_info *revs, struct commit *commit, struct commit_list **tail)\n {\n \tstruct commit_list *p;\n@@ -1469,6 +1485,9 @@ static struct commit_list **simplify_one(struct rev_info *revs, struct commit *c\n \t\tpst = locate_simplify_state(revs, p->item);\n \t\tp->item = pst->simplified;\n \t}\n+\n+\tremove_treesame_parents(commit);\n+\n \tcnt = remove_duplicate_parents(commit);\n \n \t/*\ndiff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh\nindex 510bb96..d6d79c4 100755\n--- a/t/t6012-rev-list-simplify.sh\n+++ b/t/t6012-rev-list-simplify.sh\n@@ -59,7 +59,23 @@ test_expect_success setup '\n \n \techo \"Final change\" >file &&\n \ttest_tick && git commit -a -m \"Final change\" &&\n-\tnote I\n+\tnote I &&\n+\n+\tgit symbolic-ref HEAD refs/heads/unrelated &&\n+\tgit rm -f \"*\" &&\n+\techo \"Unrelated branch\" >side &&\n+\tgit add side &&\n+\ttest_tick && git commit -m \"Side root\" &&\n+\tnote J &&\n+\n+\tgit checkout master &&\n+\ttest_tick && git merge -m \"Coolest\" unrelated &&\n+\tnote K &&\n+\n+\techo \"Immaterial\" >elif &&\n+\tgit add elif &&\n+\ttest_tick && git commit -m \"Last\" &&\n+\tnote L\n '\n \n FMT='tformat:%P \t%H | %s'\n@@ -82,10 +98,10 @@ check_result () {\n \t'\n }\n \n-check_result 'I H G F E D C B A' --full-history\n-check_result 'I H E C B A' --full-history -- file\n-check_result 'I H E C B A' --full-history --topo-order -- file\n-check_result 'I H E C B A' --full-history --date-order -- file\n+check_result 'L K J I H G F E D C B A' --full-history\n+check_result 'K I H E C B A' --full-history -- file\n+check_result 'K I H E C B A' --full-history --topo-order -- file\n+check_result 'K I H E C B A' --full-history --date-order -- file\n check_result 'I E C B A' --simplify-merges -- file\n check_result 'I B A' -- file\n check_result 'I B A' --topo-order -- file\n-- \n1.8.1.1.431.g469ab37\n"}]}