git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How can I figure out what commits relate to a given diff?

From
Jeff King <peff@peff.net>
Date
May 22, 2008, 16:04 UTC
Message-ID
<20080522160414.GA11158@sigill.intra.peff.net>
In-Reply-To
<48358F7E.6030401@harris.com>
On Thu, May 22, 2008 at 11:21:34AM -0400, Steven A. Falco wrote:
Show 9 quoted lines
> For example, one of the diffs in the patch file begins with:
> 
> diff --git a/Makefile b/Makefile
> index 9ceadaa..ad31bc6 100644
> 
> Is there a way to map a blob SHA1 to a commit?  In this example, I'd
> like to map 9ceadaa and ad31bc6 to their commits.  It seems easy to go
> the other way, seeing what is in a commit, but I've not been able to
> find a method for going "backwards" from a blob to a commit.

Miklos suggested a way of looking up trees and commits which contain blobs, but you can also look for that specific change of blobs:

  git log --pretty=format:'%h %s' --raw |
    perl -00 -ne 'print if /9ceadaa.*ad31bc6/'
-Peff
Previous: Steven A. Falco
Message 4 of 4 in “How can I figure out what commits relate to a given diff?”
  1. Steven A. FalcoMay 22, 2008
  2. Miklos VajnaMay 22, 2008
  3. Steven A. FalcoMay 22, 2008
  4. Jeff KingMay 22, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.