On 2020-08-21 at 12:14:58, Ulrich HERRMANN wrote: > Hi all, > > I am now a user of git-submodules for quite some time. However I still > haven’t figured out how to get better status/diff information. When > the submodule is at a different version it always gives me "new > commits" but never "old commits" even though I have checked out an > older version inside the submodule. git diff gives me two different > hashes which also don't give any directly readable information. Git > could check the ancestry graph to figure the relation of the two > commits: child/parent, parent/child, common ancestor, etc. > Or is there a feature / command line switch of git which I am missing? You may be interested in the status.submoduleSummary option, which if enabled will show a summary of what's changed in the submodule. If you don't want to set that setting, the command "git submodule summary" can also be used. For git diff, there's the --submodule option, which can be used to control what information is shown in the diff, and the diff.submodule option controls the default. As for just knowing whether the revision checked out is ahead or behind the committed revision, I don't think there's an option for that. Most notably, it need not be either: the two commits could be on two different branches with some shared history or even on two commits that don't share any history at all. So there's not necessarily any answer that's correct there at all. You could script some of this with an alias or script by doing something like this: #!/bin/sh -e # old value A=$(git rev-parse --verify $1) # new value B=$(git rev-parse --verify $2) MB=$(git merge-base $A $B || true) if [ -z "$MB" ] then echo "No common ancestors" elif [ "$A" = "$MB" ] then echo "New commits" elif [ "$B" = "$MB" ] then echo "Old commits" else echo "Common ancestor" fi -- brian m. carlson: Houston, Texas, US
Attachment:
signature.asc
Description: PGP signature