What's the Git command to determine which commit changed a submodule pointer?
Asked Answered
B

2

11

I'm dissecting a series of changes made to a git repo, some of which involved a submodule. I used git blame to find the relevant commit within the submodule, but is there a simple way to locate which commit in my main repo changed the submodule pointer to that commit?

Cue simple diagram:

1 <- 2 <- 3 <- 4 <- 5    (Main chain of commits)
|    |    |    |    |
1    1    1    2    2    (Submodule)

I have located the commit where submodule #1 changed into submodule #2 (say it's 9d95812e...). How do I determine the fact that main-commit #4 is where the new submodule commit was first employed?

Banbury answered 6/5, 2016 at 4:37 Comment(1)
Isn't this just a git search for string matching +Subproject commit SHA?Sobel
B
5

From what I can tell this isn't quite possible, the closest you can get is to determine which commits added or removed that particular submodule pointer:

git log -p -S "Subproject commit c4965b1..."

yields:

commit xyz123456
Author:
Date:

    Message

diff...
@@ -1 +1 @@
-Subproject commit 901231290321
+Subproject commit 1902u8129039

The only thing is +/- are not part of the actual string you're searching for, so you can't look for an addition or removal specifically, but using the -p flag will let you see this easily.

Banbury answered 6/5, 2016 at 5:12 Comment(0)
H
8

You can also use

git log -p -- path/to/submodule

to see all commits that have updated your submodule pointer if you want to see how it changed over time.

Harken answered 21/12, 2018 at 7:53 Comment(0)
B
5

From what I can tell this isn't quite possible, the closest you can get is to determine which commits added or removed that particular submodule pointer:

git log -p -S "Subproject commit c4965b1..."

yields:

commit xyz123456
Author:
Date:

    Message

diff...
@@ -1 +1 @@
-Subproject commit 901231290321
+Subproject commit 1902u8129039

The only thing is +/- are not part of the actual string you're searching for, so you can't look for an addition or removal specifically, but using the -p flag will let you see this easily.

Banbury answered 6/5, 2016 at 5:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.