emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: git log question


From: Stephen Berman
Subject: Re: git log question
Date: Thu, 30 Nov 2017 15:19:44 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

On Thu, 30 Nov 2017 20:15:51 +0700 Yuri Khan <address@hidden> wrote:

> On Thu, Nov 30, 2017 at 7:02 PM, Stephen Berman <address@hidden> wrote:
>
>> I want to call `git
>> <command> <commit>' on a branch and see the commit only if it is indeed
>> on that branch, not on some other branch in the repository.  From your
>> reply, it appears that git does not have such a command, but I have to
>> first call `git branch --contains <commit>' and, if it shows the branch
>> I want, then call `git log <commit> -1'.  If so, fine, though a bit
>> disappointing it's not more straightforward.
>
> You are trying to do two things at once: (1) determine if a commit is
> reachable from a branch, and (2) show the commit. 

I'm not sure what you mean by "reachable from a branch"; what I want is
to find out whether a specific commit (identified by its hash) exists on
the current branch -- not just whether it exists on some branch in the
current repository -- and if so, to see that commit.

>                                                   But it seems Git
> does not have a command to do exactly that, or any means to intersect
> revision ranges in one command.
>
> This works:
>
>     $ git merge-base --is-ancestor <commit> HEAD && git log -1 <commit>
>
> You might be able to define a Git alias to shorten it further.

Thanks, but this does do what I want.  For example, when I invoke `git
branch --contains b407c521f2' on emacs-26 (here currently at
408862f02a), it outputs `master', but when I invoke `git merge-base
--is-ancestor b407c521f2 HEAD && git log -1 b407c521f2' on emacs-26, it
outputs nothing; though when I invoke this on emacs-master (here
currently at f069ea4f84), it does ouput that commit.

I find the following puzzling:

steve [ ~/git/emacs-master ]$ git log --oneline | grep b407c521f2
b407c521f2 Remove pinentry.el

steve [ ~/git/emacs-26 ]$ git log --oneline | grep b407c521f2

The latter gives no output; yet:

steve [ ~/git/emacs-26 ]$ git log --oneline b407c521f2 -1
b407c521f2 Remove pinentry.el

That is, `git log' invoked with a specific commit will find that commit
even when it's not on the current branch but on another branch in this
repository, but it appears unable to say which branch it's on.

Steve Berman



reply via email to

[Prev in Thread] Current Thread [Next in Thread]