Live data from Hacker News

Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

github.com

71–80 of 130 posts

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#71

Earlier quoted context omitted.

I have seen `git blame` used to blame specific people. I've seen it work. Some of those people deserved some blame. The manpage explains what the command does. How and why it's used is up to the user.

Alternatively git praise https://github.com/ansman/git-praise

Why wouldn’t you just set an alias in your global git config for this?

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#72
post #49

Earlier quoted context omitted.

I'm pretty sure it's about who wrote the code. 'git blame' is named after the subversion and CVS blame features that do the same thing. Subversion docs are clear that it's a snarky name and that 'svn praise' and 'svn annotate' are neutral synonyms. Perhaps someone familiar with CVS can comment on its history there since it seems to be the first source control to add it. EDIT: and one of the main reasons it's a useful…

> EDIT: and one of the main reasons it's a useful feature is it tells you who to talk to to understand a piece of code, or to coordinate a roll back, or to do any other sort of communication. It probably matters more in a big company where code is changing frequently and you're unlikely to know everyone and what they're working on. It's actually a pretty awful feature because it misses so much context. I've been blam…

Just know that it can also be used in very positive ways.

For instance, I may want to change some basic behavior. Easy enough, spend some time implementing and testing, and then run into a downstream consequence of that change while implementing. Now I need to make a decision. Reviewing the history of the relevant sections of code, using git blame, can help me uncover the context and ways in which the code I'm puzzling about changing has changed previously. This can be incredibly valuable and speed up or even obviate an amount of discussion around the potential change.

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#73
post #49

Earlier quoted context omitted.

I'm pretty sure it's about who wrote the code. 'git blame' is named after the subversion and CVS blame features that do the same thing. Subversion docs are clear that it's a snarky name and that 'svn praise' and 'svn annotate' are neutral synonyms. Perhaps someone familiar with CVS can comment on its history there since it seems to be the first source control to add it. EDIT: and one of the main reasons it's a useful…

> EDIT: and one of the main reasons it's a useful feature is it tells you who to talk to to understand a piece of code, or to coordinate a roll back, or to do any other sort of communication. It probably matters more in a big company where code is changing frequently and you're unlikely to know everyone and what they're working on. It's actually a pretty awful feature because it misses so much context. I've been blam…

> It's actually a pretty awful feature

Obligatory T-Shirt link

https://www.amazon.com/Blame-Ruining-Friendships-Since-T-Shi...

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#74
post #10

By the way, git blaming is really misunderstood by a lot of people; its NOT about who did it, its about which commit is to blame -- that's different.

BTW, one of the more frustrating things about "git blame" comes about when cleaning up an old codebase: In my current job I had to move a lot of files, combine repos, reformat code, ect, ect.

"git blame" and similar tools often always show my name, even though I didn't write the code.

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#75
post #74
post #10

By the way, git blaming is really misunderstood by a lot of people; its NOT about who did it, its about which commit is to blame -- that's different.

BTW, one of the more frustrating things about "git blame" comes about when cleaning up an old codebase: In my current job I had to move a lot of files, combine repos, reformat code, ect, ect. "git blame" and similar tools often always show my name, even though I didn't write the code.

Most places I worked have a blame.ignoreRevsFile[0] somewhere on the top level to inhibit this. It's a bit awkward because first you need to commit, then you need commit again to update the commit hash in the ignore revs file, but it's great for filtering out pure refactor churn.

[0] https://git-scm.com/docs/git-blame#Documentation/git-blame.t...

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#76
Tiny prototype implementation:

