0

From the pull request found in here we can see that in the file

/java/org/wso2/carbon/analytics/apim/internal/TemplateManagerInitializerComponent.java

38,39 and 40 lines have been deleted. Now I need to identify the commit hash (hashes) which added those lines (deleted 38,39 and 40 lines) to the file, but the blame view for the file shown in here does not show the history for the deleted lines . How to get this information from github. Thanks in advance

Kasun Siyambalapitiya
  • 3,956
  • 8
  • 38
  • 58

1 Answers1

0

Try git log -S <string> :

git log -S "import javax.xml.bind.JAXBException"

quoting the doc (git help log) about -S and its cousin -G :

-S<string>
Look for differences that change the number of occurrences of the specified string (i.e. addition/deletion) in a file. Intended for the scripter’s use.

It is useful when you’re looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into -S, and keep going until you get the very first version of the block.

-G<regex>
Look for differences whose patch text contains added/removed lines that match <regex>.

To illustrate the difference between -S<regex> --pickaxe-regex and -G<regex>, consider a commit with the following diff in the same file:

+    return !regexec(regexp, two->ptr, 1, &regmatch, 0);
     ...
-    hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);

While git log -G"regexec\(regexp" will show this commit,
git log -S"regexec\(regexp" --pickaxe-regex will not (because the number of occurrences of that string did not change).

See the pickaxe entry in gitdiffcore(7) for more information.

LeGEC
  • 46,477
  • 5
  • 57
  • 104