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

VCS: Fix weird tag creation #10586

Merged
merged 3 commits into from
Dec 5, 2024
Merged

Conversation

9999years
Copy link
Collaborator

@9999years 9999years commented Nov 22, 2024

Follow-up to #10254; @alt-romes is there a reason to create the tag matching FETCH_HEAD here instead of using FETCH_HEAD directly?

Creating a tag with an arbitrary user-supplied name can cause problems, like the warning below. Fortunately, we can just use FETCH_HEAD as the ref name directly instead of creating a tag to match it!

Running: git fetch origin d1dc91fd977bb4b28f0e01966fa08640a1283318
From /private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/vcstest-90401/src
 * branch            d1dc91fd977bb4b28f0e01966fa08640a1283318 -> FETCH_HEAD

Running: git tag -f d1dc91fd977bb4b28f0e01966fa08640a1283318 FETCH_HEAD

Running: git reset --hard d1dc91fd977bb4b28f0e01966fa08640a1283318 --
warning: refname 'd1dc91fd977bb4b28f0e01966fa08640a1283318' is ambiguous.
Git normally never creates a ref that ends with 40 hex characters
because it will be ignored when you just specify 40-hex. These refs
may be created by mistake. For example,

  git switch -c $br $(git rev-parse ...)

where "$br" is somehow empty and a 40-hex ref is created. Please
examine these refs and maybe delete them. Turn this message off by
running "git config advice.objectNameWarning false"
  • Patches conform to the coding conventions.
  • Is this a PR that fixes CI? If so, it will need to be backported to older cabal release branches (ask maintainers for directions).

@9999years 9999years force-pushed the git-tag-creation-warning branch from 86fed33 to 052e7e3 Compare November 22, 2024 19:19
@9999years 9999years mentioned this pull request Nov 22, 2024
2 tasks
@9999years 9999years changed the title VCS tests: Quieter output VCS: Fix weird tag creation Nov 22, 2024
@9999years 9999years force-pushed the git-tag-creation-warning branch from 052e7e3 to cd14144 Compare November 22, 2024 19:25
@alt-romes
Copy link
Collaborator

Oh, this is problematic -- Cabal "tags" can be commit refs of course...

I'm not looking at the code at the moment, but this decision may have been caused by how the "synchronization" step works: you'll only fetch once, but you may want to synchronize using the tag later on. I'm not entirely sure, but if you mean to look in the meantime, that's what I'd do: does the tag have to exist to synchronize later on?

It's also a bit unfortunate the testsuite missed this. It'd be great if you could add a regression test.

@9999years
Copy link
Collaborator Author

Hmm, we only use the FETCH_HEAD immediately after git fetching, so I think it's fine if we don't make a specific tag for it.

@9999years 9999years force-pushed the git-tag-creation-warning branch from cd14144 to 383a78a Compare November 22, 2024 22:40
@9999years
Copy link
Collaborator Author

It's also a bit unfortunate the testsuite missed this. It'd be great if you could add a regression test.

I'm not sure it's possible, because it's only a warning...

@9999years 9999years force-pushed the git-tag-creation-warning branch from 383a78a to 322e598 Compare November 22, 2024 22:44
Copy link
Collaborator

@geekosaur geekosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, what's here is fine, I'm just trying to figure the logic behind the original version. FETCH_HEAD can change, tags can't (unless you remove, recreate, and force push).

cabal-install/src/Distribution/Client/VCS.hs Show resolved Hide resolved
@geekosaur
Copy link
Collaborator

geekosaur commented Nov 23, 2024

Okay, I can't make sense of it. In particular, there seems to be no reason why you can't do

git fetch refspec # using the refspec from source-repository-package
git switch -d refspec
git submodule update --init # optional

and not even bother with a tag. It's minimal, it's faster than what we were doing before, and I can't find any reason why anything else would be necessary given that it's only intended to be built, with no other git commands and no editing. In particular, this is more or less what submodules do, and while submodules have their problems this isn't one of them.

@ulysses4ever
Copy link
Collaborator

I hope it's okay to comment on the PR even though it's a draft. If not, please let me know.

My understanding of git aligns completely with what @geekosaur is saying. I think we could switch to the simpler approach.

@alt-romes
Copy link
Collaborator

I may have overcomplicated the design when I was down in the weeds.

If that is what submodules do, it seems sensible it would work for us too.

I wasn't aware of git switch -d, so maybe that's why

@alt-romes
Copy link
Collaborator

What's the status of this patch @9999years?

@9999years
Copy link
Collaborator Author

@alt-romes The patch is ready, just needs a second review before it can be merged.

@alt-romes alt-romes added the merge me Tell Mergify Bot to merge label Dec 2, 2024
@mergify mergify bot added the ready and waiting Mergify is waiting out the cooldown period label Dec 2, 2024
@Kleidukos Kleidukos added the attention: needs-manual-qa PR is destined for manual QA label Dec 3, 2024
@mergify mergify bot added the merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days label Dec 5, 2024
Creating a tag with an arbitrary user-supplied name can cause problems.
If we fetch, we can just use `FETCH_HEAD` as the ref name directly!

```
Running: git fetch origin d1dc91fd977bb4b28f0e01966fa08640a1283318
From /private/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/vcstest-90401/src
 * branch            d1dc91fd977bb4b28f0e01966fa08640a1283318 -> FETCH_HEAD

Running: git tag -f d1dc91fd977bb4b28f0e01966fa08640a1283318 FETCH_HEAD

Running: git reset --hard d1dc91fd977bb4b28f0e01966fa08640a1283318 --
warning: refname 'd1dc91fd977bb4b28f0e01966fa08640a1283318' is ambiguous.
Git normally never creates a ref that ends with 40 hex characters
because it will be ignored when you just specify 40-hex. These refs
may be created by mistake. For example,

  git switch -c $br $(git rev-parse ...)

where "$br" is somehow empty and a 40-hex ref is created. Please
examine these refs and maybe delete them. Turn this message off by
running "git config advice.objectNameWarning false"
```
@Mikolaj Mikolaj force-pushed the git-tag-creation-warning branch from 7057fac to 18a040a Compare December 5, 2024 17:42
@mergify mergify bot merged commit 8cc49d9 into haskell:master Dec 5, 2024
49 checks passed
@9999years 9999years deleted the git-tag-creation-warning branch December 5, 2024 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attention: needs-manual-qa PR is destined for manual QA merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days merge me Tell Mergify Bot to merge ready and waiting Mergify is waiting out the cooldown period
Projects
Status: To Test
Development

Successfully merging this pull request may close these issues.

5 participants