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

FR: Honor remote refspec definitions when fetching from git colocated workspaces #5323

Open
ipetkov opened this issue Jan 9, 2025 · 3 comments

Comments

@ipetkov
Copy link

ipetkov commented Jan 9, 2025

Is your feature request related to a problem? Please describe.
Running jj git fetch will fetch all branches (and maybe tags?) of a remote repo, even if git fetch origin wouldn't (due to refspec definitions for the remote)

Describe the solution you'd like
It would be really nice if jj git fetch would honor the refspec definitions for the remote server (instead of fetching the entire repo) if they are present.

Alternatively I'd also settle for jj specific configuration to define equivalent behavior

Describe alternatives you've considered
As an alternative I've been getting by with running git fetch origin && jj git import which does the trick, but it would be nice to not have to remember to not run jj git fetch

Additional context
I work on a monorepo that gets a lot of traffic (tons of tags and branches that are being worked on). Generally speaking each developer working in this monorepo will push their branches behind a specific prefix so that we can judiciously filter out what is fetched by default by git. For example I have the following definition in .git/config:

[remote "origin"]
  fetch = +refs/heads/main:refs/remotes/origin/main
  fetch = +refs/heads/ivan/*:refs/remotes/origin/ivan/*
  tagOpt = --no-tags

That way by default, I'll only fetch and track the main branch as well as my own branches. (If I need to check out someone else's branch I do that with git fetch origin someone/their-branch && git checkout FETCH_HEAD but this functionality is out of scope for this feature request)

@PhilipMetzger
Copy link
Contributor

They will be respected when #4979 is fixed, although we'd probably should have a similar option for a native backend in the future.

@martinvonz
Copy link
Member

martinvonz commented Jan 9, 2025

We could support refspecs that fetc a subset of branches, but we probably don't want to support refspecs that rename branches. For example, +refs/heads/foo/*:refs/remotes/origin/bar/* would fetch a branch called foo/blah as local ref refs/remotes/origin/bar/blah, which jj would import them as bar/blah@origin. If you then push that to the remote, it would be pushed as bar/blah. Unless we also support renaming refspecs for push. I hope we won't need to support renaming in either direction.

git fetch origin someone/their-branch

Does jj git fetch -b someone/their-branch work?

They will be respected when #4979 is fixed

I think it looks like that PR (i.e. #5228) uses the same refspec as we currently use with libgit2.

@ipetkov
Copy link
Author

ipetkov commented Jan 10, 2025

Does jj git fetch -b someone/their-branch work?

It does, thank you! I'll remember that one

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

No branches or pull requests

3 participants