unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: Mathias Megyei <mathias@mnet-mail.de>,
	Emacs developers <emacs-devel@gnu.org>
Subject: Re: git log question
Date: Thu, 30 Nov 2017 15:19:44 +0100	[thread overview]
Message-ID: <87shcvdf27.fsf@gmx.net> (raw)
In-Reply-To: <CAP_d_8W26X7BM44sOtLu6evL9cTum=Fh8AydA0Z_7QGxvbmbVQ@mail.gmail.com> (Yuri Khan's message of "Thu, 30 Nov 2017 20:15:51 +0700")

On Thu, 30 Nov 2017 20:15:51 +0700 Yuri Khan <yuri.v.khan@gmail.com> wrote:

> On Thu, Nov 30, 2017 at 7:02 PM, Stephen Berman <stephen.berman@gmx.net> 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	other threads:[~2017-11-30 14:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-30 10:00 git log question Stephen Berman
2017-11-30 11:30 ` Mathias Megyei
2017-11-30 12:02   ` Stephen Berman
2017-11-30 13:15     ` Yuri Khan
2017-11-30 14:19       ` Stephen Berman [this message]
2017-11-30 14:59         ` Noam Postavsky
2017-11-30 15:05         ` Yuri Khan
2017-11-30 15:05         ` Andreas Schwab
2017-11-30 15:21           ` Kaushal Modi
2017-11-30 15:25             ` Andreas Schwab
2017-11-30 15:35             ` Noam Postavsky
2017-11-30 17:46             ` Clément Pit-Claudel
2017-11-30 17:59               ` Kaushal Modi
2017-11-30 17:06         ` Davis Herring
2017-11-30 19:11           ` Stephen Berman
2017-11-30 14:28 ` Herring, Davis
2017-11-30 14:37   ` Stephen Berman
2017-11-30 15:57 ` Eli Zaretskii
2017-11-30 19:10   ` Stephen Berman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shcvdf27.fsf@gmx.net \
    --to=stephen.berman@gmx.net \
    --cc=emacs-devel@gnu.org \
    --cc=mathias@mnet-mail.de \
    --cc=yuri.v.khan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).