Verify git's behavior with platform path conventions in .gitmodules #60

Open
opened 2026-06-04 07:55:13 +00:00 by mih · 0 comments
Owner

I think the normal behavior is "everything in POSIX notation". However, I could not convince myself that we can rely on this behavior. https://github.com/datalad/datalad/issues/3795 appears to confirm this. It also means that datalad itself will have generated gitmodules files with a problematic setup at some point.

This needs to be investigated:

  • check what git submodule add does on windows with a recent version
  • decide on a behavior for reading from gitmodules

libgit2 implements a forced conversion of backslashes to slashes (https://github.com/libgit2/libgit2/pull/3307). This is not nice (a backslash is a legal non-separate element of a POSIX path). However, the presence of such a path would be a portability issue. IMHO it boils done when and where to pay the price for putting a non-POSIX path into .gitmodules. I think:

  • we should always write POSIX paths ourselves
  • we should sacrifice the possibility of a path-with-backslash on a POSIX platform in favor of being able to act on a non-POSIX path written to .gitmodules

If would make the latter point conditional on the investigation on what git submodule add does these days.

Consider the options to adjust read_gitmodules*() to normalize paths on-read, and guarantee POSIX conventions for consuming code -- maybe even returning PurePosixPath instances...

I think the normal behavior is "everything in POSIX notation". However, I could not convince myself that we can rely on this behavior. https://github.com/datalad/datalad/issues/3795 appears to confirm this. It also means that datalad itself will have generated gitmodules files with a problematic setup at some point. This needs to be investigated: - check what `git submodule add` does on windows with a recent version - decide on a behavior for reading from gitmodules libgit2 implements a forced conversion of backslashes to slashes (https://github.com/libgit2/libgit2/pull/3307). This is not nice (a backslash is a legal non-separate element of a POSIX path). However, the presence of such a path would be a portability issue. IMHO it boils done when and where to pay the price for putting a non-POSIX path into .gitmodules. I think: - we should always write POSIX paths ourselves - we should sacrifice the possibility of a path-with-backslash on a POSIX platform in favor of being able to act on a non-POSIX path written to `.gitmodules` If would make the latter point conditional on the investigation on what `git submodule add` does these days. Consider the options to adjust `read_gitmodules*()` to normalize paths on-read, and guarantee POSIX conventions for consuming code -- maybe even returning `PurePosixPath` instances...
Sign in to join this conversation.
No description provided.