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

Support git-like remote and local branch UX #1136

Closed
chooglen opened this issue Jan 27, 2023 · 6 comments
Closed

Support git-like remote and local branch UX #1136

chooglen opened this issue Jan 27, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@chooglen
Copy link
Contributor

chooglen commented Jan 27, 2023

Description

jj treats remote branches very differently compared to Git. Unfortunately, jj is primarily used as a client to remote Git repositories which the user may or may not have control over. Certain idiomatic Git patterns don't fit this model well, leading to a bad UX:

  • Adding a remote with a large number of branches that developers aren't necessarily expected to interact with regularly, e.g. https://github.com/gitster/git has a large number of historical topic branches. This is a somewhat GIt-specific problem since Git repos tend to have more branches than Mercurial repos have bookmarks.

    • branch import causes local branches to be created, and they may be exported back to Git unexpectedly
    • the output of jj branch list becomes very large and largely irrelevant
  • Adding multiple remotes with different branching structures. In Git, remotes can be used to "bookmark" URLs without necessarily fetching the entire contents of the remote/creating local branches for each remote branch.

    • when branches share the same name across remotes (particularly read-only remotes), the "conflicted" branch state becomes less meaningful

Proposal

Add a config option that gives a more Git-like user experience to remote branches. An initial list of features could be:

  • Don't create local branches automatically on imports
  • Hide remote-only branches in jj branch list
  • When deleting a remote branch with jj git push --branch=no-local-target, require an explicit --delete flag
@martinvonz
Copy link
Member

SGTM :)

@samueltardieu
Copy link
Contributor

This should be configurable by remote repository in addition to a default setting.

Wouldn't it be useful to also have an option for jj git clone and jj git remote add to overwrite the configured default behaviour? It would add this remote-specific option to the local configuration file.

@martinvonz
Copy link
Member

This should be configurable by remote repository in addition to a default setting.

Makes sense.

Wouldn't it be useful to also have an option for jj git clone and jj git remote add to overwrite the configured default behaviour? It would add this remote-specific option to the local configuration file.

That also makes sense to me. We'd need support for writing configuration files first.

yuja added a commit to yuja/jj that referenced this issue Jun 28, 2023
Typical query would be something like -r 'mine()' or -r 'branches()' to
exclude remote-only branches jj-vcs#1136.

I originally considered a filter applied only to local targets, but it might
also be useful to filter by remote names. So both local and remote targets are
tested. It's also nice that -r 'all()' includes deleted/forgotten branches.
Suppose a local-ref target wouldn't likely be pointed by unrelated remote ref,
I think non-strict filtering like this is practically okay.
yuja added a commit to yuja/jj that referenced this issue Jun 29, 2023
Typical query would be something like -r 'mine()' or -r 'branches()' to
exclude remote-only branches jj-vcs#1136.

I originally considered a filter applied only to local targets, but it might
also be useful to filter by remote names. So both local and remote targets are
tested. It's also nice that -r 'all()' includes deleted/forgotten branches.
Suppose a local-ref target wouldn't likely be pointed by unrelated remote ref,
I think non-strict filtering like this is practically okay.
yuja added a commit to yuja/jj that referenced this issue Jun 30, 2023
Typical query would be something like -r 'mine()' or -r 'branches()' to
exclude remote-only branches jj-vcs#1136.

I originally considered a filter applied only to local targets, but it might
also be useful to filter by remote names. So both local and remote targets are
tested. It's also nice that -r 'all()' includes deleted/forgotten branches.
Suppose a local-ref target wouldn't likely be pointed by unrelated remote ref,
I think non-strict filtering like this is practically okay.
@ilyagr
Copy link
Contributor

ilyagr commented Jul 1, 2023

Hide remote-only branches in jj branch list

I think this is a good idea, we also discussed it a bit with @yuja in #1762 (comment).

I think an important detail is that if jj branch list does not print these branches by default, it should instead print a message along the lines of:

Skipped 55 inactive branches; show them with --include-inactive.

yuja added a commit to yuja/jj that referenced this issue Jul 1, 2023
Typical query would be something like -r 'mine()' or -r 'branches()' to
exclude remote-only branches jj-vcs#1136.

The query matches against local targets only. This means there's no way to
select deleted/forgotten branches by -r option. If we add a default revset
configuration, we'll need some way to turn the default off.
yuja added a commit to yuja/jj that referenced this issue Jul 2, 2023
Typical query would be something like -r 'mine()' or -r 'branches()' to
exclude remote-only branches jj-vcs#1136.

