Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making sense of git submodule status output

Tags:

git

I am having trouble understanding the output of git submodule status. I think it's because I don't use tags very often.

I added a submodule to a Git repository (you can replicate this locally really easily using the 3 git commands directly below):

/ $ git init
/ $ git submodule add https://github.com/twbs/bootstrap.git
Cloning into 'bootstrap'...
## Output abridged ##
/ $ git submodule status
93694898838b479d2806c53c827847f724312bcc bootstrap (v2.3.1-2965-g9369489)    
/ $ cd bootstrap/
bootstrap/ $ git rev-parse HEAD
93694898838b479d2806c53c827847f724312bcc

I checked out v3.0.0:

bootstrap/ $ git checkout v3.0.0
Note: checking out 'v3.0.0'.
## Tells me about the detached HEAD ##
HEAD is now at e8a1df5... remove dumb validation reports
bootstrap/ $ cd ..
/ $ git commit -a -m 'Added submodule and changed its checked out commit'

The output of git submodule status:

/ $ git submodule status
e8a1df5f060bf7e6631554648e0abde150aedbe4 bootstrap (v2.3.1-2765-ge8a1df5)

The commit that's referenced (e8a1df5) makes sense to me, but the tag is confusing. man git-submodule says thats each line of git submodule status output is:

the SHA-1 of the currently checked out commit for each submodule, along with the submodule path and the output of git describe for the SHA-1.

So the output of git describe e8a1df5f060bf7e6631554648e0abde150aedbe4 is (v2.3.1-2765-ge8a1df5)? But I just checked out v3.0.0?!

Anyway, man git-describe says this:

The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit.

So, applying this knowledge to (v2.3.1-2765-ge8a1df5) from the git submodule status output I received above:

  • "v2.3.1" must be the most recent tag reachable from e8a1df5
  • "2765" must be the number of commits on top of "v.2.3.1"
  • and "e8a1df5" must be the abbreviated object name of the most recent commit (see man gitrevisions re: the g prefix)

But this doesn't make sense to me. Why is v2.3.1 plus 2765 commits shown instead of v3.0.0? After all, I did check out v3.0.0, and:

bootstrap/ $ git tag --contains `git rev-parse HEAD`
v3.0.0

How can I find out why git describe decided that v2.3.1 is the most recent reachable tag? What's going on here?

like image 934
Dmitry Minkovsky Avatar asked Sep 01 '13 15:09

Dmitry Minkovsky


1 Answers

By default (without --all or --tags) git describe only shows annotated tags.

So v3.0.0 being a lightweight tag would produce this behavior.

like image 193
jthill Avatar answered Oct 12 '22 23:10

jthill