From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Ulrich HERRMANN <ulrich.herrmann@st.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git submodule status never says “old commits”
Date: Sat, 22 Aug 2020 01:54:02 +0000 [thread overview]
Message-ID: <20200822015402.GY8085@camp.crustytoothpaste.net> (raw)
In-Reply-To: <VE1PR10MB3374796F04367FA5DE25F921945B0@VE1PR10MB3374.EURPRD10.PROD.OUTLOOK.COM>
[-- Attachment #1: Type: text/plain, Size: 1995 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]
next prev parent reply other threads:[~2020-08-22 1:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <VE1PR10MB33746C60D550BB11162F5E24945B0@VE1PR10MB3374.EURPRD10.PROD.OUTLOOK.COM>
2020-08-21 12:14 ` git submodule status never says “old commits” Ulrich HERRMANN
2020-08-22 1:54 ` brian m. carlson [this message]
2020-10-12 13:38 ` Ulrich HERRMANN
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200822015402.GY8085@camp.crustytoothpaste.net \
--to=sandals@crustytoothpaste.net \
--cc=git@vger.kernel.org \
--cc=ulrich.herrmann@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).