Skip to content

Skip commits in blame view

Problem

I want to find out what commit introduced a certain function / line of code / etc, or changed it to include a new wording / parameter / etc, and what the context or reason was (linked issues, commit message). Naturally, I head over to the blame view for that file, wait until it loads, and scroll down to the line in question. However, often enough the blamed commit is insignificant and does not interest me. It fixed a typo in a comment, renamed a variable, or refactored whitespaces. I want to skip that commit, and look at the history of edits ignoring this one.

Current workflow

What I do to get the answers I am looking for is to get to the blame view of the file in the prior commit (the parent of the one I am looking to ignore). Please call out on me if that's dumb and there's a much easier way :-) Regardless, starting from the blame view I do the following steps:

  1. Click on the link to the commit that is blamed to last have changed the interesting line
  2. Recognise that this commit is not relevant (though usually that already follows from the commit message)
  3. Scroll down to the file with the interesting line - the commit may have changed a lot
  4. Click the "view file @commit" button
  5. [Sometimes, scroll down to the interesting section and assure that the context is still the expected one (i.e. a version between HEAD and the commit I'm looking for)]
  6. Remember that hitting "blame" now would just blame the interesting line to the commit I'm currently viewing
  7. Click the "History" button, which takes me to the commit history for this file, starting with the commit I just viewed
  8. Click the "Browse file" button at the second commit shown, i.e. the one prior to the one I just viewed
  9. Click the "Blame" button
  10. Scroll down to the line in question, now being blamed to an earlier commit
  11. Rinse and repeat for every irrelevant commit, until I find the commit I was looking for

You get that this is not satisfactory for me :-)

Ideas

I can think of several ways to improve this flow. Maybe I'm completely on the wrong track and you find a much better solution to my problem, but still here they are:

  • the optimal feature would be a "follow this line through time" (context menu?) option, that takes me to a view with all commits that changed something there (or in its vicinity), showing every version or a diff of the respective region.
  • also nice would be a filter option for blame so that it disregards a) commits whose messages contain certain chosable keywords ("cleanup", "typo", etc) b) dynamically selected commits (with an "add to ignore" button right in every blamed section)

I have no idea how feasible those are. There might be some issues with merge commits (which parent to choose when the merge is ignored?), but I suspect my current workflow doesn't handle them well either. Maybe those things are possible with the command line version of git blame, but the web view has a much better UI (and feature discoverability).

But there are also some small (simple) improvements that would make my current approach easier:

  • Avoid step 3: the commit link in the blame view should take me directly to the diff of the file (or line) I was viewing
  • Combine steps 1-4: there should be a direct "view file at this revision" link in the blame view, possibly even with line number again (avoiding step 5)
  • Combine steps 7-8: there could be an (arrow?) navigation to the next child(ren)/parent(s) versions of the current file
  • Combine steps 6-9: there could be a "blame parent" button that takes one to the blame view for the predecessor version (or multiple buttons in case of a merge commit?). Maybe that button should be placed in the context of the version navigation.
  • Combine steps 1-10: add a direct "blame prior to this commit" link in the blame view

Maybe my problem feels familiar to you. I hope to spark some ideas!