Re:Show HN: git self-blame – Blame yourself for others' mist...
by dh-g on Thursday February 22, 2018 @04:08PM
(#16441418)
Not in the spirit of the project but I would like to see an alias added to the README to replace `git blame` (to run on your own / teammates / friends computers).
[ Parent
| on HN ]
Re:Show HN: git self-blame – Blame yourself for others' mist...
by jacobevelyn on Thursday February 22, 2018 @04:34PM
(#16441606)
Heh, I actually looked into that but it's not so easy. See: https://stackoverflow.com/a/3538791/1103543
So even if this script is the absolute first thing in your $PATH, `git blame` will always call the builtin rather than this. There are probably more involved ways to make this happen the way you want (like create a different `git` program that shells everything out to the real one except the `blame` command) but I wasn't sure I wanted to go down that rabbit hole.
Feel free to submit a PR if you find a simpler way though!
Re:Show HN: git self-blame – Blame yourself for others' mist...
by pcthrowaway on Thursday February 22, 2018 @05:10PM
(#16441952)
If they're using bash, it shouldn't be so hard. Just put something like this in your/their bashrc
git() {
if [[ $1 == blame ]]; then
shift
git self-blame "${@}"
else
command git "${@}"
fi
}
edit: this isn't 100% perfect as it won't work (but won't break git either) in situations where the user uses a global flag in addition to blame. I've been using git for years though and the only global flag I've used are --version and --help
Re:Show HN: git self-blame – Blame yourself for others' mist...
by jacobevelyn on Thursday February 22, 2018 @07:05PM
(#16442847)
Awesome, thanks for sharing! My Bash skills definitely have lots of room for improvement—I think I learned at least three new things from your comment alone. :)
I too had never really used global git flags until they came in very handy for `git self-blame`!
Re:Show HN: git self-blame – Blame yourself for others' mist...
by sinisterShroom on Friday February 23, 2018 @01:38PM
(#16448284)
https://github.com/ccraciun/git-blame-bob
Just rename/symlink git-blame-bob to git-blame-joe
Re:Show HN: git self-blame – Blame yourself for others' mist...
by jacobevelyn on Saturday February 24, 2018 @10:47AM
(#16453719)
Hahaha love it. :)