Skip to content

Commit 04502e3

Browse files
committed
feat: add open::Options::current_dir().
That way it's possible to obtain the current working directory with which the repository was opened.
1 parent 2202c23 commit 04502e3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

gix/src/repository/location.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ impl crate::Repository {
1515
self.options.git_dir_trust.expect("definitely set by now")
1616
}
1717

18+
/// Return the current working directory as present during the instantiation of this repository.
19+
///
20+
/// Note that this should be preferred over manually obtaining it as this may have been adjusted to
21+
/// deal with `core.precomposeUnicode`.
22+
pub fn current_dir(&self) -> &Path {
23+
self.options
24+
.current_dir
25+
.as_deref()
26+
.expect("BUG: cwd is always set after instantiation")
27+
}
28+
1829
/// Returns the main git repository if this is a repository on a linked work-tree, or the `git_dir` itself.
1930
pub fn common_dir(&self) -> &std::path::Path {
2031
self.common_dir.as_deref().unwrap_or_else(|| self.git_dir())

0 commit comments

Comments
 (0)