git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gitdiffbinstat  -  git diff --shortstat -like output for changes in binary files
@ 2013-03-29 18:07 Matthias Krüger
  2013-03-29 18:49 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Matthias Krüger @ 2013-03-29 18:07 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 886 bytes --]

I use git mostly for game-development which means I have to deal with a 
lot of binary files (images, sound files etc).

When I came to a point where I had run image optimization on a branch, I 
wanted to know of course how much smaller the new branch was in 
comparison to master.
Problem was that 'git diff --stat' would only summerize per-binary-file 
size changes and 'git diff --shortstat' did skip the binary files entirely.

To solve this problem, I wrote a script ("gitdiffbinstat") which 
basically runs 'git diff --stat' and summerizes the output.

The script can be found here: 
https://github.com/matthiaskrgr/gitdiffbinstat/blob/master/gitdiffbinstat.sh
Screenshot of example output is attached.

I wondered what you guys thought about the script, is there a chance to 
perhaps get it included as some kind of helper script into the official 
git repo?


Regards, Matthias

[-- Attachment #2: screenshot.png --]
[-- Type: image/png, Size: 15497 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gitdiffbinstat  -  git diff --shortstat -like output for changes in binary files
  2013-03-29 18:07 gitdiffbinstat - git diff --shortstat -like output for changes in binary files Matthias Krüger
@ 2013-03-29 18:49 ` Jeff King
  2013-03-29 19:22   ` Matthias Krüger
  2013-03-29 19:30   ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Jeff King @ 2013-03-29 18:49 UTC (permalink / raw)
  To: Matthias Krüger; +Cc: git

On Fri, Mar 29, 2013 at 07:07:32PM +0100, Matthias Krüger wrote:

> I use git mostly for game-development which means I have to deal with
> a lot of binary files (images, sound files etc).
> 
> When I came to a point where I had run image optimization on a
> branch, I wanted to know of course how much smaller the new branch
> was in comparison to master.
> Problem was that 'git diff --stat' would only summerize
> per-binary-file size changes and 'git diff --shortstat' did skip the
> binary files entirely.

Have you tried "--summary"? Combined with --stat (or --shortstat) I
wonder if it would get you closer to what you want.

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gitdiffbinstat  -  git diff --shortstat -like output for changes in binary files
  2013-03-29 18:49 ` Jeff King
@ 2013-03-29 19:22   ` Matthias Krüger
  2013-03-29 19:30   ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Matthias Krüger @ 2013-03-29 19:22 UTC (permalink / raw)
  To: Jeff King; +Cc: git

On 03/29/2013 07:49 PM, Jeff King wrote:
> On Fri, Mar 29, 2013 at 07:07:32PM +0100, Matthias Krüger wrote:
>
>> I use git mostly for game-development which means I have to deal with
>> a lot of binary files (images, sound files etc).
>>
>> When I came to a point where I had run image optimization on a
>> branch, I wanted to know of course how much smaller the new branch
>> was in comparison to master.
>> Problem was that 'git diff --stat' would only summerize
>> per-binary-file size changes and 'git diff --shortstat' did skip the
>> binary files entirely.
> Have you tried "--summary"? Combined with --stat (or --shortstat) I
> wonder if it would get you closer to what you want.
>
> -Peff
No it doesnt.
It appears to append stuff like

  delete mode 100644 sound/music/NewTutorialStage.ogg
  delete mode 100644 src/pngfuncs.c
  delete mode 100644 src/pngfuncs.h
  delete mode 100644 src/widgets/widget_text_list.c
  delete mode 100644 src/widgets/widget_text_list.h

to the stat but does not summarize the binary file size changes.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: gitdiffbinstat  -  git diff --shortstat -like output for changes in binary files
  2013-03-29 18:49 ` Jeff King
  2013-03-29 19:22   ` Matthias Krüger
@ 2013-03-29 19:30   ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2013-03-29 19:30 UTC (permalink / raw)
  To: Jeff King; +Cc: Matthias Krüger, git

Jeff King <peff@peff.net> writes:

>> I use git mostly for game-development which means I have to deal with
>> a lot of binary files (images, sound files etc).
>> 
>> When I came to a point where I had run image optimization on a
>> branch, I wanted to know of course how much smaller the new branch
>> was in comparison to master.
>> Problem was that 'git diff --stat' would only summerize
>> per-binary-file size changes and 'git diff --shortstat' did skip the
>> binary files entirely.
>
> Have you tried "--summary"? Combined with --stat (or --shortstat) I
> wonder if it would get you closer to what you want.

"diff" is not about "how much did my project grow or shink".  If you
moved one block of lines up or down in the same file, you will see
double the number of lines moved in the statistics.

On the other hand, the use case to measure how much it helped to run
png optimizers only cares about the total size.

I do not think it is a good match to present the "binary stat" next
to the textual diff stats in the first place.  Adding two numbers do
not give us any meaningful number.

It is an interesting use case, but it just is not a problem core
Git, which is a source code management system, particularly wants to
bolt on a solution for, that does not mesh well with other parts of
the system.

We do want to make sure that people who want to deal with binaries
have access to raw statistics, so that they can build their solution
on top of, though.  "ls-tree -r -l" gives byte-size of each blob,
and the attribute system can let you tell which paths are binaries.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-29 19:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-29 18:07 gitdiffbinstat - git diff --shortstat -like output for changes in binary files Matthias Krüger
2013-03-29 18:49 ` Jeff King
2013-03-29 19:22   ` Matthias Krüger
2013-03-29 19:30   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).