jj icon indicating copy to clipboard operation
jj copied to clipboard

jj git clone not cloning all tags

Open lfrancke opened this issue 1 year ago • 5 comments

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 [email protected]: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 [email protected]: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

lfrancke avatar Oct 21 '24 10:10 lfrancke

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 avatar Oct 21 '24 10:10 yuja

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

ilyagr avatar Oct 21 '24 20:10 ilyagr

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

⮞ git clone [email protected]: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

tim-janik avatar Oct 24 '24 11:10 tim-janik

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.

arxanas avatar Oct 25 '24 19:10 arxanas

Pretty sure I just experienced this problem. After a fresh jj git fetch, I was not able to see / use this tag: https://github.com/ARM-software/arm-trusted-firmware/releases/tag/lts-v2.12.1 After a git fetch --tags --all, I was able to use the tag with jj.

$ jj version
jj 0.27.0

ElvishJerricco avatar Mar 31 '25 23:03 ElvishJerricco

Should be fixed with https://github.com/jj-vcs/jj/pull/7192

ipetkov avatar Aug 16 '25 00:08 ipetkov