-
Notifications
You must be signed in to change notification settings - Fork 346
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
Fix bug where a forgotten branch couldn't be fetched (v1) #1714
Conversation
7ec4905
to
e0ddf77
Compare
56125fc
to
fc9a791
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Not finished reviewing yet. I'll take a look later today or tomorrow.)
lib/src/git.rs
Outdated
import_refs(mut_repo, git_repo, git_settings) | ||
import_some_refs(mut_repo, git_repo, git_settings, |_| { | ||
ImportMethod::MergeOrResurrect | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's equally annoying if forgotten branches are resurrected by jj git fetch
.
It might be nice if we had a set of "tracked" remote branches. No local branch will be re-created for forgotten (or "untracked") remote branch. And to re-track such branch, user will run jj branch track
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's equally annoying if forgotten branches are resurrected by jj git fetch.
I'm going to rework this a bit so that only remote-tracking branches are imported at this point.
I'm not sure whether that addresses your question at all; the question could be in regard to several things, but for most of the others I wouldn't expect it to show up at this line of code.
It might be nice if we had a set of "tracked" remote branches. No local branch will be re-created for forgotten (or "untracked") remote branch. And to re-track such branch, user will run jj branch track.
This is a very interesting idea. One possible conclusion from this PR and all the jj branch forget
tests I'm adding is that jj branch forget
is a bad command to have, and some other abstraction could be better. I haven't thought your specific idea through entirely, but it seems to match what I usually want to do better.
But until we do that, I think jj git fetch
should behave as I described. The difference between it and jj git import
is that jj git fetch
takes glob arguments and is not run automatically in colocated repos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to rework this a bit so that only remote-tracking branches are imported at this point.
This is now more or less done. I hoped to go further and make fetch
actually not touch other branches, but I had a test failure with ilyagr@tmp_onlyremotes. I couldn't immediately decide whether it's safe to change the corresponding test. Here is the portion until the failing assertion:
https://github.com/martinvonz/jj/blob/8a8b96a448a949c50e40966ead8eac0c730ce158/lib/tests/test_git.rs#L1561-L1579
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean I want jj branch forget
persist as much as possible. The current behavior isn't great, but it doesn't resurrect forgotten (i.e. uninteresting) branch so long as the remote is unchanged.
Perhaps, I would probably want jj git fetch
that doesn't import most of the remote branches. I'd like to get remote changes, but doesn't want to maintain branches they have.
jj branch forget
is a bad command to have, and some other abstraction could be better.
I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be nice if we had a set of "tracked" remote branches. No local branch will be re-created for forgotten (or "untracked") remote branch. And to re-track such branch, user will run jj branch track.
[...]
Perhaps, I would probably want jj git fetch that doesn't import most of the remote branches. I'd like to get remote changes, but doesn't want to maintain branches they have.
I've also felt this way: I don't want to logically import a given remote branch without explicitly asking for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's my write-up: #1734. It is very much a draft, it's quite possible that I missed something important, and I'm happy to change it, or to throw it out if we decide on a different approach (or switch to more git-like branch model).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mainly used it when I accidentally fetched too many branches
Isn't undo
a better option in that case? I guess undo
wouldn't work at least for colocated repo, but I think it's the same kind of problem we've discussed in the other jj undo
thread.
As for what gets fixed/merged first, I'm unsure what the best option is.
Does this forget
+ fetch
issue need an immediate fix? I feel it's not serious bug, but I might be wrong.
Here's my write-up: #1734
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't undo a better option in that case? I guess undo wouldn't work at least for colocated repo, but I think it's the same kind of problem we've discussed in the other jj undo thread.
Sometimes a bit of time has passed and it's hard to find in the op-log.
Sometimes it might be easier to fetch all branches and then forget some globs than to fetch some globs.
More generally, I think that, as far as possible, anything undo
can do should be doable by regular commands for similar reasons (at least, that I can think of now): it may be hard to search the oplog or you might want to partially undo something. I'm not sure how important this principle is to me, but this situation feels like it should apply.
I guess undo wouldn't work at least for colocated repo
Aargh. At the moment, I have more emotions than words for this.
I actually think it might work and we might even have a test for it, but I need to double-check. If not, I should add a test to #1700 to see what happens, at least.
Does this forget + fetch issue need an immediate fix? I feel it's not serious bug, but I might be wrong.
I felt like the situation from Discord that I put in the summary is quite a confusing situation for a user to end up in. I find it hard to weigh that against you (and potentially other people) who may be relying on the current behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another use-case for branch forget
I just came upon: you did a jj branch delete
and realized that you don't want to destroy the branch on push. I just remembered it after looking at #1537.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that, as far as possible, anything undo can do should be doable by regular commands
Yes, I agree about that. It might be a maintenance command like jj git forget-refs
or option to ignore known git_refs state, but I don't know.
Not sure where to mention this, but another thing I was considering is having |
@arxanas, @yuja, @martinvonz I'm not sure whether I'll have time for this in the near future (especially since I'm itching to be done with #1700), but here are some thoughts (an RFC?) about a redesign the @yuja suggested It's not clear to me whether the list of forgotten branches should list branches or globs. E.g., should A technical point: in colocated repos, I'd want I'm not sure how long it'd take it to settle on a design and implement it, and whether it's worth waiting for that or whether it's better to call that a long-term plan. |
I tested out what happens when fetching a forgotten branch that moved on the remote. It indeed creates a conflict. This is part of the tests in this PR now. It also turns out that my fix doesn't actually fix that part of the problem. I need to think about how big of a problem that is. It wouldn't be a frequently encountered bug (especially since I don't think our UI shows the difference between a normal branch and a move-deletion branch conflict), but it would be confusing to those who notice it. |
5584286
to
de95b6d
Compare
The fix is slightly messy, but I don't know a better way without reworking the logic of `jj git fetch` and `jj git push` in-depth. This bug was originally reported by @arxanas in a [Discord discussion]. [Discord discussion]: https://discord.com/channels/968932220549103686/969829516539228222/1114997445949136936 Summary: > How do I proceed here to check out the remote branch that I know exists? > > ``` > $ jj git fetch --branch 'arxanas/fsmonitor' --remote origin > Nothing changed. > $ jj checkout arxanas/fsmonitor > Error: Revision "arxanas/fsmonitor" doesn't exist > $ jj checkout arxanas/fsmonitor@origin > Error: Revision "arxanas/fsmonitor@origin" doesn't exist > $ git show origin/arxanas/fsmonitor > commit bac43af (origin/arxanas/fsmonitor, refs/jj/keep/bac43af9fbaade36a2374f4b2a7457ca4caa05ee) > Author: Waleed Khan <[email protected]> > Date: Fri Jun 10 18:58:21 2022 -0700 > > fsmonitor: add `.watchmanconfig` to repo > > This identifies the directory as Watchman-enabled. Additional config settings can go in this file. > > diff --git a/.watchmanconfig b/.watchmanconfig > new file mode 100644 > index 00000000..0967ef42 > --- /dev/null > +++ b/.watchmanconfig > @@ -0,0 +1 @@ > +{} > ```
I'll reopen this if it seems more urgent, but otherwise I'm hoping we'll either have a minimal version of this that doesn't mess up Yuya's usecase or we'll have a full-blown redesign as discussed in #1734. |
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1714, or we have a better idea.
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1714, or we have a better idea.
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1714, or we have a better idea.
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1714, or we have a better idea.
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1714, or we have a better idea.
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1714, or we have a better idea.
This is a bit unwieldy; see a comment in the code for a detailed explanation. We'll have to decide whether we prefer this, or we prefer the approach of jj-vcs#1714, or we have a better idea.
This PR is obsoleted by #1771. |
The fix is slightly messy, but I don't know a better way without reworking
the logic of
jj git fetch
andjj git push
in-depth.This bug was originally reported by @arxanas in a Discord discussion.
Summary:
Checklist
If applicable:
CHANGELOG.md