Context:
Often while investigating an issue, I will introduce debugging statements (isolated from the solution, in their own commits), and then once I have a solution I will remove all these debug statements. Sometimes, however, when viewing a diff or a blame, it is unclear which changes were introduced in debugging and which were intended as part of the solution. In this case I would like to determine, for any specific commit or set of commits, which lines (if any) were changed in that commit and not changed again later. This way I can be sure that all of the debug changes have been correctly reverted.
Ordinarily, I would simply revert the commits through git, but especially when spending a long time on a solution, alternating between fixing and debugging, there will likely be code-changing commits which remove lines introduced in debugging, making git revert
non-trivial.
Summary:
I would like to see any lines in any files in a repository, which would be labelled with one of a specific set of commits in a git blame
. That is to say, any lines which were touched by a given commit and not changed since. Currently, my workflow is as follows:
git log
#record short hashes of the commits i'm interested in
for each hash:
git show --name-only $hash
#record files affected
for each file:
git blame -- "$file" | grep $hash