Jeach
Jeach

Reputation: 9042

Getting a GIT change summary like GitHub

I've got a group of developers which make GIT commit and merge mistakes (once in a while).

I would like to monitor for 'large changes' somehow. I see in GitHub that they have the following line when looking at the details of a specific commit:

Showing 759 changed files with 21,736 additions and 3,237 deletions.

That is an example of a real merge that should have only had 1 file changed and several additions/deletions.

Is there some way or some tool that exists that would send out an alert via email or SMS when a commit breaches a configured threshold?

If not, I was wondering if it was possible to generate that same type of output using the GIT command line. That way, if no tool exists, I can easily script it and send out an email with my own tools.


Update: 2014-03-20 18:52

Based on nulltoken's suggestion, I've tried the following command:

git diff --shortstat $(git rev-parse HEAD HEAD^)

And got exactly what I needed (for the very last commit anyway). Oddly enough though, what I just observed is that GitHub (1) provides the following numbers, compared to what my GIT provides (2):

1 : 759 changed files with 21,736 additions and 3,237 deletions.

2 : 759 files changed, 3237 insertions(+), 21736 deletions(-)

So somebody clearly has a bug! Either GitHub or my GIT (version 1.7.10.4)... funny!


Update: 2014-03-20 19:05

Correction, I simply inverted my hashes and it fixed it... my mistake! No bug to report.

Upvotes: 1

Views: 266

Answers (1)

nulltoken
nulltoken

Reputation: 67599

if it was possible to generate that same type of output using the GIT command line. That way, if no tool exists, I can easily script it and send out an email with my own tools.

You may be after one of the following options of git diff

  • git diff --stat <from_commit> <until_commit>

  • git diff --shortstat <from_commit> <until_commit>


Those commands, when ran against the LibGit2Sharp project, output the following

$ git diff --stat a4c6c45 14ab41c
 LibGit2Sharp.Tests/StashFixture.cs  |  3 ++-
 LibGit2Sharp/Core/NativeMethods.cs  |  8 +++-----
 LibGit2Sharp/Core/Proxy.cs          | 18 +++++++++---
 LibGit2Sharp/ReferenceCollection.cs |  5 ++++-
 4 files changed, 18 insertions(+), 16 deletions(-)

$ git diff --shortstat a4c6c45 14ab41c
 4 files changed, 18 insertions(+), 16 deletions(-)

You'll note that this is pretty much the same content than from the GitHub page showcasing those changes (Note: Clicking on the "Show Diff Stats" will show the per file counts).

Upvotes: 2

Related Questions