Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable auto local branch creation with config option #894

Merged
merged 3 commits into from
Jan 30, 2023

Conversation

chooglen
Copy link
Contributor

@chooglen chooglen commented Dec 14, 2022

As a Git developer, my git/git repo has https://github.com/gitster/git as an upstream. Since we create a local jj branch when we import the remote-tracking branches and then subsequently export the local branches to git, my git repo has seen a sudden explosion in the number of local branches.

This attempts to fix the problem by not creating a local branch during import. This workflow might also be desirable to users with certain remote setups that make local branch creation confusing. FWIW I think I'd sometimes like to have the local branch and sometimes not; I find automatic branch creation useful when there's only one remote, but confusing with >= 3 remotes, like my git/git repo.

An alternative solution to the branch proliferation problem would be to create the local branch but don't export it to Git (which would have also been a fix for #493). However, if we take this PR, I don't see a compelling enough reason to make the Git export configurable, especially since having more knobs makes the UX potentially more confusing.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have added tests to cover my changes

@martinvonz
Copy link
Member

I think this makes sense. Thanks!

@chooglen chooglen force-pushed the push-d50fb2d6c9c1499da78ea446af275342 branch from 00c3f3a to 930a050 Compare December 17, 2022 00:11
@chooglen chooglen changed the title [RFC] Disable auto local branch creation with config option Disable auto local branch creation with config option Dec 17, 2022
@chooglen chooglen marked this pull request as ready for review December 17, 2022 00:12
@avamsi
Copy link
Member

avamsi commented Jan 22, 2023

This would be pretty useful -- chooglen@, would you mind syncing and updating this PR?

@chooglen
Copy link
Contributor Author

Ah, I've been updating this on my end, but haven't had the time to send it out yet. Give me a bit.

@chooglen chooglen force-pushed the push-d50fb2d6c9c1499da78ea446af275342 branch 2 times, most recently from 56624bb to 8358f6d Compare January 26, 2023 01:24
@chooglen
Copy link
Contributor Author

Okay, I think this is ready for review, PTAL :)

lib/src/settings.rs Outdated Show resolved Hide resolved
lib/src/settings.rs Outdated Show resolved Hide resolved
tests/test_git_import_export.rs Outdated Show resolved Hide resolved
tests/test_git_import_export.rs Show resolved Hide resolved
src/commands/branch.rs Outdated Show resolved Hide resolved
@chooglen chooglen force-pushed the push-d50fb2d6c9c1499da78ea446af275342 branch 2 times, most recently from 08ab346 to a967923 Compare January 30, 2023 03:18
We'll add an import test in the next commit.
This test coverage will become more important when we make changes to
remote branch importing.
@chooglen chooglen force-pushed the push-d50fb2d6c9c1499da78ea446af275342 branch 3 times, most recently from 965a8db to d02c1a6 Compare January 30, 2023 03:46
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for adding this feature!

Add a new git.auto-local-branch config option. When set to false, a
remote-tracking branch imported from Git will not automatically create a
local branch target. This is implemented by a new GitSettings struct
that passes Git-related settings from UserSettings.

This behavior is particularly useful in a co-located jj and Git repo,
because a Git remote might have branches that are not of everyday
interest to the user, so it does not make sense to export them as local
branches in Git. E.g. https://github.com/gitster/git, the maintainer's
fork of Git, has 379 branches, most of which are topic branches kept
around for historical reasons, and Git developers wouldn't be expected
to have local branches for each remote-tracking branch.
@chooglen chooglen force-pushed the push-d50fb2d6c9c1499da78ea446af275342 branch from d02c1a6 to 3c1532a Compare January 30, 2023 04:00
@chooglen chooglen merged commit 3418c8f into jj-vcs:main Jan 30, 2023
@chooglen chooglen deleted the push-d50fb2d6c9c1499da78ea446af275342 branch June 7, 2023 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants