ok/jj
1
0
Fork 0
forked from mirrors/jj

cli: on "git clone --colocate", set up .git/info/exclude to ignore .jj dir

This commit is contained in:
Yuya Nishihara 2023-08-12 17:26:46 +09:00
parent 5c6ef75b2b
commit d57237af5d
2 changed files with 11 additions and 0 deletions

View file

@ -512,6 +512,7 @@ fn do_git_clone(
) -> Result<(WorkspaceCommandHelper, git2::Repository, Option<String>), CommandError> {
let (workspace, repo) = if colocate {
let git_repo = git2::Repository::init(wc_path)?;
add_to_git_exclude(ui, &git_repo)?;
Workspace::init_external_git(command.settings(), wc_path, git_repo.path())?
} else {
Workspace::init_internal_git(command.settings(), wc_path)?

View file

@ -197,6 +197,16 @@ fn test_git_clone_colocate() {
.expect("Repo HEAD should be set.")
.symbolic_target()
);
// ".jj" directory should be ignored at Git side.
let git_statuses: String = jj_git_repo
.statuses(None)
.unwrap()
.iter()
.map(|entry| format!("{:?} {}\n", entry.status(), entry.path().unwrap()))
.collect();
insta::assert_snapshot!(git_statuses, @r###"
IGNORED .jj/
"###);
// The old default branch "master" shouldn't exist.
let stdout = test_env.jj_cmd_success(&test_env.env_root().join("clone"), &["branch", "list"]);