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

git: turn git.auto-local-branch off by default

As far as I can see in the chat, there's no objection to changing the default,
and git.auto-local-branch = false is generally preferred.

docs/branches.md isn't updated as it would otherwise conflict with #2625. I
think the "Remotes" section will need a non-trivial rewrite.

#1136, #1862
This commit is contained in:
Yuya Nishihara 2023-12-16 19:01:44 +09:00
parent 6971ec239a
commit 87a8238bee
7 changed files with 32 additions and 16 deletions

View file

@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking changes
* `jj git fetch` no longer imports new remote branches as local branches. Set
`git.auto-local-branch = true` to restore the old behavior.
### New features
* Information about new and resolved conflicts is now printed by every command.

View file

@ -223,7 +223,7 @@
"auto-local-branch": {
"type": "boolean",
"description": "Whether jj creates a local branch with the same name when it imports a remote-tracking branch from git. See https://github.com/martinvonz/jj/blob/main/docs/config.md#automatic-local-branch-creation",
"default": true
"default": false
},
"abandon-unreachable-commits": {
"type": "boolean",
@ -382,4 +382,4 @@
}
}
}
}
}

View file

@ -73,6 +73,19 @@ fn get_log_output(test_env: &TestEnvironment, workspace_root: &Path) -> String {
test_env.jj_cmd_success(workspace_root, &["log", "-T", template, "-r", "all()"])
}
#[test]
fn test_git_fetch_with_default_config() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
let repo_path = test_env.env_root().join("repo");
add_git_remote(&test_env, &repo_path, "origin");
test_env.jj_cmd_ok(&repo_path, &["git", "fetch"]);
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
origin@origin: oputwtnw ffecd2d6 message
"###);
}
#[test]
fn test_git_fetch_default_remote() {
let test_env = TestEnvironment::default();

View file

@ -499,19 +499,19 @@ conflict is considered fully resolved when there are no conflict markers left.
### Automatic local branch creation
By default, when `jj` imports a new remote-tracking branch from Git, it also
creates a local branch with the same name. In some repositories, this
may be undesirable, e.g.:
When `jj` imports a new remote-tracking branch from Git, it can also create a
local branch with the same name. This feature is disabled by default because it
may be undesirable in some repositories, e.g.:
- There is a remote with a lot of historical branches that you don't
want to be exported to the co-located Git repo.
- There are multiple remotes with conflicting views of that branch,
resulting in an unhelpful conflicted state.
You can disable this behavior by setting `git.auto-local-branch` like so,
You can enable this behavior by setting `git.auto-local-branch` like so,
```toml
git.auto-local-branch = false
git.auto-local-branch = true
```
This setting is applied only to new remote branches. Existing remote branches

View file

@ -352,8 +352,6 @@ Note: desired behavior of `jj branch forget` is to
## Remaining issues
* `git.auto_local_branch = false` by default to help Git interop?
* https://github.com/martinvonz/jj/issues/1862
* https://github.com/martinvonz/jj/issues/1278 pushing to tracked remote
* Option could be added to push to all `tracking` remotes?
* Track remote branch locally with different name

View file

@ -165,12 +165,14 @@ The hyphen after `your-feature` comes from the
## Working with other people's branches
By default `jj git clone` and `jj git fetch` clone all active branches from
the remote. This means that if you want to iterate or test another
contributor's branch you can `jj new <branchname>` onto it.
By default, `jj git clone` imports the default remote branch (which is usually
`main` or `master`), but `jj git fetch` doesn't import new remote branches to
local branches. This means that if you want to iterate or test another
contributor's branch, you'll need to do `jj new <branch>@<remote>` onto it.
If your remote has a large amount of old, inactive branches or this feature is
undesirable, set `git.auto-local-branch = false` in the config file.
If you want to import all remote branches including inactive ones, set
`git.auto-local-branch = true` in the config file. Then you can specify a
contributor's branch as `jj new <branch>` instead of `jj new <branch>@<remote>`.
You can find more information on that setting [here][auto-branch].

View file

@ -47,7 +47,7 @@ pub struct GitSettings {
impl GitSettings {
pub fn from_config(config: &config::Config) -> Self {
GitSettings {
auto_local_branch: config.get_bool("git.auto-local-branch").unwrap_or(true),
auto_local_branch: config.get_bool("git.auto-local-branch").unwrap_or(false),
abandon_unreachable_commits: config
.get_bool("git.abandon-unreachable-commits")
.unwrap_or(true),
@ -58,7 +58,7 @@ impl GitSettings {
impl Default for GitSettings {
fn default() -> Self {
GitSettings {
auto_local_branch: true,
auto_local_branch: false,
abandon_unreachable_commits: true,
}
}