bookmarks: add support for git.auto-local-bookmark (to match docs)

We had documented that we support `git.auto-local-bookmark` but we
don't. The documentation has been incorrect since d9c68e08b1. This
patch fixes it by adding support for `git.auto-local-bookmark` with
fallback to the old/current `git.auto-local-branch`.
.
This commit is contained in:
Martin von Zweigbergk 2024-10-29 21:36:31 -07:00 committed by Martin von Zweigbergk
parent cba3261f04
commit 30ab71d340
15 changed files with 73 additions and 65 deletions

View file

@ -32,6 +32,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### Deprecations
* `git.auto-local-bookmark` replaces `git.auto-local-branch`. The latter remains
supported for now (at lower precedence than the former).
### New features
* Added diff options to ignore whitespace when comparing lines. Whitespace

View file

@ -219,7 +219,7 @@ fn init_git_refs(
}
print_git_import_stats(ui, tx.repo(), &stats, false)?;
if colocated {
// If git.auto-local-branch = true, local bookmarks could be created for
// If git.auto-local-bookmark = true, local bookmarks could be created for
// the imported remote branches.
let failed_refs = git::export_refs(tx.repo_mut())?;
print_failed_git_export(ui, &failed_refs)?;

View file

@ -313,7 +313,7 @@
"type": "object",
"description": "Settings for git behavior (when using git backend)",
"properties": {
"auto-local-branch": {
"auto-local-bookmark": {
"type": "boolean",
"description": "Whether jj creates a local bookmark with the same name when it imports a remote-tracking branch from git. See https://martinvonz.github.io/jj/latest/config/#automatic-local-bookmark-creation",
"default": false

View file

@ -709,7 +709,7 @@ fn test_bookmark_forget_fetched_bookmark() {
// Set up a git repo with a bookmark and a jj repo that has it as a remote.
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
let git_repo_path = test_env.env_root().join("git-repo");
@ -833,7 +833,7 @@ fn test_bookmark_forget_deleted_or_nonexistent_bookmark() {
// ======== Beginning of test setup ========
// Set up a git repo with a bookmark and a jj repo that has it as a remote.
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
let git_repo_path = test_env.env_root().join("git-repo");
@ -928,7 +928,7 @@ fn test_bookmark_track_untrack() {
"refs/heads/feature2",
],
);
test_env.add_config("git.auto-local-branch = false");
test_env.add_config("git.auto-local-bookmark = false");
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
insta::assert_snapshot!(stderr, @r###"
bookmark: feature1@origin [new] untracked
@ -1039,7 +1039,7 @@ fn test_bookmark_track_untrack() {
"refs/heads/feature3",
],
);
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
insta::assert_snapshot!(stderr, @r###"
bookmark: feature1@origin [updated] untracked
@ -1130,7 +1130,7 @@ fn test_bookmark_track_untrack_patterns() {
}
// Fetch new commit without auto tracking
test_env.add_config("git.auto-local-branch = false");
test_env.add_config("git.auto-local-bookmark = false");
let (_stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
insta::assert_snapshot!(stderr, @r###"
bookmark: feature1@origin [new] untracked
@ -1235,7 +1235,7 @@ fn test_bookmark_track_untrack_patterns() {
#[test]
fn test_bookmark_list() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
// Initialize remote refs
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "remote"]);
@ -1413,7 +1413,7 @@ fn test_bookmark_list() {
#[test]
fn test_bookmark_list_filtered() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
// Initialize remote refs
@ -1638,7 +1638,7 @@ fn test_bookmark_list_filtered() {
#[test]
fn test_bookmark_list_much_remote_divergence() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
// Initialize remote refs
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "remote"]);
@ -1683,7 +1683,7 @@ fn test_bookmark_list_much_remote_divergence() {
#[test]
fn test_bookmark_list_tracked() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
// Initialize remote refs
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "remote"]);

View file

@ -37,7 +37,7 @@ fn set_up(trunk_name: &str) -> (TestEnvironment, PathBuf) {
&[
"git",
"clone",
"--config-toml=git.auto-local-branch=true",
"--config-toml=git.auto-local-bookmark=true",
origin_git_repo_path.to_str().unwrap(),
"local",
],

View file

@ -550,7 +550,7 @@ fn test_log_evolog_divergence() {
#[test]
fn test_log_bookmarks() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "origin"]);

View file

@ -46,7 +46,7 @@ fn set_up_non_empty_git_repo(git_repo: &git2::Repository) {
#[test]
fn test_git_clone() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let git_repo_path = test_env.env_root().join("source");
let git_repo = git2::Repository::init(git_repo_path).unwrap();
@ -160,7 +160,7 @@ fn test_git_clone() {
#[test]
fn test_git_clone_colocate() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let git_repo_path = test_env.env_root().join("source");
let git_repo = git2::Repository::init(git_repo_path).unwrap();
@ -366,8 +366,8 @@ fn test_git_clone_remote_default_bookmark() {
.reference("refs/heads/feature1", oid, false, "")
.unwrap();
// All fetched bookmarks will be imported if auto-local-branch is on
test_env.add_config("git.auto-local-branch = true");
// All fetched bookmarks will be imported if auto-local-bookmark is on
test_env.add_config("git.auto-local-bookmark = true");
let (_stdout, stderr) =
test_env.jj_cmd_ok(test_env.env_root(), &["git", "clone", "source", "clone1"]);
insta::assert_snapshot!(stderr, @r###"
@ -396,8 +396,8 @@ fn test_git_clone_remote_default_bookmark() {
revset-aliases.'trunk()' = "main@origin"
"###);
// Only the default bookmark will be imported if auto-local-branch is off
test_env.add_config("git.auto-local-branch = false");
// Only the default bookmark will be imported if auto-local-bookmark is off
test_env.add_config("git.auto-local-bookmark = false");
let (_stdout, stderr) =
test_env.jj_cmd_ok(test_env.env_root(), &["git", "clone", "source", "clone2"]);
insta::assert_snapshot!(stderr, @r###"
@ -501,7 +501,7 @@ fn test_git_clone_at_operation() {
#[test]
fn test_git_clone_with_remote_name() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let git_repo_path = test_env.env_root().join("source");
let git_repo = git2::Repository::init(git_repo_path).unwrap();
set_up_non_empty_git_repo(&git_repo);
@ -560,7 +560,7 @@ fn test_git_clone_trunk_deleted() {
#[test]
fn test_git_clone_with_depth() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let git_repo_path = test_env.env_root().join("source");
let git_repo = git2::Repository::init(git_repo_path).unwrap();
set_up_non_empty_git_repo(&git_repo);

View file

@ -516,7 +516,7 @@ fn test_git_colocated_checkout_non_empty_working_copy() {
#[test]
fn test_git_colocated_fetch_deleted_or_moved_bookmark() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let origin_path = test_env.env_root().join("origin");
git2::Repository::init(&origin_path).unwrap();
test_env.jj_cmd_ok(&origin_path, &["git", "init", "--git-repo=."]);

View file

@ -88,7 +88,7 @@ fn test_git_fetch_with_default_config() {
#[test]
fn test_git_fetch_default_remote() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
@ -103,7 +103,7 @@ fn test_git_fetch_default_remote() {
#[test]
fn test_git_fetch_single_remote() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -122,7 +122,7 @@ fn test_git_fetch_single_remote() {
#[test]
fn test_git_fetch_single_remote_all_remotes_flag() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -140,7 +140,7 @@ fn test_git_fetch_single_remote_all_remotes_flag() {
#[test]
fn test_git_fetch_single_remote_from_arg() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -155,7 +155,7 @@ fn test_git_fetch_single_remote_from_arg() {
#[test]
fn test_git_fetch_single_remote_from_config() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -171,7 +171,7 @@ fn test_git_fetch_single_remote_from_config() {
#[test]
fn test_git_fetch_multiple_remotes() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -192,7 +192,7 @@ fn test_git_fetch_multiple_remotes() {
#[test]
fn test_git_fetch_all_remotes() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -210,7 +210,7 @@ fn test_git_fetch_all_remotes() {
#[test]
fn test_git_fetch_multiple_remotes_from_config() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -265,7 +265,7 @@ fn test_git_fetch_nonexistent_remote_from_config() {
#[test]
fn test_git_fetch_from_remote_named_git() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let repo_path = test_env.env_root().join("repo");
init_git_remote(&test_env, "git");
let git_repo = git2::Repository::init(&repo_path).unwrap();
@ -311,7 +311,7 @@ fn test_git_fetch_from_remote_named_git() {
#[test]
fn test_git_fetch_prune_before_updating_tips() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
@ -339,7 +339,7 @@ fn test_git_fetch_prune_before_updating_tips() {
#[test]
fn test_git_fetch_conflicting_bookmarks() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "rem1");
@ -367,7 +367,7 @@ fn test_git_fetch_conflicting_bookmarks() {
#[test]
fn test_git_fetch_conflicting_bookmarks_colocated() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let repo_path = test_env.env_root().join("repo");
let _git_repo = git2::Repository::init(&repo_path).unwrap();
// create_colocated_repo_and_bookmarks_from_trunk1(&test_env, &repo_path);
@ -430,7 +430,7 @@ fn create_trunk2_and_rebase_bookmarks(test_env: &TestEnvironment, repo_path: &Pa
#[test]
fn test_git_fetch_all() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
let source_git_repo_path = test_env.env_root().join("source");
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
@ -579,7 +579,7 @@ fn test_git_fetch_all() {
#[test]
fn test_git_fetch_some_of_many_bookmarks() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
let source_git_repo_path = test_env.env_root().join("source");
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
@ -795,7 +795,7 @@ fn test_git_fetch_some_of_many_bookmarks() {
#[test]
fn test_git_fetch_bookmarks_some_missing() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
@ -883,7 +883,7 @@ fn test_git_fetch_bookmarks_some_missing() {
#[test]
fn test_git_fetch_undo() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let source_git_repo_path = test_env.env_root().join("source");
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
@ -960,7 +960,7 @@ fn test_git_fetch_undo() {
#[test]
fn test_fetch_undo_what() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let source_git_repo_path = test_env.env_root().join("source");
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
@ -1057,7 +1057,7 @@ fn test_fetch_undo_what() {
#[test]
fn test_git_fetch_remove_fetch() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
@ -1101,7 +1101,7 @@ fn test_git_fetch_remove_fetch() {
#[test]
fn test_git_fetch_rename_fetch() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
@ -1142,7 +1142,7 @@ fn test_git_fetch_rename_fetch() {
#[test]
fn test_git_fetch_removed_bookmark() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let source_git_repo_path = test_env.env_root().join("source");
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
@ -1234,7 +1234,7 @@ fn test_git_fetch_removed_bookmark() {
#[test]
fn test_git_fetch_removed_parent_bookmark() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let source_git_repo_path = test_env.env_root().join("source");
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
@ -1347,7 +1347,7 @@ fn test_git_fetch_remote_only_bookmark() {
.unwrap();
// Fetch using git.auto_local_bookmark = true
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
test_env.jj_cmd_ok(&repo_path, &["git", "fetch", "--remote=origin"]);
insta::assert_snapshot!(get_bookmark_output(&test_env, &repo_path), @r###"
feature1: mzyxwzks 9f01a0e0 message
@ -1366,7 +1366,7 @@ fn test_git_fetch_remote_only_bookmark() {
.unwrap();
// Fetch using git.auto_local_bookmark = false
test_env.add_config("git.auto-local-branch = false");
test_env.add_config("git.auto-local-bookmark = false");
test_env.jj_cmd_ok(&repo_path, &["git", "fetch", "--remote=origin"]);
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
9f01a0e04879 message feature1 feature2@origin

View file

@ -516,7 +516,7 @@ fn test_git_init_colocated_via_git_repo_path_symlink_gitlink() {
#[test]
fn test_git_init_colocated_via_git_repo_path_imported_refs() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
// Set up remote refs
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "remote"]);
@ -545,7 +545,7 @@ fn test_git_init_colocated_via_git_repo_path_imported_refs() {
.unwrap();
};
// With git.auto-local-branch = true
// With git.auto-local-bookmark = true
let local_path = test_env.env_root().join("local1");
set_up_local_repo(&local_path);
let (_stdout, stderr) = test_env.jj_cmd_ok(&local_path, &["git", "init", "--git-repo=."]);
@ -562,8 +562,8 @@ fn test_git_init_colocated_via_git_repo_path_imported_refs() {
@origin: vvkvtnvv 230dd059 (empty) (no description set)
"###);
// With git.auto-local-branch = false
test_env.add_config("git.auto-local-branch = false");
// With git.auto-local-bookmark = false
test_env.add_config("git.auto-local-bookmark = false");
let local_path = test_env.env_root().join("local2");
set_up_local_repo(&local_path);
let (_stdout, stderr) = test_env.jj_cmd_ok(&local_path, &["git", "init", "--git-repo=."]);

View file

@ -37,7 +37,7 @@ fn set_up() -> (TestEnvironment, PathBuf) {
&[
"git",
"clone",
"--config-toml=git.auto-local-branch=true",
"--config-toml=git.auto-local-bookmark=true",
origin_git_repo_path.to_str().unwrap(),
"local",
],

View file

@ -38,7 +38,7 @@ fn set_up() -> (TestEnvironment, PathBuf) {
&[
"git",
"clone",
"--config-toml=git.auto-local-branch=true",
"--config-toml=git.auto-local-bookmark=true",
origin_git_repo_path.to_str().unwrap(),
"local",
],
@ -429,7 +429,7 @@ fn test_git_push_creation_unexpectedly_already_exists() {
fn test_git_push_locally_created_and_rewritten() {
let (test_env, workspace_root) = set_up();
// Ensure that remote bookmarks aren't tracked automatically
test_env.add_config("git.auto-local-branch = false");
test_env.add_config("git.auto-local-bookmark = false");
// Push locally-created bookmark
test_env.jj_cmd_ok(&workspace_root, &["new", "root()", "-mlocal 1"]);
@ -1085,7 +1085,7 @@ fn test_git_push_deleted() {
#[test]
fn test_git_push_conflicting_bookmarks() {
let (test_env, workspace_root) = set_up();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
let git_repo = {
let mut git_repo_path = workspace_root.clone();
git_repo_path.extend([".jj", "repo", "store", "git"]);

View file

@ -388,7 +388,7 @@ fn test_init_git_colocated_symlink_gitlink() {
#[test]
fn test_init_git_colocated_imported_refs() {
let test_env = TestEnvironment::default();
test_env.add_config("git.auto-local-branch = true");
test_env.add_config("git.auto-local-bookmark = true");
// Set up remote refs
test_env.jj_cmd_ok(test_env.env_root(), &["init", "remote", "--git"]);
@ -417,7 +417,7 @@ fn test_init_git_colocated_imported_refs() {
.unwrap();
};
// With git.auto-local-branch = true
// With git.auto-local-bookmark = true
let local_path = test_env.env_root().join("local1");
set_up_local_repo(&local_path);
let (_stdout, stderr) = test_env.jj_cmd_ok(&local_path, &["init", "--git-repo=."]);
@ -436,8 +436,8 @@ fn test_init_git_colocated_imported_refs() {
@origin: vvkvtnvv 230dd059 (empty) (no description set)
"###);
// With git.auto-local-branch = false
test_env.add_config("git.auto-local-branch = false");
// With git.auto-local-bookmark = false
test_env.add_config("git.auto-local-bookmark = false");
let local_path = test_env.env_root().join("local2");
set_up_local_repo(&local_path);
let (_stdout, stderr) = test_env.jj_cmd_ok(&local_path, &["init", "--git-repo=."]);

View file

@ -6,7 +6,7 @@ This is a plan to implement more Git-like remote tracking branch UX.
`jj` imports all remote branches to local branches by default. As described in
[#1136], this doesn't interact nicely with Git if we have multiple Git remotes
with a number of branches. The `git.auto-local-branch` config can mitigate this
with a number of branches. The `git.auto-local-bookmark` config can mitigate this
problem, but we'll get locally-deleted branches instead.
The goal of this plan is to implement
@ -120,14 +120,14 @@ With the proposed data model, we can
### Tracking state
The `git.auto-local-branch` config knob is applied when importing new remote
The `git.auto-local-bookmark` config knob is applied when importing new remote
branch. `jj branch` sub commands will be added to change the tracking state.
```rust
fn default_state_for_newly_imported_branch(config, remote) {
if remote == "git" {
State::Tracking
} else if config["git.auto-local-branch"] {
} else if config["git.auto-local-bookmark"] {
State::Tracking
} else {
State::New
@ -155,7 +155,7 @@ fn target_in_merge_context(known_target, state) {
* New `remotes[remote].branches` corresponds to
`branches[].remote_targets[remote]`.
* `state = new|tracking` doesn't exist in the current model. It's determined
by `git.auto-local-branch` config.
by `git.auto-local-bookmark` config.
## Common command behaviors

View file

@ -50,11 +50,16 @@ pub struct GitSettings {
impl GitSettings {
pub fn from_config(config: &config::Config) -> Self {
let auto_local_bookmark = config
.get_bool("git.auto-local-bookmark")
.or_else(|_| config.get_bool("git.auto-local-branch"))
.unwrap_or(false);
let abandon_unreachable_commits = config
.get_bool("git.abandon-unreachable-commits")
.unwrap_or(true);
GitSettings {
auto_local_bookmark: config.get_bool("git.auto-local-branch").unwrap_or(false),
abandon_unreachable_commits: config
.get_bool("git.abandon-unreachable-commits")
.unwrap_or(true),
auto_local_bookmark,
abandon_unreachable_commits,
}
}
}