{"thread":{"id":"47008","subject":"hot to get file sizes in git log output","startedAt":"2017-10-20T18:27:41Z","lastAt":"2017-10-21T03:25:12Z","messageCount":8,"participants":["David Lang","Jacob Keller","Jeff King","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"330736","messageId":"nycvar.QRO.7.76.6.1710201105351.5973@qynat-yncgbc","threadId":"47008","inReplyTo":null,"subject":"hot to get file sizes in git log output","fromName":"David Lang","fromEmail":"david@lang.hm","sentAt":"2017-10-20T18:12:34Z","receivedAt":"2017-10-20T18:27:41Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"I'm needing to scan through git history looking for the file sizes (looking for \nwhen a particular file shrunk drastically)\n\nI'm not seeing an option in git log or git whatchanged that gives me the file \nsize, am I overlooking something?\n\nDavid Lang\n"},{"id":"330740","messageId":"CA+P7+xpdWJbxtxAggRpYR3eE8qjH6TfbYQS_=20aZM7d2RbC0Q@mail.gmail.com","threadId":"47008","inReplyTo":"nycvar.QRO.7.76.6.1710201105351.5973@qynat-yncgbc","subject":"Re: hot to get file sizes in git log output","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-10-20T20:44:36Z","receivedAt":"2017-10-20T20:45:03Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Oct 20, 2017 at 11:12 AM, David Lang <david@lang.hm> wrote:\n> I'm needing to scan through git history looking for the file sizes (looking\n> for when a particular file shrunk drastically)\n>\n> I'm not seeing an option in git log or git whatchanged that gives me the\n> file size, am I overlooking something?\n>\n> David Lang\n\nI'm not exactly sure what you mean by size, but if you want to show\nhow many lines were added and removed by a given commit for each file,\nyou can use the \"--stat\" option to produce a diffstat. The \"size\" of\nthe files in each commit isn't very meaningful to the commit itself,\nbut a stat of how much was removed might be more accurate to what\nyou're looking for.\n\nThanks,\nJake\n"},{"id":"330745","messageId":"20171020214312.3kb3ncz2ks7mfxw4@sigill.intra.peff.net","threadId":"47008","inReplyTo":"CA+P7+xpdWJbxtxAggRpYR3eE8qjH6TfbYQS_=20aZM7d2RbC0Q@mail.gmail.com","subject":"Re: hot to get file sizes in git log output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-10-20T21:43:12Z","receivedAt":"2017-10-20T21:43:19Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 20, 2017 at 01:44:36PM -0700, Jacob Keller wrote:\n\n> On Fri, Oct 20, 2017 at 11:12 AM, David Lang <david@lang.hm> wrote:\n> > I'm needing to scan through git history looking for the file sizes (looking\n> > for when a particular file shrunk drastically)\n> >\n> > I'm not seeing an option in git log or git whatchanged that gives me the\n> > file size, am I overlooking something?\n> >\n> > David Lang\n> \n> I'm not exactly sure what you mean by size, but if you want to show\n> how many lines were added and removed by a given commit for each file,\n> you can use the \"--stat\" option to produce a diffstat. The \"size\" of\n> the files in each commit isn't very meaningful to the commit itself,\n> but a stat of how much was removed might be more accurate to what\n> you're looking for.\n\nThat's a good suggestion, and hopefully could help David answer his\noriginal question.\n\nI took the request to mean \"walk through history, and for each file that\na commit touches, show its size\". Which is a bit harder to do, and I\nthink you need to script a little:\n\n  git rev-list HEAD |\n  git diff-tree --stdin -r |\n  perl -lne '\n    # raw diff line, capture filename and post-image sha1\n    if (/^:\\S+ \\S+ \\S+ (\\S+) \\S+\\t(.*)/) {\n      print \"$1 $commit:$2\"\n    }\n    # otherwise it is a commit sha1\n    else {\n      $commit = $_;\n    }\n  ' |\n  git cat-file --batch-check='%(objectsize) %(rest)'\n\nThat should show the size of each file along with the \"commit:path\" in\nwhich it was introduced.\n\n-Peff\n"},{"id":"330749","messageId":"CAPig+cQ56ZNaEOkV+ZCq2KsL-2nTockTrEbqvj=j_wO0YtCx6g@mail.gmail.com","threadId":"47008","inReplyTo":"20171020214312.3kb3ncz2ks7mfxw4@sigill.intra.peff.net","subject":"Re: hot to get file sizes in git log output","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2017-10-20T21:50:41Z","receivedAt":"2017-10-20T21:54:43Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Oct 20, 2017 at 5:43 PM, Jeff King <peff@peff.net> wrote:\n> On Fri, Oct 20, 2017 at 01:44:36PM -0700, Jacob Keller wrote:\n>> On Fri, Oct 20, 2017 at 11:12 AM, David Lang <david@lang.hm> wrote:\n>> > I'm needing to scan through git history looking for the file sizes (looking\n>> > for when a particular file shrunk drastically)\n>> >\n>> > I'm not seeing an option in git log or git whatchanged that gives me the\n>> > file size, am I overlooking something?\n>>\n>> I'm not exactly sure what you mean by size, but if you want to show\n>> how many lines were added and removed by a given commit for each file,\n>> you can use the \"--stat\" option to produce a diffstat. The \"size\" of\n>> the files in each commit isn't very meaningful to the commit itself,\n>> but a stat of how much was removed might be more accurate to what\n>> you're looking for.\n>\n> That's a good suggestion, and hopefully could help David answer his\n> original question.\n>\n> I took the request to mean \"walk through history, and for each file that\n> a commit touches, show its size\". Which is a bit harder to do, and I\n> think you need to script a little:\n\nDavid's mention of \"a particular file\", suggests to me that something\n\"bad\" happened to one file, and he wants to know in which commit that\n\"badness\" happened. If so, then it sounds like a job for git-bisect.\n"},{"id":"330750","messageId":"CA+P7+xqx3EDbRKq7rwHXn9qeqVTZCZr2vYZ_63THC+UEL5q2Yw@mail.gmail.com","threadId":"47008","inReplyTo":"CAPig+cQ56ZNaEOkV+ZCq2KsL-2nTockTrEbqvj=j_wO0YtCx6g@mail.gmail.com","subject":"Re: hot to get file sizes in git log output","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-10-20T21:54:29Z","receivedAt":"2017-10-20T21:54:56Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Oct 20, 2017 at 2:50 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:\n> On Fri, Oct 20, 2017 at 5:43 PM, Jeff King <peff@peff.net> wrote:\n>> On Fri, Oct 20, 2017 at 01:44:36PM -0700, Jacob Keller wrote:\n>>> On Fri, Oct 20, 2017 at 11:12 AM, David Lang <david@lang.hm> wrote:\n>>> > I'm needing to scan through git history looking for the file sizes (looking\n>>> > for when a particular file shrunk drastically)\n>>> >\n>>> > I'm not seeing an option in git log or git whatchanged that gives me the\n>>> > file size, am I overlooking something?\n>>>\n>>> I'm not exactly sure what you mean by size, but if you want to show\n>>> how many lines were added and removed by a given commit for each file,\n>>> you can use the \"--stat\" option to produce a diffstat. The \"size\" of\n>>> the files in each commit isn't very meaningful to the commit itself,\n>>> but a stat of how much was removed might be more accurate to what\n>>> you're looking for.\n>>\n>> That's a good suggestion, and hopefully could help David answer his\n>> original question.\n>>\n>> I took the request to mean \"walk through history, and for each file that\n>> a commit touches, show its size\". Which is a bit harder to do, and I\n>> think you need to script a little:\n>\n> David's mention of \"a particular file\", suggests to me that something\n> \"bad\" happened to one file, and he wants to know in which commit that\n> \"badness\" happened. If so, then it sounds like a job for git-bisect.\n\nYea, if you have a simple script which can tell when the file is\n\"bad\", you could run it through git bisect run pretty easily and\nrapidly find the right answer.\n\nThanks,\nJake\n"},{"id":"330766","messageId":"nycvar.QRO.7.76.6.1710201929210.5973@qynat-yncgbc","threadId":"47008","inReplyTo":"CAPig+cQ56ZNaEOkV+ZCq2KsL-2nTockTrEbqvj=j_wO0YtCx6g@mail.gmail.com","subject":"Re: hot to get file sizes in git log output","fromName":"David Lang","fromEmail":"david@lang.hm","sentAt":"2017-10-21T02:38:00Z","receivedAt":"2017-10-21T02:38:30Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"On Fri, 20 Oct 2017, Eric Sunshine wrote:\n\n>>> I'm not exactly sure what you mean by size, but if you want to show\n>>> how many lines were added and removed by a given commit for each file,\n>>> you can use the \"--stat\" option to produce a diffstat. The \"size\" of\n>>> the files in each commit isn't very meaningful to the commit itself,\n>>> but a stat of how much was removed might be more accurate to what\n>>> you're looking for.\n>>\n>> That's a good suggestion, and hopefully could help David answer his\n>> original question.\n>>\n>> I took the request to mean \"walk through history, and for each file that\n>> a commit touches, show its size\". Which is a bit harder to do, and I\n>> think you need to script a little:\n>\n> David's mention of \"a particular file\", suggests to me that something\n> \"bad\" happened to one file, and he wants to know in which commit that\n> \"badness\" happened. If so, then it sounds like a job for git-bisect.\n\nIn this case, I have git store a copy of the state file for chromium (and do a \nsimilar thing for firefox), so that if something bad happens and it crashes and \nlooses all 200-400 tabs in a way that it's recovery doesn't work, I can go back \nto a prior version.\n\nThis is done by having the following crontab entries, along with smudge filters \nthat change the one-line json to pretty printed json before the commit.\n\n0 * * * * dlang cd /home/dlang/.config/chromium/Default; git add *Session *Tabs Bookmarks History ; git commit -mupdate > /dev/null 2>&1\n\n0 0 3 * * dlang cd /home/dlang/.config/chromium/Default; git gc --aggressive > /dev/null 2>&1\n\n0 * * * * dlang cd /home/dlang/.mozilla/firefox/bux6mwl1.default/sessionstore-backups; git add *.js ; git commit -mupdate > /dev/null 2>&1\n\n0 0 3 * * dlang cd /home/dlang/.mozilla/firefox/bux6mwl1.default/sessionstore-backups; git gc --aggressive > /dev/null 2>&1\n\nThis has saved me many times in the past. But this time I didn't recognize when \nthe problem happened because instead of a crash, it just closed all the tabs \nexcept the one that was open. Once I realized all my other tabs were gone, I \ndidn't have time to mess with it for a few days. So the problem could have \nhappened anytime in the last week or two.\n\nI'm sure that when this happened, the files shrunk drastically (from several \nhundred tabs to a dozen or so will be very obvious).\n\nBut I don't have any specific line I can look at, the lines that are there \nchange pretty regularly, and/or would not have changed at the transition.\n\ngit whatchanged shows commits like:\n\ncommit fb7e54c12ddc7c87c4862806d583f5c6abf3e731\nAuthor: David Lang <david@lang.hm>\nDate:   Fri Oct 20 11:00:01 2017 -0700\n\n     update\n\n:100644 100644 1a842ca... 290e9dd... M  Default/Bookmarks\n:100644 100644 1cd745c... 388a455... M  Default/Current Session\n:100644 100644 51074ad... c4dce40... M  Default/Current Tabs\n\nIf there was a way to add file size to this output, it would be perfect for what \nI'm needing.\n\nDavid Lang\n"},{"id":"330767","messageId":"nycvar.QRO.7.76.6.1710201940440.5973@qynat-yncgbc","threadId":"47008","inReplyTo":"nycvar.QRO.7.76.6.1710201929210.5973@qynat-yncgbc","subject":"Re: hot to get file sizes in git log output","fromName":"David Lang","fromEmail":"david@lang.hm","sentAt":"2017-10-21T02:43:22Z","receivedAt":"2017-10-21T02:43:37Z","isPatch":false,"sender":{"key":"david@lang.hm","avatar":null},"body":"On Fri, 20 Oct 2017, David Lang wrote:\n\n> On Fri, 20 Oct 2017, Eric Sunshine wrote:\n>\n>>>> I'm not exactly sure what you mean by size, but if you want to show\n>>>> how many lines were added and removed by a given commit for each file,\n>>>> you can use the \"--stat\" option to produce a diffstat. The \"size\" of\n>>>> the files in each commit isn't very meaningful to the commit itself,\n>>>> but a stat of how much was removed might be more accurate to what\n>>>> you're looking for.\n>>> \n>>> That's a good suggestion, and hopefully could help David answer his\n>>> original question.\n>>> \n>>> I took the request to mean \"walk through history, and for each file that\n>>> a commit touches, show its size\". Which is a bit harder to do, and I\n>>> think you need to script a little:\n>> \n>> David's mention of \"a particular file\", suggests to me that something\n>> \"bad\" happened to one file, and he wants to know in which commit that\n>> \"badness\" happened. If so, then it sounds like a job for git-bisect.\n\nsummarizing (and removing the long explination of why I'm doing this)\n\nfor each file (or each file changed in the commit), what is the byte count of \nthat file at the time of that commit.\n\ngit whatschanged currently reports\n\ncommit 17be1c1e1f80086e8ddda1706c8c8d6cf80d26b7\nAuthor: David Lang <david@lang.hm>\nDate:   Thu Oct 19 22:00:01 2017 -0700\n\n     update\n\n:100644 100644 bb9dcd3... 8635d2b... M  Default/Current Session\n\ncommit d3f94d406e0d5c6ee7b6f6bcea019adff438127c\nAuthor: David Lang <david@lang.hm>\nDate:   Thu Oct 19 21:00:01 2017 -0700\n\n     update\n\n:100644 100644 88ece53... bb9dcd3... M  Default/Current Session\n\ncommit fea290bd235a444bbd4bc4430fa0844501ae2b8c\nAuthor: David Lang <david@lang.hm>\nDate:   Thu Oct 19 06:00:01 2017 -0700\n\n     update\n\n:100644 100644 ff04089... 88ece53... M  Default/Current Session\n\nwhat is the size of the file \"Current Session\" for each commit?\n\nDavid Lang\n"},{"id":"330772","messageId":"20171021032505.e6vysjteesr4r5pj@sigill.intra.peff.net","threadId":"47008","inReplyTo":"nycvar.QRO.7.76.6.1710201929210.5973@qynat-yncgbc","subject":"Re: hot to get file sizes in git log output","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2017-10-21T03:25:05Z","receivedAt":"2017-10-21T03:25:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 20, 2017 at 07:38:00PM -0700, David Lang wrote:\n\n> git whatchanged shows commits like:\n> \n> commit fb7e54c12ddc7c87c4862806d583f5c6abf3e731\n> Author: David Lang <david@lang.hm>\n> Date:   Fri Oct 20 11:00:01 2017 -0700\n> \n>     update\n> \n> :100644 100644 1a842ca... 290e9dd... M  Default/Bookmarks\n> :100644 100644 1cd745c... 388a455... M  Default/Current Session\n> :100644 100644 51074ad... c4dce40... M  Default/Current Tabs\n> \n> If there was a way to add file size to this output, it would be perfect for\n> what I'm needing.\n\nThere isn't. You'll have to process the output to pass the post-image\nhashes to cat-file to get the size (i.e., what I showed before, though\nof course you could make the output prettier if you wanted to).\n\n-Peff\n"}]}