{"thread":{"id":"15816","subject":"git-who","startedAt":"2008-10-07T21:02:46Z","lastAt":"2008-10-08T18:35:53Z","messageCount":7,"participants":["Rhodes, Kate","Miklos Vajna","Jeff King","Johannes Sixt","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"92564","messageId":"DE2CF127-A7FD-4765-A8E4-5235C5F1B9A9@gmail.com","threadId":"15816","inReplyTo":null,"subject":"git-who","fromName":"Rhodes, Kate","fromEmail":"masukomi@gmail.com","sentAt":"2008-10-07T21:02:46Z","receivedAt":"2008-10-07T21:02:46Z","isPatch":false,"sender":{"key":"masukomi@gmail.com","avatar":null},"body":"Once upon a someone asked about seeing who had touched some files.  \nPetr Baudis responded with a quickie script that did the job. I've  \nsince expanded upon it a little, and since I find it pretty useful, I  \nfigured I'd send it back for others to use too.\n\nAs is it's probably not worth including in git, but I'm thinking that  \nsomeone else can probably come up with some improvements, such as  \ndates in the verbose mode, support for a treeish instead of a single  \nfile path, and / or rewriting it in C so that it can work on Windows.\n\nhttp://github.com/masukomi/git_accessories/tree/master\ngit://github.com/masukomi/git_accessories.git\n\nNot that it's particularly worthy of it's own repo at the moment, but  \nI figure I'll continue to keep poking it from time to time...\n\n-masukomi\n"},{"id":"92573","messageId":"20081007223530.GF536@genesis.frugalware.org","threadId":"15816","inReplyTo":"DE2CF127-A7FD-4765-A8E4-5235C5F1B9A9@gmail.com","subject":"Re: git-who","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-10-07T22:35:30Z","receivedAt":"2008-10-07T22:35:30Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Oct 07, 2008 at 05:02:46PM -0400, \"Rhodes, Kate\" <masukomi@gmail.com> wrote:\n> the verbose mode, support for a treeish instead of a single file path, and \n> / or rewriting it in C so that it can work on Windows.\n\nI thought - based on this - that it's written in ruby or something, but\nit's just shell and perl, so probably it works in Windows as well\nwithout any kind of rewrite.\n"},{"id":"92577","messageId":"20081008022505.GB29313@coredump.intra.peff.net","threadId":"15816","inReplyTo":"DE2CF127-A7FD-4765-A8E4-5235C5F1B9A9@gmail.com","subject":"Re: git-who","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-10-08T02:25:05Z","receivedAt":"2008-10-08T02:25:05Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Oct 07, 2008 at 05:02:46PM -0400, Kate Rhodes wrote:\n\n> As is it's probably not worth including in git, but I'm thinking that  \n> someone else can probably come up with some improvements, such as dates in \n> the verbose mode, support for a treeish instead of a single file path, and \n> / or rewriting it in C so that it can work on Windows.\n\nScripts like this often find a good home in git's contrib/ directory.\nConsider submitting a patch which adds it there.\n\n> git://github.com/masukomi/git_accessories.git\n\nI took a look. My biggest complaint is that for many files, it produces\ntoo many names. It would be nice to at least sort the names by number\nof commits. But even more accurate might be the number of added lines.\nSomebody who creates a 200-line file should surely come before somebody\nwho made a 1-line tweak, right?\n\nBut perhaps even more accurate would be to rely on blame output, since\nit attributes not just added lines, but lines which have actually\nsurvived into the current product. And fortunately that is relatively\neasy to do (only lightly tested):\n\n-- >8 --\n#!/usr/bin/perl\n#\n# Invoke as 'git who -M -C file.c' (or whichever blame options\n# you prefer). You can even check a particular set of lines\n# with \"git who -M -C -L 40,60 file.c\".\n\nuse strict;\n\nopen(my $in, '-|', qw(git blame -p), @ARGV);\n\nmy %count;\nmy %author;\nmy $current_sha1;\nwhile(<$in>) {\n  if (!$current_sha1) {\n    /^[0-9a-f]{40}/ or die \"expected sha1, got $_\";\n    $current_sha1 = $&;\n    $count{$current_sha1}++;\n  }\n  elsif (/^author (.*)/) {\n    $author{$current_sha1} = $1;\n  }\n  elsif (/^\\t/) {\n    $current_sha1 = undef;\n  }\n}\n\nmy %acount;\nwhile(my ($h, $c) = each %count) {\n  $acount{$author{$h}} += $c;\n}\n\nforeach (sort { $acount{$b} <=> $acount{$a} } keys %acount) {\n  print \"$_ ($acount{$_})\\n\";\n}\n"},{"id":"92578","messageId":"70ED45EF-54B8-42D9-98BA-F2E98C786419@gmail.com","threadId":"15816","inReplyTo":"20081008022505.GB29313@coredump.intra.peff.net","subject":"Re: git-who","fromName":"Rhodes, Kate","fromEmail":"masukomi@gmail.com","sentAt":"2008-10-08T04:59:45Z","receivedAt":"2008-10-08T04:59:45Z","isPatch":false,"sender":{"key":"masukomi@gmail.com","avatar":null},"body":"\nOn Oct 7, 2008, at 10:25 PM, Jeff King wrote:\n\n> On Tue, Oct 07, 2008 at 05:02:46PM -0400, Kate Rhodes wrote:\n>\n>> As is it's probably not worth including in git, but I'm thinking that\n>> someone else can probably come up with some improvements, such as  \n>> dates in\n>> the verbose mode, support for a treeish instead of a single file  \n>> path, and\n>> / or rewriting it in C so that it can work on Windows.\n>\n> Scripts like this often find a good home in git's contrib/ directory.\n> Consider submitting a patch which adds it there.\n>\n>> git://github.com/masukomi/git_accessories.git\n>\n> I took a look. My biggest complaint is that for many files, it  \n> produces\n> too many names.\n\nYeah, I agree, I just haven't come up with a better idea that  \naddresses the question of \"who touched this\". Maybe some sort of  \nrecency toggle.\n\n> It would be nice to at least sort the names by number\n> of commits. But even more accurate might be the number of added lines.\n> Somebody who creates a 200-line file should surely come before  \n> somebody\n> who made a 1-line tweak, right?\n\nYeah, I've considered maybe adding a -n (number) like that and  \nordering people by number of commits. I'm not convinced that, in most  \ncases, size of changes is as important as number.  I think it depends  \non the file. In some cases a person who's constantly mucking about  \nwith the file is a better go-to person when you have questions /  \nissues, than someone who happened to make a few large commits a while  \nago. But then again....\n\n\n>\n> But perhaps even more accurate would be to rely on blame output, since\n> it attributes not just added lines, but lines which have actually\n> survived into the current product.\n\nmmm good idea.\n\n\n> And fortunately that is relatively\n> easy to do (only lightly tested):\n\nexcellent! Thank you. I'll poke at this tomorrow. :)\n\n-masukomi\n\n>\n>\n> -- >8 --\n> #!/usr/bin/perl\n> #\n> # Invoke as 'git who -M -C file.c' (or whichever blame options\n> # you prefer). You can even check a particular set of lines\n> # with \"git who -M -C -L 40,60 file.c\".\n>\n> use strict;\n>\n> open(my $in, '-|', qw(git blame -p), @ARGV);\n>\n> my %count;\n> my %author;\n> my $current_sha1;\n> while(<$in>) {\n>  if (!$current_sha1) {\n>    /^[0-9a-f]{40}/ or die \"expected sha1, got $_\";\n>    $current_sha1 = $&;\n>    $count{$current_sha1}++;\n>  }\n>  elsif (/^author (.*)/) {\n>    $author{$current_sha1} = $1;\n>  }\n>  elsif (/^\\t/) {\n>    $current_sha1 = undef;\n>  }\n> }\n>\n> my %acount;\n> while(my ($h, $c) = each %count) {\n>  $acount{$author{$h}} += $c;\n> }\n>\n> foreach (sort { $acount{$b} <=> $acount{$a} } keys %acount) {\n>  print \"$_ ($acount{$_})\\n\";\n> }\n"},{"id":"92581","messageId":"48EC4F9D.4020202@viscovery.net","threadId":"15816","inReplyTo":"DE2CF127-A7FD-4765-A8E4-5235C5F1B9A9@gmail.com","subject":"Re: git-who","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-10-08T06:13:49Z","receivedAt":"2008-10-08T06:13:49Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Rhodes, Kate schrieb:\n> Once upon a someone asked about seeing who had touched some files. Petr\n> Baudis responded with a quickie script that did the job.\n\nWouldn't\n\n   git shortlog -s -- path/to/file\n\nsolve your problem?\n\n-- Hannes\n"},{"id":"92620","messageId":"8323B5AF-AECC-4576-BA85-382BAD8FE74B@gmail.com","threadId":"15816","inReplyTo":"48EC4F9D.4020202@viscovery.net","subject":"Re: git-who","fromName":"Rhodes, Kate","fromEmail":"masukomi@gmail.com","sentAt":"2008-10-08T13:48:12Z","receivedAt":"2008-10-08T13:48:12Z","isPatch":false,"sender":{"key":"masukomi@gmail.com","avatar":null},"body":"\nNo. No, that's far too simple.\n\n\n;)\n\n-Kate\n\nOn Oct 8, 2008, at 2:13 AM, Johannes Sixt wrote:\n> Rhodes, Kate schrieb:\n>> Once upon a someone asked about seeing who had touched some files.  \n>> Petr\n>> Baudis responded with a quickie script that did the job.\n>\n> Wouldn't\n>\n>   git shortlog -s -- path/to/file\n>\n> solve your problem?\n>\n> -- Hannes\n>\n"},{"id":"92626","messageId":"alpine.LFD.2.00.0810081119490.3208@nehalem.linux-foundation.org","threadId":"15816","inReplyTo":"48EC4F9D.4020202@viscovery.net","subject":"Re: git-who","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-10-08T18:35:53Z","receivedAt":"2008-10-08T18:35:53Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 8 Oct 2008, Johannes Sixt wrote:\n> \n> Wouldn't\n> \n>    git shortlog -s -- path/to/file\n\nI suspect \"-sn\" is better. It sorts by number rather than by name, and if \nyou're interested in who has touched a file, you probably wants to know \nwho has touched it _most_.\n\nAnd as usual, the nice thing about it is that all the normal git rules \napply, so you can do it by multiple files or subdirectories, and you can \nfilter by time. And ignore merges, since they tend to be about upper-level \nmaintainers than about the people doing patches.\n\nSo for the kernel, you can do something like\n\n\tgit shortlog -ns --no-merges --since=6.months.ago drivers/scsi include/scsi\n\nand see who has been doing scsi-related stuff lately.\n\nOf course, when it comes to relevance, it may be more interesting to just \nlook at 'git blame' output, and then you're limited to single files at a  \ntime. And performance is going to be a problem, especially if you enable \nmovement detection. \n\nBut we don't have anything special for that. You can do it with something \nlike\n\n\tgit blame -M -w kernel/sched.c |\n\t\tgrep -v '^^' |\n\t\tcut -d'(' -f2- |\n\t\tcut -c1-20 |\n\t\tsort |\n\t\tuniq -c |\n\t\tsort -n\n\nwhich will ignore the root commit (so as not to give me all the credit for \nold history), but it would probably be better (but more complex - need \nperl or some other \"real\" language with associative arrays etc to remember \nthe commit information) to parse the output of \"git blame --incremental\" \ninstead.\n\n\t\tLinus\n"}]}