# can I get only the list of merges?

6 messages from 2006-07-10 to 2006-07-10. Participants: Diego Calleja, Matthias Lederhofer, Linus Torvalds, Johannes Schindelin.
Thread: https://gitlist.dev/t/4833

## Diego Calleja, 2006-07-10 17:26

Subject: can I get only the list of merges?
Message-ID: <20060710192622.70c51a81.diegocg@gmail.com>
URL: https://gitlist.dev/e/20060710192622.70c51a81.diegocg%40gmail.com

```
Hi, git-log and git-rev-list and friends have a --no-merges option. However,
I need the contrary functionality: a sort of "--only-merges" way of getting
the log? (that is, without parsing manually the git-log output)

```

## Matthias Lederhofer, 2006-07-10 17:41

Subject: Re: can I get only the list of merges?
Message-ID: <E1FzzlS-0003JE-9C@moooo.ath.cx>
URL: https://gitlist.dev/e/E1FzzlS-0003JE-9C%40moooo.ath.cx
In-Reply-To: <20060710192622.70c51a81.diegocg@gmail.com>

```
Diego Calleja <diegocg@gmail.com> wrote:
> Hi, git-log and git-rev-list and friends have a --no-merges option. However,
> I need the contrary functionality: a sort of "--only-merges" way of getting
> the log? (that is, without parsing manually the git-log output)

Perhaps something like this?  It finds all commits with more than one
parent (I dunno if there are any other commits that have more than one
parent)
git-rev-list --parents HEAD | \
grep -E '^([a-z0-9]{40} ){2}[a-z0-9]{40}' | \
cut -d ' ' -f 1

```

## Matthias Lederhofer, 2006-07-10 17:57

Subject: [PATCH] git-rev-list: add documentation for --parents, --no-merges
Message-ID: <E1G000X-0004om-A0@moooo.ath.cx>
URL: https://gitlist.dev/e/E1G000X-0004om-A0%40moooo.ath.cx
In-Reply-To: <20060710192622.70c51a81.diegocg@gmail.com>

```
---
Btw: grep -E ' .* ' should work too.

 Documentation/git-rev-list.txt |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index e220842..f60eacd 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -56,6 +56,9 @@ OPTIONS
 	Print the contents of the commit in raw-format; each
 	record is separated with a NUL character.
 
+--parents::
+	Print the parents of the commit.
+
 --objects::
 	Print the object IDs of any object referenced by the listed commits.
 	'git-rev-list --objects foo ^bar' thus means "send me all object IDs
@@ -102,6 +105,9 @@ OPTIONS
 --remove-empty::
 	Stop when a given path disappears from the tree.
 
+--no-merges::
+	Do not print commits with more than one parent.
+
 --not::
 	Reverses the meaning of the '{caret}' prefix (or lack
 	thereof) for all following revision specifiers, up to
-- 
1.4.1.gf157-dirty

```

## Linus Torvalds, 2006-07-10 18:09

Subject: Re: can I get only the list of merges?
Message-ID: <Pine.LNX.4.64.0607101103160.5623@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0607101103160.5623%40g5.osdl.org
In-Reply-To: <E1FzzlS-0003JE-9C@moooo.ath.cx>

```


On Mon, 10 Jul 2006, Matthias Lederhofer wrote:

> Diego Calleja <diegocg@gmail.com> wrote:
> > Hi, git-log and git-rev-list and friends have a --no-merges option. However,
> > I need the contrary functionality: a sort of "--only-merges" way of getting
> > the log? (that is, without parsing manually the git-log output)
> 
> Perhaps something like this?  It finds all commits with more than one
> parent (I dunno if there are any other commits that have more than one
> parent)
> git-rev-list --parents HEAD | \
> grep -E '^([a-z0-9]{40} ){2}[a-z0-9]{40}' | \
> cut -d ' ' -f 1

Well, the above is the "proper" way of doing things, and is efficient and 
gives the right answer. However, if you want a _sneaky_ way of doing it, 
and want a graphical result, and have a recent version of git, you can 
also just do something like

	gitk --full-history -- %%nonexistant-file%%

which will give you each commit that changes that nonexistant file (there 
should be none ;), and the full commit history for those (ie all the 
merges).

(If you use "git log", you also need to add "--parents" while gitk will do 
it for you).

			Linus

```

## Linus Torvalds, 2006-07-10 18:51

Subject: Re: can I get only the list of merges?
Message-ID: <Pine.LNX.4.64.0607101145590.5623@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0607101145590.5623%40g5.osdl.org
In-Reply-To: <Pine.LNX.4.64.0607101103160.5623@g5.osdl.org>

```


On Mon, 10 Jul 2006, Linus Torvalds wrote:
>
> However, if you want a _sneaky_ way of doing it, and want a graphical 
> result, and have a recent version of git, you can also just do something 
> like
> 
> 	gitk --full-history -- %%nonexistant-file%%
> 
> which will give you each commit that changes that nonexistant file (there 
> should be none ;), and the full commit history for those (ie all the 
> merges).

Btw, a better way to do the same is probably

	gitk --full-history -- a//b

which is guaranteed to not match any files and doesn't depend on just an 
_unlikely_ filename. Instead, it depends on the fact that a name with a 
double slash should not exist in a git archive.

(There are other possibilities too - instead of "a//a", you can just use 
the filename ".git", for the same reasons - it definitely won't be tracked 
by git).

		Linus

```

## Johannes Schindelin, 2006-07-10 22:37

Subject: Re: can I get only the list of merges?
Message-ID: <Pine.LNX.4.63.0607110035390.29667@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0607110035390.29667%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <E1FzzlS-0003JE-9C@moooo.ath.cx>

```
Hi,

On Mon, 10 Jul 2006, Matthias Lederhofer wrote:

> git-rev-list --parents HEAD | \
> grep -E '^([a-z0-9]{40} ){2}[a-z0-9]{40}' | \

Since the output of git-rev-list is well-defined, you could say

	grep  '.{121}'

instead. (Instead of 121, you could take any number between 83 and 122.)

Ciao,
Dscho

```
