update-ref: test handling large transactions properly

Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stefan Beller committed Apr 14, 2015 at 15:25 UTC d415ad022d8b94adaf67bac2b86180847cc259ec
1 file changed +28
t/t1400-update-ref.sh
+28
@@ -1065,4 +1065,32 @@ test_expect_success 'stdin -z delete refs works with packed and loose refs' '
1065 test_must_fail git rev-parse --verify -q $c
1066 '
1067
1068 +run_with_limited_open_files () {
1069 + (ulimit -n 32 && "$@")
1070 +}
1071 +
1072 +test_lazy_prereq ULIMIT_FILE_DESCRIPTORS 'run_with_limited_open_files true'
1073 +
1074 +test_expect_failure ULIMIT_FILE_DESCRIPTORS 'large transaction creating branches does not burst open file limit' '
1075 +(
1076 + for i in $(test_seq 33)
1077 + do
1078 + echo "create refs/heads/$i HEAD"
1079 + done >large_input &&
1080 + run_with_limited_open_files git update-ref --stdin <large_input &&
1081 + git rev-parse --verify -q refs/heads/33
1082 +)
1083 +'
1084 +
1085 +test_expect_failure ULIMIT_FILE_DESCRIPTORS 'large transaction deleting branches does not burst open file limit' '
1086 +(
1087 + for i in $(test_seq 33)
1088 + do
1089 + echo "delete refs/heads/$i HEAD"
1090 + done >large_input &&
1091 + run_with_limited_open_files git update-ref --stdin <large_input &&
1092 + test_must_fail git rev-parse --verify -q refs/heads/33
1093 +)
1094 +'
1095 +
1096 test_done