Reputation: 45484
The command git show --pretty="format:" --name-status bd61ad98
will show a list of all the files modified/added/deleted in the last commit where bd61ad98
is the commit ID. The output looks like this:
[trusktr@rocketship express.git]$ git show --pretty="format:" --name-status bd61ad98
A test.txt
D test3.txt
M wp-atom.php
What about a command that shows the same information but for all the commits from the last push? FOr example, if a file was deleted (D
), then re-added (A
), then modified (M
), the ideal status would be M
for modified. In other words, the net effect is that the file was modified.
Is there any such command? Even if the command were to list the duplicate statuses for files, that'd be fine. I could write a script that can determine the net effect.
Perhaps there's a way to compare diffs and output a list of files modified/deleted/added?
The reason I need such a file is that I'm making a script that will update another location using FTP based on this info.
Upvotes: 3
Views: 1883
Reputation: 488213
You really want git diff-tree
; see my other answer to your other question, too. :-)
Edit for details:
git diff-tree -r [other options] commit1 [commit2]
will give you the changes (in the formats documented for git-diff-tree) made either between commit1 and (I think) its immediate parent (if commit2 is omitted), or between commit1 and commit2.
You can also give it an actual tree-ID but then you must give it both tree IDs since it will not be able to find the parent, e.g.:
git diff-tree -r 69d8f48dd3e69f228b9a727cc69f8fbaf4534b4f
error: Object 69d8f48dd3e69f228b9a727cc69f8fbaf4534b4f is a tree, not a commit
(obviously the ID will vary).
If you have a branch name that refers to "what we last sent out", e.g., branch THEYHAVE
, and you want to send them what's on branch TESTED
, you could do:
git diff-tree -r THEYHAVE TESTED |
while read omode nmode ohash nhash letter pathname; do
...
done
and use the various letter codes and values in $nhash
and so on to extract the files ("git cat-file -p $nhash" will get you the contents of the file even in a --bare
repo).
(You can simplify this with --name-status
for your case, probably.)
Once you have everything FTP-ed to where it should go, you can then use git update-ref
to move the branch-label THEYHAVE to whatever the branch named TESTED names (it might be a good idea to use git rev-parse
once to grab the ID of that branch "up front", in case it moves while you're doing all this work).
Upvotes: 3
Reputation: 26197
I don't know the exact diff
format but here is what you can do in your script:
git fetch
Note: Do not pull, but fetch.diff
between <branch>
and <remote>/<branch>
in the format that you like, and store the results or take the required action.<remote>/<branch>
into <branch>
This way, you can take actions on separate push
es.
Upvotes: 0