Run on log from GNU Bison. We anonymize names so that search engines don't index this comment to those names:

  $ ./gwho git-log-stat.txt
  NAME                     LAST-SEEN                      FILES    LINES+   LINES- COMMITS
  A___ D_______            Tue Sep 20 08:19:02 2022 +0200 17083    356066   255931    4440
  P___ E_____              Mon Mar 17 17:46:43 2025 -0700  4496     61898    71486    1123
  J___ E_ D____            Sun Aug 21 17:35:26 2011 -0400  3922     75517    50121     612
  R_____ A_____            Thu May 2 16:43:00 2002 +0000    101      7631     4522      23
  J____ T____              Sun Jan 21 16:43:58 2001 +0000   200      8308     3205      60
  P___ H________           Tue Feb 26 16:28:36 2013 -0800   122      5057     2864      26
  A___ R_______            Wed Jan 5 15:47:25 2011 +0200    124      5297     2101      30
  T________ R______        Tue Nov 13 10:38:49 2012 +0000   229      3841     2744      94
  V_______ T_____          Wed Nov 11 18:55:15 2020 +0100    67      4739     1128      17
  J__ M_______             Sat Jan 18 20:52:21 2020 -0800   337      1569     3894      45
  J___ M_____ G_______     Mon May 12 00:58:38 2008 +0000    91      2570     2060      49
  R______ M_ S_______      Mon Jan 5 00:25:39 1998 +0000    134      2978     1155      64
  P____ B______            Tue Nov 11 13:37:36 2008 +0100    90      2991      786      17
  A____ V___               Mon Sep 19 19:09:20 2022 +0200   130      2335      943      46
  M___ A_____              Sun Jan 20 15:59:34 2002 +0000   201      1797     1291      76
  D____ J__                Sun Dec 7 21:54:45 2008 -0800     57      2142      816      15
  P_____ B___              Fri Oct 19 11:03:50 2001 +0000    67      1771     1182      19
  E___ B____               Thu Aug 27 10:56:53 2009 -0600    61      2172      590      22
  V_____ S_____            Fri Jun 29 16:23:42 2012 +0200    64       865      918       9
  D____ M________          Thu Nov 10 22:34:22 1994 +0000    26      1526       84      18
  D_____ H_________        Thu Jun 13 10:08:19 2013 +0200     6      1142       54       1
  V______ I______          Sat Jan 23 13:25:18 2021 -0500    47       824      360      16
  A_____ V___________      Thu Feb 27 09:52:03 2020 +0100    25       524      189      13
  V_____ M______ C______   Fri Feb 14 18:41:55 2020 +0100    16       284      364       1
  J_____ W___              Tue Feb 16 08:00:28 2021 -0600    18       306       33       3
  W_______ P____           Thu Feb 21 17:08:18 2008 +0000    13       195       76       9
  J___ S____               Wed Jul 26 00:30:05 2017 -0400    67        88       88      63
  E___ S_ R______          Wed Feb 13 10:39:54 2019 -0500     2       133       33       1
  Y_______ K_____          Mon Nov 11 08:57:15 2019 +0900     5       125       13       2
  K______ K_______         Sun Jan 27 06:58:17 2019 +0100     3        85       24       1
  H_ S_ T___               Fri Mar 1 06:16:54 2019 +0100      1        45       51       1
  T__ L__________          Tue Mar 27 19:28:02 2012 +0000     9        81        9       5
  T__ V__ H_____           Fri Jan 11 15:32:06 2002 +0000     7        55       34       3
  A________ D_________     Wed May 14 18:41:48 2003 +0000     3        66       16       1
  L_____ V_____            Fri Aug 9 14:24:14 2019 +0200      8        71        2       2
  M______ D_ B_________    Thu Jul 30 20:53:35 2020 +0200    10        30       29       3
  J______                  Tue Nov 20 22:02:20 2018 +0100     3        30       28       3
  J_______ N_____          Tue Dec 15 22:03:18 2009 -0600    10        42       13       3
  N___ F_______            Mon Sep 6 19:51:09 1993 +0000      7        36       18       7
  K__ K______              Tue Oct 13 15:39:41 2020 -0700     5        26       28       2
  E_____ S________         Mon Dec 10 15:18:37 2018 +0200    10        25       25       1
  M_____ R____             Wed Nov 18 09:10:01 2020 +0100    10        26       13       2
  J___ B_____              Mon Oct 2 20:04:58 2000 +0000      3        26        8       1
  T_____ P________         Tue May 19 22:05:22 2020 +0200     4        29        2       1
  A_____ B_______          Sun Mar 6 22:19:18 2011 -0500      6        24        2       2
  N___ G_____              Tue Oct 27 06:12:27 2020 +0000     4        14       11       3
  B____ K_____             Sat Feb 19 19:24:07 2011 -0500     6        22        2       2
  A___ S______             Wed Oct 31 14:01:31 2018 +0000     1        12        9       1
  S_____ T______           Mon Nov 24 15:27:49 2008 +0100     1        11        6       1
  F______ K____            Tue May 14 00:25:23 2002 +0000     3        11        6       2
  A______ H______          Fri Apr 29 04:08:35 2022 -0400     2         8        6       1
  B____ H_____             Sat Dec 18 18:45:46 2021 +0100     4         3        9       2
  T___ C_ M_____           Tue Nov 10 07:36:11 2020 +0100     2         8        3       1
  E______ S_________       Fri Nov 4 11:50:32 2022 -0700      3         5        5       1
  k_____ y                 Mon Nov 11 23:27:37 2019 +0900     3         3        3       3
  S______ L________        Sat Jul 21 17:24:23 2012 +0200     3         3        3       2
  A____ D_______           Sat Feb 15 10:49:14 2020 +0100     2         2        2       2
  J_____ L_                Fri Aug 24 17:35:32 2018 +0000     1         1        1       1
  D_____ H______           Wed Nov 29 01:26:22 1995 +0000     1         1        1       1
  A______ S_____           Sat Sep 28 00:00:34 2013 +0200     1         1        1       1
  A_____ R___              Mon Jun 14 21:54:40 2021 +0000     1         1        1       1
