From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.devel Subject: Re: git log question Date: Thu, 30 Nov 2017 15:19:44 +0100 Message-ID: <87shcvdf27.fsf@gmx.net> References: <87bmjkgk6h.fsf@gmx.net> <920d2cc0-a9b8-b740-1b4a-51403a790f90@mnet-mail.de> <87wp28c6ul.fsf@gmx.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1512051599 5134 195.159.176.226 (30 Nov 2017 14:19:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 30 Nov 2017 14:19:59 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Mathias Megyei , Emacs developers To: Yuri Khan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Nov 30 15:19:51 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eKPgt-0000tM-3M for ged-emacs-devel@m.gmane.org; Thu, 30 Nov 2017 15:19:51 +0100 Original-Received: from localhost ([::1]:48533 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKPh0-0007pX-E7 for ged-emacs-devel@m.gmane.org; Thu, 30 Nov 2017 09:19:58 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eKPgt-0007pO-V9 for emacs-devel@gnu.org; Thu, 30 Nov 2017 09:19:52 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eKPgq-0007gu-OZ for emacs-devel@gnu.org; Thu, 30 Nov 2017 09:19:51 -0500 Original-Received: from mout.gmx.net ([212.227.15.18]:63674) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eKPgq-0007gP-Ea for emacs-devel@gnu.org; Thu, 30 Nov 2017 09:19:48 -0500 Original-Received: from rosalinde ([83.135.10.157]) by mail.gmx.com (mrgmx003 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LnOve-1f1zW30Zfa-00hcXp; Thu, 30 Nov 2017 15:19:45 +0100 In-Reply-To: (Yuri Khan's message of "Thu, 30 Nov 2017 20:15:51 +0700") X-Provags-ID: V03:K0:PhGjGDBZXWw+ohCTLJkF60Z3Wn5jAAs+8wv8XjPErcbOJyqPcle W8vsWyds/s4Qx5D/gdesdFfv6tFWxA+XxMjIJRooHw7YeA4IfOEXJnmj6LgyukoqbPFEmMh MZdDBvQSLcEDy9aN0hrmWtozq/GGCXooDiZcQXQQTaGi0IUIb6VM75ULaKBELTILZPcjEVc KTu7BYAk2RESpJ728SyVQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:Z5nzGsfLH7Q=:tcVfAGUYV+j3eUVuwavhrm ctOOStwPqA+ACEP5DWBfSE73XXN/uxxzIismjOL9IGUTBUECBPAmPN3RXaxS7afdgsVY8Mx3r tpKiPA9B+K7qOvbeZ9oXnfTGH5bgnG+4j1qdhBEaOXoljivbKYi5arXFkh08bteNB12bLkdsT kH4aecmUCjsgfWB6so/FNTt7tKn6t+HDQ0dUY+Qf9Nht0o8qQWArnkIzL0FO3eOgERmFXnU8T 3xWAR2MWEqvqfMpmVEwgfRY20PX/DwRrmax4iw5I1f2g3Y/tP8JbV48DS2DdR/HoWJOLqR7nI 0sUl7Bf/nD0nMDPNu+2R3XHoOviuL3ZYEO8j06yW5yaoL0RJSKk9c/S80SqsALKmgtvcGrYr5 Wn8ce9YGgWCpaAwvpgFe2NKeGnoklPCWjA7JIFIle/HOarwFCgdap5v9uaI1ZymPk2d9oo6tj oqTMs4qlSUcQw6JbgrpPUmsTqtq+rMkBLybznjCPkGi8ShwLyToJJ60Jr1lRRmWXbcK/zwsiP JxpvvxLJlTjwLztiRgV4Xny06Qh5VlHUrkpakPX6bywWsS01yhp0TanS8FmPQG3SeGAt8qeG8 21T5D3aRq+SyzgkTy8KCseb84Xzps6/wl6s4z951Qln6JXb4609ka+A0A8cQMzomvErxp61Hv fOnLFq59GqllLTHvic60lIlCzUAMWahTaD/Z7Viwzl04VXbjQZmUvRL24SfKeJP+FARNs9723 bpFa8vBSLmKOohTL7sIzwyRhnz2tPWcEKkd0vIwIIKgTYoKgjbE/CzC7+pj8Ov/+UDRm3KJt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.18 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:220541 Archived-At: On Thu, 30 Nov 2017 20:15:51 +0700 Yuri Khan wrote: > On Thu, Nov 30, 2017 at 7:02 PM, Stephen Berman wrote: > >> I want to call `git >> ' 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 ' and, if it shows the branch >> I want, then call `git log -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 HEAD && git log -1 > > 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