* How do I show only log messages for commits on a specific branch?
@ 2009-12-16 10:16 bd
2009-12-16 18:05 ` Elijah Newren
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: bd @ 2009-12-16 10:16 UTC (permalink / raw)
To: git
Hello list,
[ git v1.6.3.3 ]
imagine this:
--A--*--B (new)
/
*--X--*--Y (master)
Now I'd like to list only log messages for A..B (X..B would be okay too).
I know of
git log master..new
however then I need to remember that I branched new of master, and to be honest,
sometimes I forget.
So how do I:
git please-tell-me-the-branch-I-started-this-branch-from new
Thanks in advance,
Stefan
--
BOFH excuse #181:
Atilla the Hub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 10:16 How do I show only log messages for commits on a specific branch? bd
@ 2009-12-16 18:05 ` Elijah Newren
2009-12-16 23:26 ` Miklos Vajna
2009-12-17 9:20 ` David Roden
2009-12-17 15:04 ` Pat Notz
2 siblings, 1 reply; 10+ messages in thread
From: Elijah Newren @ 2009-12-16 18:05 UTC (permalink / raw)
To: bd; +Cc: git
On Wed, Dec 16, 2009 at 3:16 AM, <bd@bc-bd.org> wrote:
> imagine this:
>
> --A--*--B (new)
> /
> *--X--*--Y (master)
>
> Now I'd like to list only log messages for A..B (X..B would be okay too).
>
> I know of
>
> git log master..new
>
> however then I need to remember that I branched new of master, and to be honest,
> sometimes I forget.
>
> So how do I:
>
> git please-tell-me-the-branch-I-started-this-branch-from new
In the above example, you technically did not create 'new' off of
'master', you created new starting at X. You may think of it in terms
of branching off of 'master', but
git branch new master
resolves 'master' to the commit it points at and creates 'new'
pointing at that commit. That's all that is recorded. But I believe
the info you are really interested in is where new started, rather
than the fact that it branched off master. Is that correct? If so,
just use new@{30.years.ago} (or any other sufficiently long period of
time):
git log new@{30.years.ago}..new
(You'll get a warning that 'new' hasn't existed for 30 years but it
doesn't hurt anything)
Hope that helps,
Elijah
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 18:05 ` Elijah Newren
@ 2009-12-16 23:26 ` Miklos Vajna
2009-12-16 23:58 ` Santi Béjar
2009-12-16 23:59 ` Elijah Newren
0 siblings, 2 replies; 10+ messages in thread
From: Miklos Vajna @ 2009-12-16 23:26 UTC (permalink / raw)
To: Elijah Newren; +Cc: bd, git
[-- Attachment #1: Type: text/plain, Size: 784 bytes --]
On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren <newren@gmail.com> wrote:
> git log new@{30.years.ago}..new
> (You'll get a warning that 'new' hasn't existed for 30 years but it
> doesn't hurt anything)
That's the same as "git log new", if I'm not mistaken.
What Stefan wants to do is to let git log show the commits which are
only in the "new" branch, but I don't think there is an out-of-the-box
solution for that.
One solution I can think of is to iterate over each ref using "git
for-each-ref --format='%(refname)' 'refs/heads/*'", then run "git
merge-base $i new", run git rev-list $mb..new|wc -l and then you could
decide what is the first commit that does not belong to any other
branch. But that's just an idea, I don't have the motivation to script
it properly.
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 23:26 ` Miklos Vajna
@ 2009-12-16 23:58 ` Santi Béjar
2009-12-17 0:04 ` Elijah Newren
2009-12-16 23:59 ` Elijah Newren
1 sibling, 1 reply; 10+ messages in thread
From: Santi Béjar @ 2009-12-16 23:58 UTC (permalink / raw)
To: Miklos Vajna; +Cc: Elijah Newren, bd, git
On Thu, Dec 17, 2009 at 12:26 AM, Miklos Vajna <vmiklos@frugalware.org> wrote:
> On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren <newren@gmail.com> wrote:
>> git log new@{30.years.ago}..new
>> (You'll get a warning that 'new' hasn't existed for 30 years but it
>> doesn't hurt anything)
>
> That's the same as "git log new", if I'm not mistaken.
>
> What Stefan wants to do is to let git log show the commits which are
> only in the "new" branch, but I don't think there is an out-of-the-box
> solution for that.
Not out-of-the-box but this does exactly what you said, print all
commits only reachable from the "new" branch:
git log new --not $(git for-each-ref --format='%(refname)'
'refs/heads/*' | grep -v refs/heads/new)
For the original question, I think what makes most sense in this case
is asking for the commits since the upstream branch. Some time ago
there was a discussion about a syntax for the tracking branch and
there was even a patch:
Subject: [PATCH v2] Introduce <branch>@{upstream} as shortcut to the
tracked branch
Date: 2009-09-10 15:25:57 GMT
http://news.gmane.org/find-root.php?message_id=%3calpine.DEB.1.00.0909101724520.8306%40pacific.mpi%2dcbg.de%3e
but it's not in git.git.
HTH,
Santi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 23:26 ` Miklos Vajna
2009-12-16 23:58 ` Santi Béjar
@ 2009-12-16 23:59 ` Elijah Newren
2009-12-17 0:20 ` Miklos Vajna
1 sibling, 1 reply; 10+ messages in thread
From: Elijah Newren @ 2009-12-16 23:59 UTC (permalink / raw)
To: Miklos Vajna; +Cc: bd, git
On Wed, Dec 16, 2009 at 4:26 PM, Miklos Vajna <vmiklos@frugalware.org> wrote:
> On Wed, Dec 16, 2009 at 11:05:52AM -0700, Elijah Newren <newren@gmail.com> wrote:
>> git log new@{30.years.ago}..new
>> (You'll get a warning that 'new' hasn't existed for 30 years but it
>> doesn't hurt anything)
>
> That's the same as "git log new", if I'm not mistaken.
Did you try it with a 'new' branch in your repository that started at
the beginning of history rather than at some commit? "git log new"
and "git log new@{30.years.ago}..new" are not the same for me with
git-1.6.5.5:
$ git init repo
$ cd repo
$ echo content> foo && git add foo && git commit -mone foo
$ echo more content >> foo && git commit -mtwo foo
$ git checkout -b new master~1
$ echo stuff >> foo && git commit -mthree foo
$ git log new@{30.years.ago}..new
warning: Log for 'new' only goes back to Wed, 16 Dec 2009 16:48:02 -0700.
commit 7df8bad7cc146875c59ab030da0d25555976e79c
Author: Elijah Newren <newren@gmail.com>
Date: Wed Dec 16 16:48:07 2009 -0700
three
$ git log new
commit 7df8bad7cc146875c59ab030da0d25555976e79c
Author: Elijah Newren <newren@gmail.com>
Date: Wed Dec 16 16:48:07 2009 -0700
three
commit b86eadcdb152877ade44bebf4b8742884949f29f
Author: Elijah Newren <newren@gmail.com>
Date: Wed Dec 16 16:47:31 2009 -0700
one
> What Stefan wants to do is to let git log show the commits which are
> only in the "new" branch, but I don't think there is an out-of-the-box
> solution for that.
Are you sure? I'm more inclined to believe he'd like to see all the
commits that have been added to the "new" branch since he created it
(which may be the same as what you say, but not necessarily). Of
course, neither my assumption or yours match what he actually asked
for (though I think what he asked for isn't possible and is merely an
means to the end he really wants).
Also, I think this does what you asked for (the commits in the "new"
branch but no other branch):
$ git log new $(git for-each-ref --format='%(refname)' 'refs/heads/*'
| grep -v '^refs/heads/new$' | sed -e s/^/^/)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 23:58 ` Santi Béjar
@ 2009-12-17 0:04 ` Elijah Newren
0 siblings, 0 replies; 10+ messages in thread
From: Elijah Newren @ 2009-12-17 0:04 UTC (permalink / raw)
To: Santi Béjar; +Cc: Miklos Vajna, bd, git
On Wed, Dec 16, 2009 at 4:58 PM, Santi Béjar <santi@agolina.net> wrote:
> git log new --not $(git for-each-ref --format='%(refname)'
> 'refs/heads/*' | grep -v refs/heads/new)
How did I miss '--not' as a git log option? Thanks for pointing it out!
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 23:59 ` Elijah Newren
@ 2009-12-17 0:20 ` Miklos Vajna
2009-12-17 14:20 ` Stefan Völkel
0 siblings, 1 reply; 10+ messages in thread
From: Miklos Vajna @ 2009-12-17 0:20 UTC (permalink / raw)
To: Elijah Newren; +Cc: bd, git
[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]
On Wed, Dec 16, 2009 at 04:59:54PM -0700, Elijah Newren <newren@gmail.com> wrote:
> Did you try it with a 'new' branch in your repository that started at
> the beginning of history rather than at some commit? "git log new"
> and "git log new@{30.years.ago}..new" are not the same for me with
> git-1.6.5.5:
>
> $ git init repo
> $ cd repo
> $ echo content> foo && git add foo && git commit -mone foo
> $ echo more content >> foo && git commit -mtwo foo
> $ git checkout -b new master~1
> $ echo stuff >> foo && git commit -mthree foo
> $ git log new@{30.years.ago}..new
Aah, thanks. Then you can just avoid the warning using
git log $(git reflog show new|sed -n 's/ .*//;$ p')..new
> Are you sure? I'm more inclined to believe he'd like to see all the
> commits that have been added to the "new" branch since he created it
> (which may be the same as what you say, but not necessarily). Of
> course, neither my assumption or yours match what he actually asked
> for (though I think what he asked for isn't possible and is merely an
> means to the end he really wants).
No, I'm not sure about what he thought, but I hope he will clarify. :)
[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 10:16 How do I show only log messages for commits on a specific branch? bd
2009-12-16 18:05 ` Elijah Newren
@ 2009-12-17 9:20 ` David Roden
2009-12-17 15:04 ` Pat Notz
2 siblings, 0 replies; 10+ messages in thread
From: David Roden @ 2009-12-17 9:20 UTC (permalink / raw)
To: git
bd@bc-bd.org wrote:
> imagine this:
>
> --A--*--B (new)
> /
> *--X--*--Y (master)
>
> Now I'd like to list only log messages for A..B (X..B would be okay too).
>
> I know of
>
> git log master..new
>
> however then I need to remember that I branched new of master, and to be
> honest, sometimes I forget.
>
> So how do I:
>
> git please-tell-me-the-branch-I-started-this-branch-from new
>
> Thanks in advance,
I have had wonderful results using
git log new --not master
or
git log new ^master
This is using git 1.6.4.4 and this way of specifying commits is not
mentioned in the man page—it seems to work, though.
David
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-17 0:20 ` Miklos Vajna
@ 2009-12-17 14:20 ` Stefan Völkel
0 siblings, 0 replies; 10+ messages in thread
From: Stefan Völkel @ 2009-12-17 14:20 UTC (permalink / raw)
To: Miklos Vajna; +Cc: Elijah Newren, git
Hi,
> git log $(git reflog show new|sed -n 's/ .*//;$ p')..new
I had trouble getting the above to work as a git alias (someething wrt
escaping I guess), however this:
gl = log --graph --pretty=oneline --abbrev-commit
bl = !sh -c 'git gl $0 --not $(git for-each-ref --format=%\\(refname\\)
refs/heads/* | grep -v refs/heads/$0)'
does exactly what I want:
# git reflog show new
76cacd3 new@{0}: commit: B
9638379 new@{1}: commit: A
7944f55 new@{2}: branch: Created from HEAD
# git gl
* 76cacd3 B
* 9638379 A
* 7944f55 Y
* b8e4a96 X
# git bl new
* 76cacd3 B
* 9638379 A
Thanks for the help,
Stefan
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: How do I show only log messages for commits on a specific branch?
2009-12-16 10:16 How do I show only log messages for commits on a specific branch? bd
2009-12-16 18:05 ` Elijah Newren
2009-12-17 9:20 ` David Roden
@ 2009-12-17 15:04 ` Pat Notz
2 siblings, 0 replies; 10+ messages in thread
From: Pat Notz @ 2009-12-17 15:04 UTC (permalink / raw)
To: bd; +Cc: git
> So how do I:
>
> git please-tell-me-the-branch-I-started-this-branch-from new
>
You may also be interested in the git show-branch command. The output
may be unintuitive at first but once you grok it it's pretty useful...
especially if you have several branches.
Aside from the man page, here's a blog post the describes the output:
https://wincent.com/wiki/Understanding_the_output_of_%22git_show-branch%22
~ Pat
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-12-17 15:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-16 10:16 How do I show only log messages for commits on a specific branch? bd
2009-12-16 18:05 ` Elijah Newren
2009-12-16 23:26 ` Miklos Vajna
2009-12-16 23:58 ` Santi Béjar
2009-12-17 0:04 ` Elijah Newren
2009-12-16 23:59 ` Elijah Newren
2009-12-17 0:20 ` Miklos Vajna
2009-12-17 14:20 ` Stefan Völkel
2009-12-17 9:20 ` David Roden
2009-12-17 15:04 ` Pat Notz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox