Skip to contentSkip to conversation

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

PATCH Steven A. Falco 6 participants 7 messages Jun 15, 2016 – Aug 13, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

I have a patch file, and I'd like to figure out which commits were used to produce it.

For example, one of the diffs in the patch file begins with:

Makefile +0 -0
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.

Thanks,
Steve

#1 lore raw
Quoted 4 lines · Steven A. Falco

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.

Something like:

for i in git rev-list HEAD
do

        git ls-tree -r $i|grep -q cb4e8ed && echo "$i contains cb4e8ed"

done

could do it for you.

I don't think there is a --contains for blobs, like git branch --contains works for commits.

#2 lore raw
Quoted 10 lines · Miklos Vajna
Quoted 4 lines · Steven A. Falco

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.

Something like:

for i in git rev-list HEAD
do

Quoted 7 lines
        git ls-tree -r $i|grep -q cb4e8ed && echo "$i contains cb4e8ed"

done

could do it for you.

I don't think there is a --contains for blobs, like git branch --contains works for commits.

Thanks! It found the commit I needed.

Steve

#3 lore raw
In reply to Steven A. Falco
Quoted 9 lines · Steven A. Falco

For example, one of the diffs in the patch file begins with:

Makefile +0 -0
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

#4 lore raw

perforce import: git-p4 memory usage

Hi!

I'm trying to import part of a perforce repo with git-p4.

However, git-p4 appears to try to read all the repo into memory (and moreover seems to need about twice as much memory as repo).

Once it runs out of swap, it dies (unsurprisingly).

I think it's failing in readP4Files(), where it appears to read the entire repository in one go with "p4 -G -x - print".

Can I just rework this function to do stuff one file at a time? Or is that dumb?

Thanks
Luke Diamand

#5 lore raw

Re: perforce import: git-p4 memory usage

Quoted 7 lines · Luke Diamand

Hi!

I'm trying to import part of a perforce repo with git-p4.

However, git-p4 appears to try to read all the repo into memory (and moreover seems to need about twice as much memory as repo).

Quoted 8 lines

Once it runs out of swap, it dies (unsurprisingly).

I think it's failing in readP4Files(), where it appears to read the entire repository in one go with "p4 -G -x - print".

Can I just rework this function to do stuff one file at a time? Or is that dumb?

It's probably a lot slower, and since git works with changesets it probably won't work all that good unless you somehow construct some middle-stage which you can then feed to git-fastimport or some such.

Signature · 3 lines
Andreas Ericsson                   [email protected]
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
#6 lore raw

Re: perforce import: git-p4 memory usage

In reply to Luke Diamand
Quoted 10 lines · Luke Diamand

However, git-p4 appears to try to read all the repo into memory (and moreover seems to need about twice as much memory as repo).

Once it runs out of swap, it dies (unsurprisingly).

I think it's failing in readP4Files(), where it appears to read the entire repository in one go with "p4 -G -x - print".

Can I just rework this function to do stuff one file at a time? Or is that dumb?

I don't know if they were ever accepted into the mainline, but see the series of patches submitted by Tommy Thorn.

http://article.gmane.org/gmane.comp.version-control.git/72342

Signature · 4 lines
                                                        Logan Kennelly
      ,,,
     (. .)
--ooO-(_)-Ooo--