Code:

  #!/usr/bin/env txr
  @(do
     (defstruct author ()
       name
       e-mail
       last-seen
       (files 0)
       (lines+ 0)
       (lines- 0)
       (commits 0))

     (defvarl ah (hash)))
  @(repeat)
  Author: @name 
  Date: @date
  @(skip)
   @files file@nil changed, @ins insertion@nil, @del deletion@nil
  @  (set name @(flow name ;; anonymize name
                  (spl " ")
                  (map (op map (do if (plusp @2) #\_ @1) @1 0))
                  (join-with " ")))
  @  (do (let ((a (or [ah name]
                      (new author
                           name name
                           e-mail addr
                           last-seen date))))
           (inc a.commits)
           (inc a.files (tointz files))
           (inc a.lines+ (tointz ins))
           (inc a.lines- (tointz del))
           (set [ah name] a)))
  @(end)
  @(do
     (flow (hash-values ah)
       (csort @1 > [callf + .lines+ .lines-])
       (cons (new author
                  name "NAME" last-seen "LAST-SEEN" files "FILES"
                  lines+ "LINES+" lines- "LINES-" commits "COMMITS"))
       (each ((a @1))
         (put-line `@{a.name 24} @{a.last-seen 30} @{a.files -5} \ \
                    @{a.lines+ -8} @{a.lines- -8} @{a.commits -7}`))))

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#77
post #23
post #13

Cool stuff. I like using Git via the CLI, but when it comes to blame, I simply use the preview UI of the VSCode GitLens extension. It takes half a second to launch it from the command palette and inspect the blame.

I have some VS Code extension (errr... not sure which) that faintly inlines the git blame result on each line of code you're working on. I find it kind of handy.

That was actually recently added as a built-in feature

https://code.visualstudio.com/updates/v1_97#_git-blame-infor...

Like the sibling comment, I didn't want to run all of GitLens just for it, but now that it's a built-in I've also been finding it quite useful.

Re: Show HN: "Git who" – A new CLI tool for industrial-scale Git blaming

#80
post #31

I like it. A problem I had right away is some people commit using two different emails. Like one from home computer and one from work computer. Would be nice to be able to define them as the same thing.

Like other commenters have said, mailmap does this and git who will respect your mailmap file.

Like the other comment, this is "I came looking for copper but found gold" moment for me. Thanks!
Post reply on HN