userformat_find_requirements(): find requirement for the correct format
[gitweb.git] / t / t5515-fetch-merge-logic.sh
index 31c108161781165d5e32f08b95089086627eda64..dbb927dec8ea9f40e8e106f416c276f1b6a07868 100755 (executable)
@@ -129,10 +129,11 @@ do
        '' | '#'*) continue ;;
        esac
        test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
-       cnt=`expr $test_count + 1`
-       pfx=`printf "%04d" $cnt`
-       expect="../../t5515/fetch.$test"
-       actual="$pfx-fetch.$test"
+       pfx=`printf "%04d" $test_count`
+       expect_f="$TEST_DIRECTORY/t5515/fetch.$test"
+       actual_f="$pfx-fetch.$test"
+       expect_r="$TEST_DIRECTORY/t5515/refs.$test"
+       actual_r="$pfx-refs.$test"
 
        test_expect_success "$cmd" '
                {
@@ -140,19 +141,32 @@ do
                        set x $cmd; shift
                        git symbolic-ref HEAD refs/heads/$1 ; shift
                        rm -f .git/FETCH_HEAD
-                       rm -f .git/refs/heads/*
-                       rm -f .git/refs/remotes/rem/*
-                       rm -f .git/refs/tags/*
+                       git for-each-ref \
+                               refs/heads refs/remotes/rem refs/tags |
+                       while read val type refname
+                       do
+                               git update-ref -d "$refname" "$val"
+                       done
                        git fetch "$@" >/dev/null
                        cat .git/FETCH_HEAD
-               } >"$actual" &&
-               if test -f "$expect"
+               } >"$actual_f" &&
+               git show-ref >"$actual_r" &&
+               if test -f "$expect_f"
                then
-                       git diff -u "$expect" "$actual" &&
-                       rm -f "$actual"
+                       test_cmp "$expect_f" "$actual_f" &&
+                       rm -f "$actual_f"
                else
                        # this is to help developing new tests.
-                       cp "$actual" "$expect"
+                       cp "$actual_f" "$expect_f"
+                       false
+               fi &&
+               if test -f "$expect_r"
+               then
+                       test_cmp "$expect_r" "$actual_r" &&
+                       rm -f "$actual_r"
+               else
+                       # this is to help developing new tests.
+                       cp "$actual_r" "$expect_r"
                        false
                fi
        '