Merge branch 'jk/faster-name-conflicts'
authorJunio C Hamano <gitster@pobox.com>
Fri, 26 Sep 2014 21:39:43 +0000 (14:39 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Sep 2014 21:39:43 +0000 (14:39 -0700)
Optimize the check to see if a ref $F can be created by making sure
no existing ref has $F/ as its prefix, which especially matters in
a repository with a large number of existing refs.

* jk/faster-name-conflicts:
refs: speed up is_refname_available

1  2 
refs.c
t/t3210-pack-refs.sh
diff --cc refs.c
Simple merge
index 3a017bf437395526cf54403d4ea1db36a3cff0b3,3d5cb4c089f110a18d60c5ff8e5357055503d4ad..aa9eb3a3e5ef0637615c6d958a29dbd9bbbf0895
@@@ -151,11 -153,31 +153,38 @@@ test_expect_success 'delete ref while a
        test_cmp /dev/null result
  '
  
 +test_expect_success 'pack ref directly below refs/' '
 +      git update-ref refs/top HEAD &&
 +      git pack-refs --all --prune &&
 +      grep refs/top .git/packed-refs &&
 +      test_path_is_missing .git/refs/top
 +'
 +
+ test_expect_success 'disable reflogs' '
+       git config core.logallrefupdates false &&
+       rm -rf .git/logs
+ '
+ test_expect_success 'create packed foo/bar/baz branch' '
+       git branch foo/bar/baz &&
+       git pack-refs --all --prune &&
+       test_path_is_missing .git/refs/heads/foo/bar/baz &&
+       test_path_is_missing .git/logs/refs/heads/foo/bar/baz
+ '
+ test_expect_success 'notice d/f conflict with existing directory' '
+       test_must_fail git branch foo &&
+       test_must_fail git branch foo/bar
+ '
+ test_expect_success 'existing directory reports concrete ref' '
+       test_must_fail git branch foo 2>stderr &&
+       grep refs/heads/foo/bar/baz stderr
+ '
+ test_expect_success 'notice d/f conflict with existing ref' '
+       test_must_fail git branch foo/bar/baz/extra &&
+       test_must_fail git branch foo/bar/baz/lots/of/extra/components
+ '
  test_done