git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: hot to get file sizes in git log output

From
DLDavid Lang <david@lang.hm>
Date
Oct 21, 2017, 02:38 UTC
Message-ID
<nycvar.QRO.7.76.6.1710201929210.5973@qynat-yncgbc>
In-Reply-To
<CAPig+cQ56ZNaEOkV+ZCq2KsL-2nTockTrEbqvj=j_wO0YtCx6g@mail.gmail.com>
On Fri, 20 Oct 2017, Eric Sunshine wrote:
Show 17 quoted lines
>>> I'm not exactly sure what you mean by size, but if you want to show
>>> how many lines were added and removed by a given commit for each file,
>>> you can use the "--stat" option to produce a diffstat. The "size" of
>>> the files in each commit isn't very meaningful to the commit itself,
>>> but a stat of how much was removed might be more accurate to what
>>> you're looking for.
>>
>> That's a good suggestion, and hopefully could help David answer his
>> original question.
>>
>> I took the request to mean "walk through history, and for each file that
>> a commit touches, show its size". Which is a bit harder to do, and I
>> think you need to script a little:
>
> David's mention of "a particular file", suggests to me that something
> "bad" happened to one file, and he wants to know in which commit that
> "badness" happened. If so, then it sounds like a job for git-bisect.

In this case, I have git store a copy of the state file for chromium (and do a similar thing for firefox), so that if something bad happens and it crashes and looses all 200-400 tabs in a way that it's recovery doesn't work, I can go back to a prior version.

This is done by having the following crontab entries, along with smudge filters that change the one-line json to pretty printed json before the commit.

0 * * * * dlang cd /home/dlang/.config/chromium/Default; git add *Session *Tabs Bookmarks History ; git commit -mupdate > /dev/null 2>&1
0 0 3 * * dlang cd /home/dlang/.config/chromium/Default; git gc --aggressive > /dev/null 2>&1
0 * * * * dlang cd /home/dlang/.mozilla/firefox/bux6mwl1.default/sessionstore-backups; git add *.js ; git commit -mupdate > /dev/null 2>&1
0 0 3 * * dlang cd /home/dlang/.mozilla/firefox/bux6mwl1.default/sessionstore-backups; git gc --aggressive > /dev/null 2>&1

This has saved me many times in the past. But this time I didn't recognize when the problem happened because instead of a crash, it just closed all the tabs except the one that was open. Once I realized all my other tabs were gone, I didn't have time to mess with it for a few days. So the problem could have happened anytime in the last week or two.

I'm sure that when this happened, the files shrunk drastically (from several hundred tabs to a dozen or so will be very obvious).

But I don't have any specific line I can look at, the lines that are there change pretty regularly, and/or would not have changed at the transition.

git whatchanged shows commits like:
commit fb7e54c12ddc7c87c4862806d583f5c6abf3e731
Author: David Lang <david@lang.hm>
Date:   Fri Oct 20 11:00:01 2017 -0700
     update

:100644 100644 1a842ca... 290e9dd... M Default/Bookmarks :100644 100644 1cd745c... 388a455... M Default/Current Session :100644 100644 51074ad... c4dce40... M Default/Current Tabs

If there was a way to add file size to this output, it would be perfect for what I'm needing.

David Lang
Previous: Jacob KellerNext: David Lang
Message 6 of 8 in “hot to get file sizes in git log output”
  1. David LangOct 20, 2017
  2. Jacob KellerOct 20, 2017
  3. Jeff KingOct 20, 2017
  4. Eric SunshineOct 20, 2017
  5. Jacob KellerOct 20, 2017
  6. David LangOct 21, 2017
  7. David LangOct 21, 2017
  8. Jeff KingOct 21, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.