commit 7fa81f883018bdf9a7067622c62c75734f846454 from: Stefan Sperling date: Fri Feb 21 01:06:03 2020 UTC allow 'got ref' to manipulate refs which do not have a slash in their name commit - 6962eb72119c221eca83da6b7b3bd76f730d6898 commit + 7fa81f883018bdf9a7067622c62c75734f846454 blob - 398dfd52fa18a9ca17559990b511e9b995dceffe blob + 135fe2d60c175b7dccea9c7781d3876385dddfa7 --- lib/reference.c +++ lib/reference.c @@ -245,7 +245,7 @@ get_refs_dir_path(struct got_repository *repo, const c static int is_valid_ref_name(const char *name) { - const char *s, *slash, *seg; + const char *s, *seg; const char forbidden[] = { ' ', '~', '^', ':', '?', '*', '[' , '\\' }; const char *forbidden_seq[] = { "//", "..", "@{" }; const char *lfs = GOT_LOCKFILE_SUFFIX; @@ -253,10 +253,6 @@ is_valid_ref_name(const char *name) int i; if (name[0] == '@' && name[1] == '\0') - return 0; - - slash = strchr(name, '/'); - if (slash == NULL) return 0; s = name; blob - 4b2f3a902b8496a2eb71b6e31a24779e249cd2c1 (mode 755) blob + 50b3132f130ff87c2a04152bb8ed0a243a817079 (mode 744) --- regress/cmdline/ref.sh +++ regress/cmdline/ref.sh @@ -106,8 +106,34 @@ function test_ref_create { return 1 fi + # Change HEAD + got ref -r $testroot/repo -s HEAD refs/heads/newref + ret="$?" + if [ "$ret" != "0" ]; then + echo "got ref command failed unexpectedly" + test_done "$testroot" "$ret" + return 1 + fi + + # Ensure that Git recognizes the ref Got has created + (cd $testroot/repo && git checkout -q HEAD) + ret="$?" + if [ "$ret" != "0" ]; then + echo "git checkout command failed unexpectedly" + test_done "$testroot" "$ret" + return 1 + fi + + # Ensure Got recognizes the new ref + (cd $testroot/wt && got update -b HEAD >/dev/null) + ret="$?" + if [ "$ret" != "0" ]; then + echo "got checkout command failed unexpectedly" + test_done "$testroot" "$ret" + return 1 + fi got ref -r $testroot/repo -l > $testroot/stdout - echo "HEAD: refs/heads/symbolicref" > $testroot/stdout.expected + echo "HEAD: refs/heads/newref" > $testroot/stdout.expected echo -n "refs/got/worktree/base-" >> $testroot/stdout.expected cat $testroot/wt/.got/uuid | tr -d '\n' >> $testroot/stdout.expected echo ": $commit_id" >> $testroot/stdout.expected