Hacker News new | ask | show | jobs
by tomhallett 462 days ago
Is there a git gui/extension/etc which makes exploring the git blame similar to what the author did easier? Here is what I find myself doing often:

- blame on file

- scroll to line 123, click on commit to see the change

- ok, that commit wasn’t the “meaningful change” I’m looking for

- click on parent commit

- browse files (for that sha)

- go to file

- click blame

- scroll to line 123 (or similar)

- repeat

5 comments

"Cregit" tool might be of interest to you, it generates token-based (rather than line-based) git "blame" annotation views: https://github.com/cregit/cregit

Example output based on Linux kernel @ "Cregit-Linux: how code gets into the kernel": https://cregit.linuxsources.org/

I learned of Cregit recently--just submitted it to HN after seeing multiple recent HN comments (yours being one I've had open in a tab for a week to remind me! :) ) discussing issues related to line-based "blame" annotation granularity:

"Cregit-Linux: how code gets into the kernel": https://news.ycombinator.com/item?id=43451654

Perhaps not exactly but you can run:

  git log -L 120,150:filename.txt
To see all commits that have touched lines 120-150 in filename.txt, and see those lines. Gives a view into a subset of lines but won't help if the code in question moved out of the line range.
If I’m looking for code changes:

    git log -S <the-string>
If it’s commit messages I’m interested in:

    git log --grep <the-word-or-phrase>
Sometimes I want to know “all the commits that introduced a pattern”:

    git blame —- $(git grep -P -l 'the.*regex') | grep -P 'the.*regex'
This last one I use frequently enough that I wrote a little shell script for it, called "git-blep" (for "blame-grep")

———

If there’s a function name that you’re logging, then you might get mileage from

   git log -L :<the-function-name>:<the-file-name>
Though that probably would not have worked in the original author’s case.
In Jetbrains you select a line of code and say "show history for selection" and it parses all that for you and just gives you a history of commits affecting that specific line. It's got a built in commit browser and visual diff tool.

Link (not much info there): https://www.jetbrains.com/help/idea/investigate-changes.html...

Not sure about a GUI way of doing this, but in the CLI, I use `git log --patch [path]` all the time. It will show you the history of diffs for that one file.