Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2022-08-01 21:15:19 +0300
committerJunio C Hamano <gitster@pobox.com>2022-08-01 22:17:13 +0300
commit04ede97211c132f4d71c96c61f5124cbb3ebdc77 (patch)
treedf7ddbab0cc91d871ec98afb2b24aef456fd5bd5 /t/t4202-log.sh
parent00d12607a27e387ad78b5957afa05e89c87e83a5 (diff)
symbolic-ref: refuse to set syntactically invalid target
You can feed absolute garbage to symbolic-ref as a target like: git symbolic-ref HEAD refs/heads/foo..bar While this doesn't technically break the repo entirely (our "is it a git directory" detector looks only for "refs/" at the start), we would never resolve such a ref, as the ".." is invalid within a refname. Let's flag these as invalid at creation time to help the caller realize that what they're asking for is bogus. A few notes: - We use REFNAME_ALLOW_ONELEVEL here, which lets: git update-ref refs/heads/foo FETCH_HEAD continue to work. It's unclear whether anybody wants to do something so odd, but it does work now, so this is erring on the conservative side. There's a test to make sure we didn't accidentally break this, but don't take that test as an endorsement that it's a good idea, or something we might not change in the future. - The test in t4202-log.sh checks how we handle such an invalid ref on the reading side, so it has to be updated to touch the HEAD file directly. - We need to keep our HEAD-specific check for "does it start with refs/". The ALLOW_ONELEVEL flag means we won't be enforcing that for other refs, but HEAD is special here because of the checks in validate_headref(). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4202-log.sh')
-rwxr-xr-xt/t4202-log.sh4
1 files changed, 2 insertions, 2 deletions
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 6e66352558..f0aaa1fa02 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -2112,9 +2112,9 @@ test_expect_success REFFILES 'log diagnoses bogus HEAD hash' '
test_i18ngrep broken stderr
'
-test_expect_success 'log diagnoses bogus HEAD symref' '
+test_expect_success REFFILES 'log diagnoses bogus HEAD symref' '
git init empty &&
- git --git-dir empty/.git symbolic-ref HEAD refs/heads/invalid.lock &&
+ echo "ref: refs/heads/invalid.lock" > empty/.git/HEAD &&
test_must_fail git -C empty log 2>stderr &&
test_i18ngrep broken stderr &&
test_must_fail git -C empty log --default totally-bogus 2>stderr &&