git submodule status - How to change the way references are described

Viewed 44

In git submodule status, all submodules are listed in the format:

[ ][commit_sha] [relative path] [description of commit with 'git describe']

For instance:

$ git submodule status
 f6811d2be995498c162000c27608a0bf4df8d315 submod_1 (tagname-42-gf6811d2)
 beda48ff60e29fc31e2a9472041500f39736039d submod_2 (heads/master)

My question is: how to customize the description of commit?

In particular, I would like to pass the --exact-match to the underlying git describe of commits so that tag names are not used when not exactly matching (but rather branch name if existing!)

1 Answers

You can build whatever you want, it's a a near-oneliner, demo:

git config -f .gitmodules --get-regexp path$ \
| while IFS='. ' read x submodule x path; do
    echo $submodule recorded commit is `git rev-parse :$path`
    echo $submodule current commit is `git -C $path describe --all --exact @`
done
Related