commit 75236079c0b50ee24defebe1509f537bae91aefe from: Stefan Sperling date: Wed Mar 25 14:30:15 2020 UTC handle refs/remotes/origin/HEAD properly; reported by Matthias aka _xhr_ commit - 465971eec96aef0fcae09797cf38a9f3c2e8cc6a commit + 75236079c0b50ee24defebe1509f537bae91aefe blob - f74cc9ecacc8b745cdb5c73db7f2c60cd9e918ef blob + 03550871081f6ba952a7e6ee214c45a6e3b023b3 --- lib/reference.c +++ lib/reference.c @@ -401,7 +401,7 @@ open_ref(struct got_reference **ref, const char *path_ char *path = NULL; char *absname = NULL; int ref_is_absolute = (strncmp(name, "refs/", 5) == 0); - int ref_is_well_known = is_well_known_ref(name); + int ref_is_well_known = (subdir[0] == '\0' && is_well_known_ref(name)); *ref = NULL; blob - 8457642808883458905c4ddef16686f54b7b7fd2 blob + 94ee8dae3a4f0d0e662bbb772531e3f027ee28ab --- regress/cmdline/ref.sh +++ regress/cmdline/ref.sh @@ -274,12 +274,23 @@ function test_ref_list { return 1 fi + # Create a HEAD ref in the namespace of a remote repository + (cd $testroot/repo && got ref -s refs/heads/master \ + refs/remotes/origin/HEAD) + ret="$?" + if [ "$ret" != "0" ]; then + test_done "$testroot" "$ret" + return 1 + fi + got ref -r $testroot/repo -l > $testroot/stdout echo "HEAD: refs/heads/master" > $testroot/stdout.expected echo "refs/foo/bar/baz: $commit_id" >> $testroot/stdout.expected echo "refs/foo/zoo: $commit_id" >> $testroot/stdout.expected echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected + echo "refs/remotes/origin/HEAD: refs/heads/master" \ + >> $testroot/stdout.expected echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected cmp -s $testroot/stdout $testroot/stdout.expected ret="$?" @@ -294,6 +305,8 @@ function test_ref_list { echo "refs/foo/bar/baz: $commit_id" > $testroot/stdout.expected echo "refs/foo/zoo: $commit_id" >> $testroot/stdout.expected echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected + echo "refs/remotes/origin/HEAD: refs/heads/master" \ + >> $testroot/stdout.expected echo "refs/tags/1.0: $tag_id" >> $testroot/stdout.expected cmp -s $testroot/stdout $testroot/stdout.expected ret="$?"