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

jj git clone not cloning all tags #4682

Open
lfrancke opened this issue Oct 21, 2024 · 4 comments
Open

jj git clone not cloning all tags #4682

lfrancke opened this issue Oct 21, 2024 · 4 comments
Labels
🐛bug Something isn't working

Comments

@lfrancke
Copy link
Collaborator

Description

Note

I initially brought this up on Discord.

I see some tags missing after running a jj git clone.

Steps to Reproduce the Problem

  1. jj git clone git@github.com:apache/druid.git druid-jj-test
  2. jj tag list | wc -l -> results in 456 tags for me today (2024-10-21)
  3. git clone git@github.com:apache/druid.git
  4. git show-ref | grep refs/tags | wc -l shows 502 tags

Expected Behavior

Same number of tags between jj and git.

Actual Behavior

Some tags are missing from jj tag list.

One tag that is missing (as an example) is: refs/tags/druid-30.0.0 with rev 09d36ee324747f1407705c27618b6d415c3fa8a9.

@yuja suggested the following: "Tag refs are fetched if they are ancestors of refs/heads/*."
I have very limited git knowledge beyond the basics (shame on me) so I did some experimenting which might be totally wrong.

❯ git rev-parse druid-30.0.0
09d36ee324747f1407705c27618b6d415c3fa8a9

❯ git rev-parse druid-30.0.1
a30af7a91d528e5c3a90356a5592abc7119191c6

❯ git merge-base --is-ancestor 09d36ee324747f1407705c27618b6d415c3fa8a9 master | complete
╭───────────┬───╮
│ stdout    │   │
│ stderr    │   │
│ exit_code │ 1 │
╰───────────┴───╯

❯ git merge-base --is-ancestor a30af7a91d528e5c3a90356a5592abc7119191c6 master | complete
╭───────────┬───╮
│ stdout    │   │
│ stderr    │   │
│ exit_code │ 1 │
╰───────────┴───╯

According to the merge-base docs:

Check if the first <commit> is an ancestor of the second <commit>, and exit with status 0 if true, or with status 1 if not. Errors are signaled by a non-zero status that is not 1.

Specifications

  • Platform: Linux
  • Version:
❯ jj --version
jj 0.22.0
@yuja
Copy link
Collaborator

yuja commented Oct 21, 2024

For some context, the current jj git clone implementation is roughly equivalent to jj git init followed by git fetch (which fetches refs/heads/*:refs/remotes/<remote>/* by default.) If tags aren't referenced by branch refs, the corresponding commits won't be fetched by jj git clone.

@yuja yuja added the 🐛bug Something isn't working label Oct 21, 2024
@ilyagr
Copy link
Collaborator

ilyagr commented Oct 21, 2024

I guess it'd be nice to have jj git fetch --all-tags as well, and then jj git clone could use it.

@tim-janik
Copy link
Collaborator

For the record, colocated repositories do not have this problem:

⮞ git clone git@github.com:apache/druid.git git-druid
⮞ cd git-druid/ && git show-ref | grep refs/tags | wc -l
503
⮞ jj git init --colocate && jj tag list | wc -l
503

@arxanas
Copy link
Collaborator

arxanas commented Oct 25, 2024

Related explanatory context: git fetch <remote> <refspec> by default includes tags in the following manner:

By default, any tag that points into the histories being fetched is also fetched; the effect is to fetch tags that point at branches that you are interested in. This default behavior can be changed by using the --tags or --no-tags options or by configuring remote..tagOpt. By using a refspec that fetches tags explicitly, you can fetch tags that do not point into branches you are interested in as well.

For most of my use-cases, I prefer to pass --no-tags, and I really don't want tags to implicitly be fetched in this way. That being said, it makes sense to match Git's behavior as closely as possible here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants