Reputation: 13195
I need to write a script that will
I have a script for step 2:
for i in `git show --pretty="format:" --name-only SHA1 | grep '.*\.hbm\.xml' `; do
# call script here.....
exit
done
Now, I need to figure out step 1.
Upvotes: 29
Views: 17643
Reputation: 791421
Something like:
branch=master
for commit in $(git rev-list $branch)
do
if git ls-tree --name-only -r $commit | grep -q '\.hbm\.xml$'; then
echo $commit
exit 0
fi
done
Note that git show
will only list files which have changed in that commit, if you want to know whether there is a path that matches a particular pattern in a commit you need to use something like git ls-tree
.
Upvotes: 36
Reputation: 175325
git rev-list
will list all revisions reachable from a given commit in reverse chronological order, so you can pass it a branch name to get the list for that branch head backwards:
$ git rev-list master
a6060477b9dca7021bc34f373360f75064a0b728
7146d679312ab5425fe531390c6bb389cd9c8910
53e3d0c1e1239d0e846b3947c4a6da585960e02d
a91b80b91e9890f522fe8e83feda32b8c6eab7b6
...
Upvotes: 15