Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git plumbing command to find out which files have been changed in a given revision

Tags:

git

githooks

I've created a hook that sends out notification emails when a developer pushes an update to his shared repository. This email includes a list of changed files, example:

A   __classes/Page/Activity.php
M   __config/Scheme.php

that I generate using the following bit of bash:

$(git diff "$newrev"^ "$newrev" --name-status)

This works fine. However, I'm trying to port all this now to the well-known post-receive-email hook. This hook does have a hooks.showrev configuration directive, but this I think this only allows for the revision number (%s) to be used once in the command. So this doesn't work:

showrev = "git diff %s^ %s --name-status"

There must be a 'plumbing' command that does just this. Can anyone point me in the right direction? :)

like image 833
Rijk Avatar asked Oct 24 '22 00:10

Rijk


2 Answers

How about using the following?

showrev = "git show --name-status --pretty=format: %s"

git show is porcelain rather than plumbing, but I think this is what you want.

like image 58
Mark Longair Avatar answered Oct 27 '22 09:10

Mark Longair


git whatchanged -1 <rev> might be a good starting point, and has a number of additional options for massaging the output format. Not sure you can get exactly the format you quoted above, but you should be able to get something comparable.

like image 26
twalberg Avatar answered Oct 27 '22 10:10

twalberg