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

using git-blame with patches as input

From
DZDon Zickus <dzickus@redhat.com>
Date
Jun 16, 2008, 21:35 UTC
Message-ID
<20080616213517.GE20727@redhat.com>

I deal with a lot of backported patches that are a combination of multiple commits. I was looking to develop a tool that would help me determine which chunks of the patch are upstream (not necessarily currently in HEAD but at some point in the file's history).

For example, if I took the top three commits from HEAD and appended them into one patch file and then ran this tool with the patch as input, I would hope that it gave as output the three original commits.

git-blame seem to handle a lot of the pieces I would need but my little brain can't follow all the logic behind some of the mechanisms.

Seeing that git-blame can take patch chunks and traverse through commit history to see if a particular chunk can be blamed on a parent, I feel like I am most of the way there. Unfortunately, I don't quite understand some of the algorithms git-blame does when it splits the patch chunks into smaller pieces to determine which pieces are blame-able on the parents.

Is there anyone who can help explain some of the low level logic to me?

What I would like to do is take a patch as input, split it into chunks and traverse through the commit history looking for a match (or something of high similarity) and output that commit id for each patch chunk.

git-cherry does something close but patches have to be exact whereas my situation has a combination of patches. I also understand there are plenty of normal scenerios where my approach falls flat on its face (but I have ideas for those). I just wanted to get a simple common case going first.

Thanks in advance.

Cheers, Don

Next: Junio C Hamano
Message 1 of 6 in “using git-blame with patches as input”
  1. Don ZickusJun 16, 2008
  2. Junio C HamanoJun 16, 2008
  3. Don ZickusJun 17, 2008
  4. Junio C HamanoJun 16, 2008
  5. Junio C HamanoJun 16, 2008
  6. Don ZickusJun 17, 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.