From d57237af5d13d26a098bdee74d973b6623b0a4bf Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Sat, 12 Aug 2023 17:26:46 +0900 Subject: [PATCH] cli: on "git clone --colocate", set up .git/info/exclude to ignore .jj dir --- cli/src/commands/git.rs | 1 + cli/tests/test_git_clone.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index 63d912403..c336ce4d5 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -512,6 +512,7 @@ fn do_git_clone( ) -> Result<(WorkspaceCommandHelper, git2::Repository, Option), 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)? diff --git a/cli/tests/test_git_clone.rs b/cli/tests/test_git_clone.rs index b233ee778..260e40963 100644 --- a/cli/tests/test_git_clone.rs +++ b/cli/tests/test_git_clone.rs @@ -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"]);