Reputation: 26742
Is there an easy way to use Git plumbing to programatically check if a submodule was updated in some commit (e.g., HEAD). (You don't care which one, you just want to know that A submodule changed)
Upvotes: 2
Views: 95
Reputation: 60275
To check a commit's changes against its parents with core commands, use
git diff-tree -m -r $commit # all parents
git diff-tree -r $commit{~,} # first parent
Submodule entries have type 16,
git diff-tree -m -r $commit | awk '$1":"$2~/:16/'
will print all changed submodule entries in $commit.
(edit: had -c
option on there by mistake, that shows only conflict resolutions, not what was wanted).
(edit 2: gaak! Submodule type is 16, not 04. "I knew that". Also, to compare against all parents, use -m
)
Upvotes: 3
Reputation: 1905
I'm unaware of a built-in way, but this does the job:
git diff $COMMIT~ $COMMIT | grep -qE '^(-|\+)Subproject commit'
echo $?
# Return code 0 if commit contains changes to a subproject
# Return code 1 if commit contains no changes to a subproject
Upvotes: 0