I wrote some script that basically uses git log to extract some information for a file in the workspace.
That works OK, but it fails if the file is part of a submodule.
As I found out, git log -- file returns nothing and exits with 0 if the file is part of a submodule; however when I cd into the submodule's directory, git log will work as expected.
So my idea was to detect whether a given file is part of a submodule, and if so: "Which submodule?". How can I get that information?
Update
Actually git log outputs data for the submodule once the new submodule is committed.
But still the log info for a file in the submodule is different depending from where the git log command is started:
When started from the main workspace it refers to the commit of the submodule, but when run from the submodule directory, it refers to the commit inside the submodule.
So the question is still valid ;-)