mirror of
https://github.com/martinvonz/jj.git
synced 2024-12-25 21:47:42 +00:00
cli: on jj init --git-repo
, point to Git repo's .git/
When using an internal Git repo (`jj init --git`), we make `.jj/repo/store/git_target` point directly to the repo (which is bare in that case). It makes sense to do the same when using an external Git repo (`jj init --git-repo`), so the contents of `.jj/repo/store/git_target` doesn't depend on whether the user included the `.git/` on the CLI.
This commit is contained in:
parent
0c6d89581e
commit
bbf4ba4118
2 changed files with 5 additions and 2 deletions
|
@ -1733,7 +1733,10 @@ fn cmd_init(ui: &mut Ui, command: &CommandHelper, args: &ArgMatches) -> Result<(
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(git_store_str) = args.value_of("git-repo") {
|
if let Some(git_store_str) = args.value_of("git-repo") {
|
||||||
let git_store_path = ui.cwd().join(git_store_str);
|
let mut git_store_path = ui.cwd().join(git_store_str);
|
||||||
|
if !git_store_path.ends_with(".git") {
|
||||||
|
git_store_path = git_store_path.join(".git");
|
||||||
|
}
|
||||||
let (workspace, repo) =
|
let (workspace, repo) =
|
||||||
Workspace::init_external_git(ui.settings(), wc_path.clone(), git_store_path)?;
|
Workspace::init_external_git(ui.settings(), wc_path.clone(), git_store_path)?;
|
||||||
let git_repo = repo.store().git_repo().unwrap();
|
let git_repo = repo.store().git_repo().unwrap();
|
||||||
|
|
|
@ -75,7 +75,7 @@ fn test_init_git_external() {
|
||||||
let git_target_file_contents = std::fs::read_to_string(store_path.join("git_target")).unwrap();
|
let git_target_file_contents = std::fs::read_to_string(store_path.join("git_target")).unwrap();
|
||||||
assert!(git_target_file_contents
|
assert!(git_target_file_contents
|
||||||
.replace('\\', "/")
|
.replace('\\', "/")
|
||||||
.ends_with("/git-repo"));
|
.ends_with("/git-repo/.git"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue