threads / discuss / 4833

can I get only the list of merges?

Subject: can I get only the list of merges?

## tl;dr

6 messages between Jul 10, 2006 and Jul 10, 2006.

replies: 5people: 4as markdown or json

Diego Calleja· Jul 10, 2006, 17:26 UTC · lore

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· Jul 10, 2006, 17:41 UTC · re: Diego Calleja · lore

Re: can I get only the list of merges?

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

Linus Torvalds· Jul 10, 2006, 18:09 UTC · re: Matthias Lederhofer · lore

Re: can I get only the list of merges?

On Mon, 10 Jul 2006, Matthias Lederhofer wrote:
Show 11 quoted lines
> 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· Jul 10, 2006, 18:51 UTC · re: Linus Torvalds · lore

Re: can I get only the list of merges?

On Mon, 10 Jul 2006, Linus Torvalds wrote:
Show 10 quoted lines
>
> 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· Jul 10, 2006, 22:37 UTC · re: Matthias Lederhofer · lore

Re: can I get only the list of merges?

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

Matthias Lederhofer· Jul 10, 2006, 17:57 UTC · re: Diego Calleja · lore

[PATCH] git-rev-list: add documentation for --parents, --no-merges

---
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

← back to recent threads