{"thread":{"id":"13025","subject":"[PATCH] Add --only-merges flag to display only merge commits.","startedAt":"2008-04-08T20:36:48Z","lastAt":"2008-04-09T20:38:46Z","messageCount":7,"participants":["Miklos Vajna","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"73875","messageId":"20080408203648.GS11574@genesis.frugalware.org","threadId":"13025","inReplyTo":null,"subject":"[PATCH] Add --only-merges flag to display only merge commits.","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-04-08T20:36:48Z","receivedAt":"2008-04-08T20:36:48Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"This is the opposite of git-rev-list --no-merges: It will hide commits\nwith single or no parent.\n\nIt is useful if a maintainer has a lot of commits between tags and\nusually each feature is developed in its own topic branch.\n\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nI just wanted to see the list of merges since the last tag in a repo\nwhere we have 1000+ commits and about 20 merges and found that there is\nno easy way to do so.\n\nAs a side effect, git rev-list --no-merges --only-merges will list\nnothing, but that's logical IMHO.\n\n Documentation/git-rev-list.txt     |    1 +\n Documentation/rev-list-options.txt |    4 ++++\n builtin-rev-list.c                 |    1 +\n builtin-rev-parse.c                |    1 +\n revision.c                         |    7 +++++++\n revision.h                         |    1 +\n 6 files changed, 15 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt\nindex d80cdf5..17c26bc 100644\n--- a/Documentation/git-rev-list.txt\n+++ b/Documentation/git-rev-list.txt\n@@ -15,6 +15,7 @@ SYNOPSIS\n \t     [ \\--min-age=timestamp ]\n \t     [ \\--sparse ]\n \t     [ \\--no-merges ]\n+\t     [ \\--only-merges ]\n \t     [ \\--first-parent ]\n \t     [ \\--remove-empty ]\n \t     [ \\--full-history ]\ndiff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt\nindex 2648a55..fc1cf0f 100644\n--- a/Documentation/rev-list-options.txt\n+++ b/Documentation/rev-list-options.txt\n@@ -176,6 +176,10 @@ endif::git-rev-list[]\n \n \tDo not print commits with more than one parent.\n \n+--only-merges::\n+\n+\tDo not print commits with less than two parents.\n+\n --first-parent::\n \tFollow only the first parent commit upon seeing a merge\n \tcommit.  This option can give a better overview when\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex edc0bd3..35c9422 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -23,6 +23,7 @@ static const char rev_list_usage[] =\n \"    --min-age=epoch\\n\"\n \"    --sparse\\n\"\n \"    --no-merges\\n\"\n+\"    --only-merges\\n\"\n \"    --remove-empty\\n\"\n \"    --all\\n\"\n \"    --branches\\n\"\ndiff --git a/builtin-rev-parse.c b/builtin-rev-parse.c\nindex 0351d54..66a6b62 100644\n--- a/builtin-rev-parse.c\n+++ b/builtin-rev-parse.c\n@@ -47,6 +47,7 @@ static int is_rev_argument(const char *arg)\n \t\t\"--max-count=\",\n \t\t\"--min-age=\",\n \t\t\"--no-merges\",\n+\t\t\"--only-merges\",\n \t\t\"--objects\",\n \t\t\"--objects-edge\",\n \t\t\"--parents\",\ndiff --git a/revision.c b/revision.c\nindex 196fedc..1f92a1a 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1127,6 +1127,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\t\t\trevs->no_merges = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n+\t\t\tif (!strcmp(arg, \"--only-merges\")) {\n+\t\t\t\trevs->only_merges = 1;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tif (!strcmp(arg, \"--boundary\")) {\n \t\t\t\trevs->boundary = 1;\n \t\t\t\tcontinue;\n@@ -1517,6 +1521,9 @@ enum commit_action simplify_commit(struct rev_info *revs, struct commit *commit)\n \t\treturn commit_ignore;\n \tif (revs->no_merges && commit->parents && commit->parents->next)\n \t\treturn commit_ignore;\n+\tif (revs->only_merges && ((commit->parents && !commit->parents->next) ||\n+\t\t\t!commit->parents))\n+\t\treturn commit_ignore;\n \tif (!commit_match(commit, revs))\n \t\treturn commit_ignore;\n \tif (revs->prune && revs->dense) {\ndiff --git a/revision.h b/revision.h\nindex c8b3b94..c40cf33 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -32,6 +32,7 @@ struct rev_info {\n \tunsigned int\tdense:1,\n \t\t\tprune:1,\n \t\t\tno_merges:1,\n+\t\t\tonly_merges:1,\n \t\t\tno_walk:1,\n \t\t\tshow_all:1,\n \t\t\tremove_empty_trees:1,\n-- \n1.5.4.5\n"},{"id":"73953","messageId":"alpine.LSU.1.00.0804091605460.10660@wbgn129.biozentrum.uni-wuerzburg.de","threadId":"13025","inReplyTo":"20080408203648.GS11574@genesis.frugalware.org","subject":"Re: [PATCH] Add --only-merges flag to display only merge commits.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-09T14:06:57Z","receivedAt":"2008-04-09T14:06:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 8 Apr 2008, Miklos Vajna wrote:\n\n> This is the opposite of git-rev-list --no-merges: It will hide commits \n> with single or no parent.\n> \n> It is useful if a maintainer has a lot of commits between tags and \n> usually each feature is developed in its own topic branch.\n> \n> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> ---\n> \n> I just wanted to see the list of merges since the last tag in a repo\n> where we have 1000+ commits and about 20 merges and found that there is\n> no easy way to do so.\n\nI usually did something like this:\n\ngit log -1 $(git rev-list --parents | sed -n \"s/ .* .*//p\")\n\nHth,\nDscho\n"},{"id":"73959","messageId":"20080409145108.GY11574@genesis.frugalware.org","threadId":"13025","inReplyTo":"alpine.LSU.1.00.0804091605460.10660@wbgn129.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Add --only-merges flag to display only merge commits.","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-04-09T14:51:08Z","receivedAt":"2008-04-09T14:51:08Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Apr 09, 2008 at 04:06:57PM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > I just wanted to see the list of merges since the last tag in a repo\n> > where we have 1000+ commits and about 20 merges and found that there is\n> > no easy way to do so.\n> \n> I usually did something like this:\n> \n> git log -1 $(git rev-list --parents | sed -n \"s/ .* .*//p\")\n\nIf you mean:\n\ngit log -1 $(git rev-list --parents HEAD | sed -n \"s/ .* .*//p\")\n\nthen it'll show only the first merge, --only-merges shows each merge.\n(While of course you can still use -1 or tag.. or so.)\n"},{"id":"73962","messageId":"alpine.LSU.1.00.0804091659130.10660@wbgn129.biozentrum.uni-wuerzburg.de","threadId":"13025","inReplyTo":"20080409145108.GY11574@genesis.frugalware.org","subject":"Re: [PATCH] Add --only-merges flag to display only merge commits.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-09T15:00:14Z","receivedAt":"2008-04-09T15:00:14Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 9 Apr 2008, Miklos Vajna wrote:\n\n> On Wed, Apr 09, 2008 at 04:06:57PM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > I just wanted to see the list of merges since the last tag in a repo\n> > > where we have 1000+ commits and about 20 merges and found that there is\n> > > no easy way to do so.\n> > \n> > I usually did something like this:\n> > \n> > git log -1 $(git rev-list --parents | sed -n \"s/ .* .*//p\")\n> \n> If you mean:\n> \n> git log -1 $(git rev-list --parents HEAD | sed -n \"s/ .* .*//p\")\n\nYes, I meant \"something like\" that...\n\n> then it'll show only the first merge, --only-merges shows each merge. \n> (While of course you can still use -1 or tag.. or so.)\n\nYep, I wrote \"-1\", but what I actually meant was \"--no-walk\".\n\nSorry,\nDscho\n"},{"id":"73970","messageId":"20080409183142.GZ11574@genesis.frugalware.org","threadId":"13025","inReplyTo":"alpine.LSU.1.00.0804091659130.10660@wbgn129.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Add --only-merges flag to display only merge commits.","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-04-09T18:31:42Z","receivedAt":"2008-04-09T18:31:42Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Apr 09, 2008 at 05:00:14PM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > then it'll show only the first merge, --only-merges shows each merge. \n> > (While of course you can still use -1 or tag.. or so.)\n> \n> Yep, I wrote \"-1\", but what I actually meant was \"--no-walk\".\n\nOh, I see. But I still think it would be handy to have an option for\nthis if there is an option to filter out merges as well.\n"},{"id":"73976","messageId":"7v3apu6bes.fsf@gitster.siamese.dyndns.org","threadId":"13025","inReplyTo":"20080408203648.GS11574@genesis.frugalware.org","subject":"Re: [PATCH] Add --only-merges flag to display only merge commits.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-04-09T20:06:19Z","receivedAt":"2008-04-09T20:06:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> This is the opposite of git-rev-list --no-merges: It will hide commits\n> with single or no parent.\n>\n> It is useful if a maintainer has a lot of commits between tags and\n> usually each feature is developed in its own topic branch.\n\nFor that particular use case, I'd suggest --first-parent.  It is not just\nabout filtering the output but more importantly also affects the way the\ntraversal is done (it does not descend into side branches).  It simply is\nmore suited for the job you described.\n\nAt this point, I have a mild aversion to a random addition to rev-list\nthat does not have to affect how the traversal works but only filters the\noutput, and more importantly does only a single purpose filtering.\n\nIt is very much unclear if the --only-merges is a very common thing for\npeople to want to do, and it is very clear what --only-merges does is a\nvery narrow single purpose filtering.\n\nContrast that to existing --no-merges or --grep.  The former is a very\nnarrow single purpose filtering but it is clearly something everybody\nwould want to have.  The latter also satisfies a common desire, and it is\nan easy way to query with a customized filtering, e.g. you can use it like\nso: 'log --grep=\"Merge \" v1.5.4..v1.5.5'.\n"},{"id":"73982","messageId":"20080409203846.GH11574@genesis.frugalware.org","threadId":"13025","inReplyTo":"7v3apu6bes.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] Add --only-merges flag to display only merge commits.","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-04-09T20:38:46Z","receivedAt":"2008-04-09T20:38:46Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Apr 09, 2008 at 01:06:19PM -0700, Junio C Hamano <gitster@pobox.com> wrote:\n> Miklos Vajna <vmiklos@frugalware.org> writes:\n> \n> > This is the opposite of git-rev-list --no-merges: It will hide commits\n> > with single or no parent.\n> >\n> > It is useful if a maintainer has a lot of commits between tags and\n> > usually each feature is developed in its own topic branch.\n> \n> For that particular use case, I'd suggest --first-parent.  It is not just\n> about filtering the output but more importantly also affects the way the\n> traversal is done (it does not descend into side branches).  It simply is\n> more suited for the job you described.\n\nHm I was not exactly correct. Trivial fixes are pushed to master\ndirectly, so just --first-parent won't solve my problem.\n\n> It is very much unclear if the --only-merges is a very common thing for\n> people to want to do, and it is very clear what --only-merges does is a\n> very narrow single purpose filtering.\n\nOK, that's something others should decide. :-) I find it useful but maybe\nit's not commonly useful.\n\n> Contrast that to existing --no-merges or --grep.  The former is a very\n> narrow single purpose filtering but it is clearly something everybody\n> would want to have.  The latter also satisfies a common desire, and it is\n> an easy way to query with a customized filtering, e.g. you can use it like\n> so: 'log --grep=\"Merge \" v1.5.4..v1.5.5'.\n\nOh, I forgot about --grep. Though I still think --only-merges would be a\nsolution and --grep=\"Merge \" is just a workaround, in practice it works\nfine, so thanks for the hint. :-)\n"}]}