Byron / gitoxide

An idiomatic, lean, fast & safe pure Rust implementation of Git
Apache License 2.0
8.42k stars 276 forks source link

gix cannot clone a repo with a branch called HEAD #1428

Open LawnGnome opened 1 week ago

LawnGnome commented 1 week ago

Current behavior 😯

Attempting to clone a repository that has a branch called HEAD results in this error:

$ gix clone https://github.com/promised-ai/rv
Error: Found 1 issue that prevents the refspec mapping to be used: 
    Conflicting destination "refs/remotes/origin/HEAD" would be written by refs/heads/HEAD ("+refs/heads/*:refs/remotes/origin/*"), HEAD ("HEAD:refs/remotes/origin/HEAD")

(I have absolutely no idea how this happened in that repo in the first place; I'm not affiliated with it in any way. But the branch does exist, according to GitHub.)

Expected behavior 🤔

A clone, presumably.

Git behavior

Git does manage to perform the clone:

$ git clone https://github.com/promised-ai/rv
Cloning into 'rv'...
remote: Enumerating objects: 7170, done.
remote: Counting objects: 100% (1619/1619), done.
remote: Compressing objects: 100% (534/534), done.
remote: Total 7170 (delta 1124), reused 1447 (delta 1032), pack-reused 5551
Receiving objects: 100% (7170/7170), 1.99 MiB | 4.96 MiB/s, done.
Resolving deltas: 100% (5275/5275), done.

Steps to reproduce 🕹

gix clone https://github.com/promised-ai/rv

Byron commented 1 week ago

Thanks a lot for reporting! It looks like this issue even prevents it from attempting any clone at all and clearly should manage to succeed.

I will work on a fix a little later, but hope to get to it towards the end of the week.