git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to find all the commits that comprise a branch?
@ 2012-05-30 17:39 Felipe Contreras
  2012-05-30 19:29 ` Junio C Hamano
  2012-05-31  3:22 ` Sitaram Chamarty
  0 siblings, 2 replies; 5+ messages in thread
From: Felipe Contreras @ 2012-05-30 17:39 UTC (permalink / raw)
  To: git

Hi,

Basically what I want to do is:

 % git log branch ^<any-other-branch>

IOW; all the commits were 'git branch --contains' would show 'branch'
and nothing else.

Is there any easy way to do that?

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to find all the commits that comprise a branch?
  2012-05-30 17:39 How to find all the commits that comprise a branch? Felipe Contreras
@ 2012-05-30 19:29 ` Junio C Hamano
  2012-05-30 20:23   ` Felipe Contreras
  2012-05-31  3:22 ` Sitaram Chamarty
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-05-30 19:29 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

Felipe Contreras <felipe.contreras@gmail.com> writes:

> Hi,
>
> Basically what I want to do is:
>
>  % git log branch ^<any-other-branch>
>
> IOW; all the commits were 'git branch --contains' would show 'branch'
> and nothing else.
>
> Is there any easy way to do that?

There was "log blah --not --all --exclude-ref=refs/heads/blah"
discussion a few months ago, but I do not think anything came out of
it.

This is a tangent, but it would be a good way to find out set of
commits that you would lose and need to go to reflog to find if you
were to delete the branch.

It however is a poor definition for "commits that comprise a branch";
I actually am not sure if the concept has a sensible definition.

Let's think aloud with a few examples.

You may be done with your "work" branch and merge it to "master".
At that point, do you think you no longer have any commit that
comprises your "work" branch?

You could argue that "work" branch is no longer relevant because it
is part of "master", and it is an understandable viewpoint.

But imagine what happens when you find a bug in your "work" and want
to fix it up by queuing a correction on your "work" branch (not
directly on "master", because your "work" branch was forked from
"maint" and you eventually want to merge it there as well).  Now, is
the single fix-up commit the only commit that comprises your "work"?

Suppose you have 5-patch series in your "work" branch, two commits
at the bottom of which are useful refactoring of existing code.  I
fork from the second commit to take advantage of your refactoring to
work on something entirely different.  These two branches now share
the bottom two commits.  At this point, do you have only three
remaining commits on your "work" branch?  Wouldn't we rather want to
say that I am merely borrowing two commits from you and you still
have 5 commits that is what your "work" branch consists of?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to find all the commits that comprise a branch?
  2012-05-30 19:29 ` Junio C Hamano
@ 2012-05-30 20:23   ` Felipe Contreras
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2012-05-30 20:23 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On Wed, May 30, 2012 at 9:29 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> Hi,
>>
>> Basically what I want to do is:
>>
>>  % git log branch ^<any-other-branch>
>>
>> IOW; all the commits were 'git branch --contains' would show 'branch'
>> and nothing else.
>>
>> Is there any easy way to do that?
>
> There was "log blah --not --all --exclude-ref=refs/heads/blah"
> discussion a few months ago, but I do not think anything came out of
> it.
>
> This is a tangent, but it would be a good way to find out set of
> commits that you would lose and need to go to reflog to find if you
> were to delete the branch.
>
> It however is a poor definition for "commits that comprise a branch";
> I actually am not sure if the concept has a sensible definition.
>
> Let's think aloud with a few examples.
>
> You may be done with your "work" branch and merge it to "master".
> At that point, do you think you no longer have any commit that
> comprises your "work" branch?

That's right... no commits.

> You could argue that "work" branch is no longer relevant because it
> is part of "master", and it is an understandable viewpoint.
>
> But imagine what happens when you find a bug in your "work" and want
> to fix it up by queuing a correction on your "work" branch (not
> directly on "master", because your "work" branch was forked from
> "maint" and you eventually want to merge it there as well).  Now, is
> the single fix-up commit the only commit that comprises your "work"?

Yes. On that branch.

> Suppose you have 5-patch series in your "work" branch, two commits
> at the bottom of which are useful refactoring of existing code.  I
> fork from the second commit to take advantage of your refactoring to
> work on something entirely different.  These two branches now share
> the bottom two commits.  At this point, do you have only three
> remaining commits on your "work" branch?  Wouldn't we rather want to
> say that I am merely borrowing two commits from you and you still
> have 5 commits that is what your "work" branch consists of?

It depends; if your branch gets merged to master, then my work branch
is comprised of 3 commits.

Of course it's debatable how to consider the commits that are
contained in multiple branches, but it's clear that the commits that
are only in one branch comprise that branch.

Either way, call them 'independent' or whatever you want, but the
concept of "commits that are only in one branch" is clear, and it's
useful to find this information.

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to find all the commits that comprise a branch?
  2012-05-30 17:39 How to find all the commits that comprise a branch? Felipe Contreras
  2012-05-30 19:29 ` Junio C Hamano
@ 2012-05-31  3:22 ` Sitaram Chamarty
  2012-05-31 12:56   ` Felipe Contreras
  1 sibling, 1 reply; 5+ messages in thread
From: Sitaram Chamarty @ 2012-05-31  3:22 UTC (permalink / raw)
  To: Felipe Contreras; +Cc: git

On Wed, May 30, 2012 at 11:09 PM, Felipe Contreras
<felipe.contreras@gmail.com> wrote:
> Hi,
>
> Basically what I want to do is:
>
>  % git log branch ^<any-other-branch>
>
> IOW; all the commits were 'git branch --contains' would show 'branch'
> and nothing else.

I have a script called "otb" (only this branch, I guess; I tend to use
crappily short names for stuff I don't make public!) that looks like
this:

#!/bin/bash

m=$(git rev-parse HEAD)
n=$(git rev-parse --branches | grep -v $m)
git log --oneline $m --not $n

I think that fits your description, but it's not *one* command.

> Is there any easy way to do that?
>
> Cheers.
>
> --
> Felipe Contreras
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Sitaram

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to find all the commits that comprise a branch?
  2012-05-31  3:22 ` Sitaram Chamarty
@ 2012-05-31 12:56   ` Felipe Contreras
  0 siblings, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2012-05-31 12:56 UTC (permalink / raw)
  To: Sitaram Chamarty; +Cc: git

On Thu, May 31, 2012 at 5:22 AM, Sitaram Chamarty <sitaramc@gmail.com> wrote:
> On Wed, May 30, 2012 at 11:09 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
>> Hi,
>>
>> Basically what I want to do is:
>>
>>  % git log branch ^<any-other-branch>
>>
>> IOW; all the commits were 'git branch --contains' would show 'branch'
>> and nothing else.
>
> I have a script called "otb" (only this branch, I guess; I tend to use
> crappily short names for stuff I don't make public!) that looks like
> this:
>
> #!/bin/bash
>
> m=$(git rev-parse HEAD)
> n=$(git rev-parse --branches | grep -v $m)
> git log --oneline $m --not $n
>
> I think that fits your description, but it's not *one* command.

Yeap, I was thinking on doing something along those lines... but hoped
there was a single command for it.

Cheers.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-31 12:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-30 17:39 How to find all the commits that comprise a branch? Felipe Contreras
2012-05-30 19:29 ` Junio C Hamano
2012-05-30 20:23   ` Felipe Contreras
2012-05-31  3:22 ` Sitaram Chamarty
2012-05-31 12:56   ` Felipe Contreras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).