summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cfbe22f)
raw | patch | inline | side by side (parent: cfbe22f)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Fri, 6 Aug 2010 03:39:22 +0000 (22:39 -0500) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 6 Aug 2010 17:01:45 +0000 (10:01 -0700) |
check-ref-format --branch requires access to the repository
to resolve refs like @{-1}.
Noticed by Nguyễn Thái Ngọc Duy.
Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
to resolve refs like @{-1}.
Noticed by Nguyễn Thái Ngọc Duy.
Cc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/check-ref-format.c | patch | blob | history | |
t/t1402-check-ref-format.sh | patch | blob | history |
index 8707ee935a0ef8c6b6859c0f078c6d51b2269af2..ae3f28115a7a4d65d8bb6f284cd1ececa4f9c2ef 100644 (file)
static int check_ref_format_branch(const char *arg)
{
struct strbuf sb = STRBUF_INIT;
+ int nongit;
+ setup_git_directory_gently(&nongit);
if (strbuf_check_branch_ref(&sb, arg))
die("'%s' is not a valid branch name", arg);
printf("%s\n", sb.buf + 11);
index eb45afb018f6e3849204b44cce06ae1a4e2e29aa..782e75d00091ebf1fda93ca5dc8e532289a15638 100755 (executable)
refname2=$(git check-ref-format --branch @{-2}) &&
test "$refname2" = master'
+test_expect_success 'check-ref-format --branch from subdir' '
+ mkdir subdir &&
+
+ T=$(git write-tree) &&
+ sha1=$(echo A | git commit-tree $T) &&
+ git update-ref refs/heads/master $sha1 &&
+ git update-ref refs/remotes/origin/master $sha1
+ git checkout master &&
+ git checkout origin/master &&
+ git checkout master &&
+ refname=$(
+ cd subdir &&
+ git check-ref-format --branch @{-1}
+ ) &&
+ test "$refname" = "$sha1"
+'
+
valid_ref_normalized() {
test_expect_success "ref name '$1' simplifies to '$2'" "
refname=\$(git check-ref-format --print '$1') &&