-
Notifications
You must be signed in to change notification settings - Fork 319
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
FR: better design for ignoring branches #1734
Comments
Does it mean "ignored branches" are effectively negative refspec set by default? In my usecase, I want to see other people's branches, but I'm not willing to maintain such branches (or branch conflicts especially) forever. And I want to freely get rid of them.
That's why I said I would want I think git-like branch model will work better for my usecase (because there will be no local branch upfront), but I'm not strongly against hg-like model.
Somewhat related: with |
I see essentially two options here: either I suggested the first option here because it seemed simpler than the second (fewer places to change in the implementation) and convenient enough for the usecases that come to my mind (see #1714 (comment)). If we go with the second option, it seems like it would be difficult for us to help the user to tell whether any new branches were silently ignored since a bit of time ago.
Fair enough. I find it strange that the usecases that seem so natural to me seem awkward to you, and vice-versa. This makes it hard for me to judge which of your suggestions or their variations seems best to me. One idea that makes me more comfortable with this is that we could have Elsewhere, you suggested making a special command to get rid of remote branches. That could go with making The alternative of I'll try to pay more attention to where that might be useful in my workflow. I also wonder what other people think. I think I can live with many of these options. For now, my preference would still be to have Update: If we change the default of
I want to get rid of that config. My feeling is that it's an inferior workaround, and only exists because people don't have a good way to get rid of branches they don't want. Of course, I could be missing somebody's usecase.
Acknowledged. Very subjectively implementing that feels unwieldy to me. I don't want to rethink the entire I find the hg branch model pleasant for my usecases, even though it's obviously less flexible. This doesn't necessarily mean it's not a good idea to switch, and it could be easier than I fear once somebody starts the work. We should keep the idea in mind, and especially the usecases that would be easier that way. |
AFAIK, the second option I proposed is a natural extension to It won't help my usecase, but I feel my requirement is conceptually different from yours.
Maybe because I rely on anonymous branches for my changes? When I get branch conflicts, it's 100% someone else's branch, and I just don't wanna be bothered by that. :)
According to #894, exporting tons of local branches is the problem. I think we'll need a way to ban local branch creation upfront (because export is automated in colocated repo.)
A bit off-topic: Is it convenient that |
Good question! I think there are two essentially different situations where I use
There, it is essential that the children of the abandoned commit are rebased onto its parents. Usually this doesn't raise any questions about branches, but sometimes I the commit I want to abandon when thinking of commits this way may have a branch commit, or might even be a leaf. In this case, it makes perfect sense for Also, if the branch is not on a leaf commit, it's unclear what else to do with the branch but move it back. While, the way I described it, the second case might seem rare, I think it's pretty important -- consistent tools for editing commit chains before sending a PR are important to jj. Clearly, having the same command for both cases is imperfect, but I don't have a proposal for how to improve the situation right now. But I'm happy to now be consciously aware of the problem. |
Re your other points, I don't have many clear thoughts about most.
This is likely it. I never use anonymous branches, not after I realized that I'd occasionally have to copy-paste their full names. I think I could benefit from them, maybe, but I find jj's support for them not nearly good enough to be practical for me and I'm a bit confused how anybody manages to use them productively in the current state (even though you and Martin obviously do). |
Perhaps this is off topic, but when do you need to use the full name? What do you even need by "their full name"? The change id? |
To move them to other commits (which also breaks the change of correspondence) if e.g. the PR turns out to be two commits instead of one (in which case I could use
|
@yuja, I'm worried that thinking out the best way for things to work will take some time and effort. Would you be OK with implementing, for now, a minimal fix to the bug from #1714 that would not make your workflow worse? I feel bad about that bug, and it bothers me a bit more since I added a hint to use I'm thinking of making a fix that would be invisible to most users. It's essentially "phase 1", but I'm currently thinking that:
It seems to me that this much should be implementable relatively quickly (thought maybe I'm missing something? One thing that could sabotage this plan is if I underestimate the difficulty of the "quick fix"), before we resolve all the surrounding gnarly issues (import/export of remote-tracking branches, best UI, etc). One potential problem I see is that it's not clear whether |
I'm okay with breaking my workflow (temporarily), and I'd prefer to keep a hotfix minimal than adding new "ignore" concept, which we aren't sure the model will work out. Implementation-wise, my feeling for #1714 is that we're patching wrong place |
Related #1136
I tend to do fetch everything, and discard outdated/uninteresting branches when things gets messy. I think that's another difference from your workflow. I'll play with |
I'm looking at this; it seems feasible and to do approximately what we want. For some reason, my draft version also breaks a test assertion at Line 1041 in c625e93
|
Appears that |
Thanks, good catch! I'm not sure I follow your idea for handling them separately. I tried at first (not very hard, perhaps), but a lot of the code got repeated. Also, perhaps at some point jj will manipulate git-tracking branches in a way that it needs to export updates, not just deletions. |
There's still an annoying problem: in a normal repo, The simplest solution would be to run
|
Note: This is orthogonal to the original "ignoring branches" idea. It's more like a git-like UX adaptation #1136 to JJ's branch model.
Tried this setup for a week, and I feel comfortable with that. There are only a few synced local branches ("main" and my ongoing PRs), and the others are remote only.
The downside is the same as #1136.
To mitigate the last bullet point, we'll probably need a flag stored in view, not in config file. Implementation ideaAdd per-remote-branch "tracking" flag, something like: struct BranchTarget {
local_target: Option<RefTarget>,
remotes: BTreeMap<String, {target: RefTarget, tracking: bool}>,
} We could add a per-branch flag, but it doesn't make sense that a branch with no remotes can be set to "tracking". I also think per-remote-branch flag is technically correct. A
An "absent" branch cannot be pushed. When tracking flag will be set:
|
Interesting! I haven't fully thought this through, but here are a few thoughts I had so far.
I think all of these points are about the UI, and it seems likely that the design can support them. I like that in your design, the value of the
Why should an entire branch be marked as absent? I think we can allow a missing branch to be deleted on one remote and absent with respect to another remote. |
Also, your design is the opposite of the the one I was thinking of in the following way. I was thinking that a branch/remote pair should have one of the following states:
Whereas in your design, the states are:
Perhaps we want to allow all four states, and have I'm not sure at the moment which of these is better. Perhaps you have some thoughts? Why not forget the RefTarget when marking a branch as untracked? I guess, in your design, whether a non-existent branch/remote pair is tracked or not is essentially determined by the |
I thought of a reason to allow untracked branches with a Let's say we have a colocated repo and an untracked branch in it, and the user does
The first option seems more user-friendly. |
Right. We can add/extend
Good idea. Non-tracking remote branches can be excluded there.
Good point. I think it's practically okay to merge as
Ah, it's more like a UI stuff. I was thinking how it should be rendered in
Perhaps, the states without RefTarget can be determined by config file when "Not tracked and having a RefTarget" is the one we don't have right now. This state shouldn't be affected by editing config file because tracked remote RefTarget should have been merged in to local RefTarget. |
I feel like this FR is obsolete now that https://github.com/martinvonz/jj/blob/9e15fba4941e00685a998d774d85f3e0cdca739a/docs/design/tracking-branches.md is implemented. We can have further discussions in new issues. |
As discussed in #1714,
jj
currently does not have good support for a situation where the user wants to ignore a large number of branches on the remote. Here is a draft design outline for a possible fix.This design assumes that we stay with hg-like concept of branches: a branch is assumed to correspond to a branch of the same name on any remote.
Phase 1
We rename
jj branch forget
tojj branch ignore
and have it persistently forget branches. Ignored branches are neither imported byjj git import
nor fetched byjj git fetch
. From the user perspective, both the branch and its remote-tracking branches disappear (but see Phase 2).We have
jj branch ignore --list
to list ignored branches.We introduce a
jj branch unignore
command to remove branches from the list of forgotten branches.We should make sure that
jj branch create/set
and other potential ways of creating branches automatically un-ignore the branch. This could be done onjj git export
/jj git push
.Technically, the BranchTarget struct will gain a new enum field that says whether this branch is ignored.
In colocated repos,
jj git export
will remove the ignored branch from the git repo. We can havejj git push
remove the ignored branch from the git repo's list of remote-tracking branches.Phase 2
The usecase here is less clear to me, so this outline is a bit vague.
Add a
--local
option tojj git ignore
that causes only the local branch to disappear.jj git fetch
still imports the remote-tracking branches, but does not recreate the local branch. The local branch can be recreated withjj branch set
or byjj git unignore; jj git fetch
.In a colocated repo, a "locally unignored" branch should have the git repo's local branches removed but the remote-tracking branches kept.
The text was updated successfully, but these errors were encountered: