Hi Brian,
thank you for this answer. I had missed the summary/--submodule option. They seem to be pretty usable.
Best Regards, Ulrich
-----Original Message-----
From: brian m. carlson <sandals@crustytoothpaste.net>
Sent: Saturday, 22 August 2020 03:54
To: Ulrich HERRMANN <ulrich.herrmann@st.com>
Cc: git@vger.kernel.org
Subject: Re: git submodule status never says “old commits”
On 2020-08-21 at 12:14:58, Ulrich HERRMANN wrote:
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