Given the hash of a blob, is there a way to get a list of commits that have this blob in their tree?
In addition of git describe, that I mention in my previous answer, git log
and git diff
now benefits as well from the "--find-object=
" option to limit the findings to changes that involve the named object.
That is in Git 2.16.x/2.17 (Q1 2018)
See commit 4d8c51a, commit 5e50525, commit 15af58c, commit cf63051, commit c1ddc46, commit 929ed70 (04 Jan 2018) by Stefan Beller (stefanbeller).
(Merged by Junio C Hamano -- gitster -- in commit c0d75f0, 23 Jan 2018)
diffcore
: add a pickaxe option to find a specific blobSometimes users are given a hash of an object and they want to identify it further (ex.: Use verify-pack to find the largest blobs, but what are these? or this Stack Overflow question "Which commit has this blob?")
One might be tempted to extend
git-describe
to also work with blobs, such thatgit describe
gives a description as ':'.
This was implemented here; as seen by the sheer number of responses (>110), it turns out this is tricky to get right.
The hard part to get right is picking the correct 'commit-ish' as that could be the commit that (re-)introduced the blob or the blob that removed the blob; the blob could exist in different branches.Junio hinted at a different approach of solving this problem, which this patch implements.
Teach thediff
machinery another flag for restricting the information to what is shown.
For example:$ ./git log --oneline --find-object=v2.0.0:Makefile b2feb64 Revert the whole "ask curl-config" topic for now 47fbfde i18n: only extract comments marked with "TRANSLATORS:"
we observe that the
Makefile
as shipped with2.0
was appeared inv1.9.2-471-g47fbfded53
and inv2.0.0-rc1-5-gb2feb6430b
.
The reason why these commits both occur prior to v2.0.0 are evil merges that are not found using this new mechanism.