I have a pretty weird problem with git.
When I use the command:
git show {number of commit}
It shows me a commit that I made, and in this commit, I can clearly see that I used the "boolToString" function. With applies that the commit is existing. But when I use
git log -S boolToString {path to file}
it does not find commit with this change. The path to file is correct because if I type some phrase that was there before my commit it is returning results. Does any of you come with a problem similar to mine? I would be more than thankful for any hints or ideas about what's going on.
I suspect History Simplification:
git log -S boolToString {path to file}
Any time you run git log [options] [--] path
, git log
turns on History Simplification. The goal of this simplification is to explain why your file looks the way it does now. This means that if what you are trying to figure out is why a line you added, some time ago, has gone missing, you may get no output. This happens when the line you added got removed during a git merge
operation.
(I consider this a failure to meet the goal of explaining why the file is as it is now, but it is what it is.)
To find the merge in which the line was removed from the file, use:
git log -S boolToString --full-history -m -- path/to/file
The --full-history
option turns off History Simplification, and the -m
makes Git examine the merge commits so that you can see the line vanish.
The -S
option looks for commits that change the number of occurrences of some string. That is:
git log -S boolToString
will show commits where boolToString
is in a +
line that is not balanced out by a corresponding -
line, in the diff output, or vice versa. If you're looking for a place where you made a change to one of the arguments to boolToString
, for instance, you want git log -G
rather than git log -S
.