The query matches against local targets only. This means there's no way to
select deleted/forgotten branches by -r option. If we add a default revset
configuration, we'll need some way to turn the default off.
yuja added a commit that referenced this issue Jul 2, 2023
Typical query would be something like -r 'mine()' or -r 'branches()' to
exclude remote-only branches #1136.

The query matches against local targets only. This means there's no way to
select deleted/forgotten branches by -r option. If we add a default revset
configuration, we'll need some way to turn the default off.
yuja added a commit to yuja/jj that referenced this issue Oct 15, 2023
I'm not sure if this is the best way to render non-tracking branches, but
it helps to write CLI tests. Maybe we can add some hint or decoration to
non-tracking branches, but I'd like to avoid bikeshedding at this point.

Since we haven't migrated the push function yet, a deleted branch can be
pushed to non-tracking remotes. This will be addressed later.

jj-vcs#1136
yuja added a commit to yuja/jj that referenced this issue Oct 15, 2023
I'm not sure if this is the best way to render non-tracking branches, but
it helps to write CLI tests. Maybe we can add some hint or decoration to
non-tracking branches, but I'd like to avoid bikeshedding at this point.

Since we haven't migrated the push function yet, a deleted branch can be
pushed to non-tracking remotes. This will be addressed later.

jj-vcs#1136
yuja added a commit to yuja/jj that referenced this issue Oct 16, 2023
I'm not sure if this is the best way to render non-tracking branches, but
it helps to write CLI tests. Maybe we can add some hint or decoration to
non-tracking branches, but I'd like to avoid bikeshedding at this point.

Since we haven't migrated the push function yet, a deleted branch can be
pushed to non-tracking remotes. This will be addressed later.

jj-vcs#1136
yuja added a commit that referenced this issue Oct 16, 2023
I'm not sure if this is the best way to render non-tracking branches, but
it helps to write CLI tests. Maybe we can add some hint or decoration to
non-tracking branches, but I'd like to avoid bikeshedding at this point.

Since we haven't migrated the push function yet, a deleted branch can be
pushed to non-tracking remotes. This will be addressed later.

#1136
yuja added a commit to yuja/jj that referenced this issue Oct 16, 2023
Although this is logically correct, the error message is a bit cryptic. It's
probably better to reject push if non-tracking remote branches exist.

jj-vcs#1136
yuja added a commit to yuja/jj that referenced this issue Oct 17, 2023
Although this is logically correct, the error message is a bit cryptic. It's
probably better to reject push if non-tracking remote branches exist.

jj-vcs#1136
yuja added a commit that referenced this issue Oct 17, 2023
Although this is logically correct, the error message is a bit cryptic. It's
probably better to reject push if non-tracking remote branches exist.

#1136
yuja added a commit to yuja/jj that referenced this issue Oct 17, 2023
… them

I personally don't mind if "jj branch list" showed all non-tracking branches,
but I agree it would be a mess if ~500 remote branches were listed. So let's
hide them by default since non-tracking branches aren't so interesting.

Closes jj-vcs#1136
yuja added a commit to yuja/jj that referenced this issue Oct 18, 2023
I personally don't mind if "jj branch list" showed all non-tracking branches,
but I agree it would be a mess if ~500 remote branches were listed. So let's
hide them by default as non-tracking branches aren't so interesting.

Closes jj-vcs#1136
@yuja yuja closed this as completed in d92be66 Oct 18, 2023
@ppwwyyxx
Copy link

Thanks @yuja for adding this. I think it's better to also hide these branches in jj log by default?

@yuja
Copy link
Contributor

yuja commented Oct 22, 2023

I think it's better to also hide these branches in jj log by default?

I prefer to see remote branches in log, but we should have some way to hide them. Maybe we can add local_branches template keyword for that purpose.

yuja added a commit to yuja/jj that referenced this issue Dec 16, 2023
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 jj-vcs#2625. I
think the "Remotes" section will need a non-trivial rewrite.

jj-vcs#1136, jj-vcs#1862
yuja added a commit to yuja/jj that referenced this issue Dec 16, 2023
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 jj-vcs#2625. I
think the "Remotes" section will need a non-trivial rewrite.

jj-vcs#1136, jj-vcs#1862
yuja added a commit that referenced this issue Dec 16, 2023
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants