git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
* git submodule status never says “old commits”
       [not found] <VE1PR10MB33746C60D550BB11162F5E24945B0@VE1PR10MB3374.EURPRD10.PROD.OUTLOOK.COM>
@ 2020-08-21 12:14 ` Ulrich HERRMANN
  2020-08-22  1:54   ` brian m. carlson
  0 siblings, 1 reply; 3+ messages in thread
From: Ulrich HERRMANN @ 2020-08-21 12:14 UTC (permalink / raw)
  To: git

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?

Best Regards, Ulrich

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git submodule status never says “old commits”
  2020-08-21 12:14 ` git submodule status never says “old commits” Ulrich HERRMANN
@ 2020-08-22  1:54   ` brian m. carlson
  2020-10-12 13:38     ` Ulrich HERRMANN
  0 siblings, 1 reply; 3+ messages in thread
From: brian m. carlson @ 2020-08-22  1:54 UTC (permalink / raw)
  To: Ulrich HERRMANN; +Cc: git

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: git submodule status never says “old commits”
  2020-08-22  1:54   ` brian m. carlson
@ 2020-10-12 13:38     ` Ulrich HERRMANN
  0 siblings, 0 replies; 3+ messages in thread
From: Ulrich HERRMANN @ 2020-10-12 13:38 UTC (permalink / raw)
  To: brian m. carlson; +Cc: git

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:
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-12 13:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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
2020-10-12 13:38     ` Ulrich HERRMANN

Code repositories for project(s) associated with this 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).