Describe the bug
commitment-issues fails when a crate is built from a Git submodule checkout inside Docker. The crate detects the submodule working tree as the Git root because a .git entry exists, but in a submodule that .git is a pointer file (gitdir: ...) to the parent repository’s .git/modules/... directory. Inside the Docker build context that referenced path does not exist, so metadata generation fails.
To Reproduce
Steps to reproduce the behavior:
-
Put a Rust crate that uses commitment_issues::include_metadata!(); inside a Git submodule.
-
Add a build.rs containing:
println!(
"cargo:rerun-if-changed={}",
commitment_issues::find_valid_git_root!()
); }
-
Build that crate in Docker from the submodule directory as the build context, copying its .git entry into the image.
-
Run cargo build .
-
See error:
--> src/lib.rs:3:1
|
3 | commitment_issues::include_metadata!();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expected behaviour
I expected commitment-issues to either:
• correctly handle submodule .git indirection, or
• fail with a clearer error explaining that the discovered .git file points to an external gitdir not available in the current build context.
Screenshots
Not applicable.
Hardware (please complete the following information):
• OS: MacOS / Linux (Docker build on Mac host, Linux container)
• OS Version: macOS Sequoia 15.x, Debian Bookworm container
• Rust Version: stable (exact version can be provided if needed)
• Commitment Issues Crate Version: 0.2
• Other Crate Versions: git2 via commitment-issues
Additional context
The relevant detail is that the submodule’s .git is not a real directory. It contains:
gitdir: ../../../.git/modules/PiHall/Home-Power-Monitor
find_valid_git_root_inner() currently appears to stop as soon as path.join(".git").exists() is true, and Repository::open(&git_root) later fails because the referenced gitdir path is outside the copied Docker build context.
This works fine in a normal standalone repository with a real .git/ directory. The issue seems specific to submodules/worktrees where .git is an indirection file rather than a self-contained repo directory.
Describe the bug
commitment-issuesfails when a crate is built from a Git submodule checkout inside Docker. The crate detects the submodule working tree as the Git root because a.gitentry exists, but in a submodule that.gitis a pointer file (gitdir: ...) to the parent repository’s.git/modules/...directory. Inside the Docker build context that referenced path does not exist, so metadata generation fails.To Reproduce
Steps to reproduce the behavior:
Put a Rust crate that uses
commitment_issues::include_metadata!();inside a Git submodule.Add a
build.rscontaining:Build that crate in Docker from the submodule directory as the build context, copying its .git entry into the image.
Run cargo build .
See error:
--> src/lib.rs:3:1
|
3 | commitment_issues::include_metadata!();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expected behaviour
I expected commitment-issues to either:
• correctly handle submodule .git indirection, or
• fail with a clearer error explaining that the discovered .git file points to an external gitdir not available in the current build context.
Screenshots
Not applicable.
Hardware (please complete the following information):
• OS: MacOS / Linux (Docker build on Mac host, Linux container)
• OS Version: macOS Sequoia 15.x, Debian Bookworm container
• Rust Version: stable (exact version can be provided if needed)
• Commitment Issues Crate Version: 0.2
• Other Crate Versions: git2 via commitment-issues
Additional context
The relevant detail is that the submodule’s .git is not a real directory. It contains:
gitdir: ../../../.git/modules/PiHall/Home-Power-Monitor
find_valid_git_root_inner() currently appears to stop as soon as path.join(".git").exists() is true, and Repository::open(&git_root) later fails because the referenced gitdir path is outside the copied Docker build context.
This works fine in a normal standalone repository with a real .git/ directory. The issue seems specific to submodules/worktrees where .git is an indirection file rather than a self-contained repo directory.