-
Notifications
You must be signed in to change notification settings - Fork 349
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
git: update jj git clone|fetch
to use new GitFetch api directly.
#4960
base: main
Are you sure you want to change the base?
Conversation
c35a6f7
to
c2e4cb0
Compare
08525a0
to
a846163
Compare
ed6876d
to
d5c1a07
Compare
4950b09
to
336bbdd
Compare
d5c1a07
to
5275f9a
Compare
336bbdd
to
11bf992
Compare
git::fetch
takes multiple remotes.0f2cc4d
to
6182c03
Compare
jj git clone|fetch
to use new GitFetch api directly.
813822d
to
51d8892
Compare
CHANGELOG.md
Outdated
* `jj git fetch` with multiple remotes will now fetch from all remotes before | ||
importing refs into the jj repo. This fixes a race condition where the treatment | ||
of a commit that is found in multiple fetch remotes depended on the order the | ||
remotes where specified. |
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.
Can you add a test for this issue?
jj git clone|fetch
to use new GitFetch api directly.jj git clone|fetch
to use new GitFetch api directly.
d661392
to
d96eb38
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.
git: refactor jj git clone|fetch to use new GitFetch api directly.
[...]
This fixes #4920 as it first fetches from all remotes beforeimport_refs()
nit: I think "refactor" is supposed to mean that it has no impact on functionality, so just say "git: use new GitFetch api directly in jj git clone|fetch
" or something instead
ba5b940
to
b2e66aa
Compare
jj git clone|fetch
to use new GitFetch api directly.jj git clone|fetch
to use new GitFetch api directly.
makes sense. Updated. |
b2e66aa
to
b733e17
Compare
* Make the new `GitFetch` api public. * Move `git::fetch` to `lib/tests/test_git.rs` as `git_fetch`, to minimize churn in the tests. Update test call sites to use `git_fetch` * Delete the `git::fetch` from `lib/src/git.rs`. * Update `jj git clone` and `git_fetch` in `cli/src/git_utils.rs` to use the new api directly. Removing one redundant layer of indirection. * This fixes #4920 as it first fetches from all remotes before `import_refs()` is called, so there is no race condition if the same commit is treated differently in different remotes specified in the same command. * Add test for the race condition. Fixes: #4920
b733e17
to
6757530
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.
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.
Restore formatting changes in CHANGELOG.md
})?; | ||
print_git_import_stats(ui, fetch_tx.repo(), &stats.import_stats, true)?; | ||
let default_branch = | ||
with_remote_git_callbacks(ui, None, |cb| -> Result<Option<String>, CommandError> { |
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.
nit: type annotation isn't needed
GitFetchStats { | ||
default_branch, | ||
import_stats, | ||
}, |
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.
nit: we don't need to return import_stats
. It will help remove struct GitFetchStats
. (can be addressed later)
GitFetchError::GitImportError(err) => err.into(), | ||
GitFetchError::InternalGitError(err) => map_git_error(err), | ||
_ => user_error(err), | ||
with_remote_git_callbacks(ui, None, |cb| -> Result<(), CommandError> { |
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.
nit: type annotation isn't needed if ?; Ok(())
is removed
@rem1: qxosxrvv 6a211027 message | ||
rem2: yszkquru 2497a8a0 message | ||
@rem2: yszkquru 2497a8a0 message | ||
"###); |
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.
Does this test fail without this patch? iirc, the issue was that a bookmark was moved in one remote, and descendant commit of that bookmark was added by the other remote, or something like that.
@@ -1394,31 +1393,6 @@ pub struct GitFetchStats { | |||
pub import_stats: GitImportStats, | |||
} | |||
|
|||
#[tracing::instrument(skip(mut_repo, git_repo, callbacks))] |
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.
nit: perhaps, tracing::instruments()
will have to be moved to fetch()
(and maybe import_refs()
)
GitFetch
api public.git::fetch*
to use the new API.One interesting artifact of the new API is that it holds onto a reference
of the
tx.repo_mut()
, so the GitFetch object needs to fall go of scopecompletely before we can make any other mutable calls to
tx
.git::fetch
jj git clone
andgit_fetch
incli/src/git_utils.rs
to usethe new api directly. Removing one redundant layer of indirection.
jj git fetch
with multiple remotes can abandon reachable commits (and rebase reachable descendants) #4920 as it first fetches from all remotes beforeimport_refs()
is called, so there is no race condition if the same commit is treated
differently in different remotes specified in the same command.
Fixes: #4920
Checklist
If applicable:
CHANGELOG.md