Submodule log bug
Git Mailing List
David Turner
2019-01-02 22:14:01 UTC
When a submodule is renamed, git log gives incorrect output:

commit 350ebece9bce8d9c495f9a51e6f5529749c5c3cc (HEAD -> master)
David Turner <>
Date:   Wed Jan 2 17:09:56 2019 -0500


diff --git a/.gitmodules b/.gitmodules
index da1a767..f4baf2a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
-[submodule "mymod"]
-	path = mymod
+[submodule "morx"]
+	path = morx
 	url = ../sub
Submodule mymod 86da4a4...86da4a4 (commits not present)

^-- I expect this last line to tell me that the submodule has been
renamed, rather than that it has changed SHA to the same SHA.

See the attached shell script for a demo of this.  I tested with
b21ebb671bb as well as 2.18 and 2.19.  Thanks to Adam Bliss
<> for helping to figure out the reproduction steps.

set -euo pipefail

rm -rf demo

mkdir demo
cd demo


$GIT init sub &&
    cd sub &&
        :> foo &&
        $GIT add foo &&
        $GIT commit -am 'initial commit'
) &&

$GIT init main &&
    cd main &&

        $GIT mymodule add ../sub mymod &&
        $GIT commit -am 'add submodule' &&
        $GIT submodule deinit mymod &&

        # try renaming
        $GIT mv mymod morx &&
        sed -i s,mymod,morx, .gitmodules &&
        $GIT commit -am 'move' &&

        rm -rf .$GIT/modules &&
        PAGER=cat $GIT log --submodule=log  -p -n1