Skip to content

Commit 0bc9568

Browse files
committed
fix: leave extensions in place if they are not .git when using gix clone <url>. (#1177)
Previously it would happily remove e.g. a `.net` extension, even though it's part of the repository name. Further, when cloning with `--bare`, don't strip the extension at all as it's common to keep the `.git` extension in this case.
1 parent 7549559 commit 0bc9568

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

gitoxide-core/src/repository/clone.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ pub(crate) mod function {
4545
let url: gix::Url = url.as_ref().try_into()?;
4646
let directory = directory.map_or_else(
4747
|| {
48-
gix::path::from_bstr(Cow::Borrowed(url.path.as_ref()))
49-
.as_ref()
50-
.file_stem()
51-
.map(Into::into)
52-
.context("Filename extraction failed - path too short")
48+
let path = gix::path::from_bstr(Cow::Borrowed(url.path.as_ref()));
49+
if !bare && path.extension() == Some(OsStr::new("git")) {
50+
path.file_stem().map(Into::into)
51+
} else {
52+
path.file_name().map(Into::into)
53+
}
54+
.context("Filename extraction failed - path too short")
5355
},
5456
|dir| Ok(dir.into()),
5557
)?;

0 commit comments

Comments
 (0)