]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t5510-fetch.sh
Merge branch 'gc/branch-recurse-submodules-fix'
[thirdparty/git.git] / t / t5510-fetch.sh
index ef0da0a63b5c2a970d63aece5e95e3efd95d2023..6f38a69fbb2c2d4fc0f7479971e880be211bb186 100755 (executable)
@@ -273,7 +273,7 @@ test_expect_success 'fetch --atomic executes a single reference transaction only
        EOF
 
        rm -f atomic/actual &&
-       write_script atomic/.git/hooks/reference-transaction <<-\EOF &&
+       test_hook -C atomic reference-transaction <<-\EOF &&
                ( echo "$*" && cat ) >>actual
        EOF
 
@@ -306,7 +306,7 @@ test_expect_success 'fetch --atomic aborts all reference updates if hook aborts'
        EOF
 
        rm -f atomic/actual &&
-       write_script atomic/.git/hooks/reference-transaction <<-\EOF &&
+       test_hook -C atomic/.git reference-transaction <<-\EOF &&
                ( echo "$*" && cat ) >>actual
                exit 1
        EOF
@@ -334,7 +334,7 @@ test_expect_success 'fetch --atomic --append appends to FETCH_HEAD' '
        test_line_count = 2 atomic/.git/FETCH_HEAD &&
        cp atomic/.git/FETCH_HEAD expected &&
 
-       write_script atomic/.git/hooks/reference-transaction <<-\EOF &&
+       test_hook -C atomic reference-transaction <<-\EOF &&
                exit 1
        EOF
 
@@ -343,6 +343,35 @@ test_expect_success 'fetch --atomic --append appends to FETCH_HEAD' '
        test_cmp expected atomic/.git/FETCH_HEAD
 '
 
+test_expect_success 'fetch --atomic --prune executes a single reference transaction only' '
+       test_when_finished "rm -rf \"$D\"/atomic" &&
+
+       cd "$D" &&
+       git branch scheduled-for-deletion &&
+       git clone . atomic &&
+       git branch -D scheduled-for-deletion &&
+       git branch new-branch &&
+       head_oid=$(git rev-parse HEAD) &&
+
+       # Fetching with the `--atomic` flag should update all references in a
+       # single transaction.
+       cat >expected <<-EOF &&
+               prepared
+               $ZERO_OID $ZERO_OID refs/remotes/origin/scheduled-for-deletion
+               $ZERO_OID $head_oid refs/remotes/origin/new-branch
+               committed
+               $ZERO_OID $ZERO_OID refs/remotes/origin/scheduled-for-deletion
+               $ZERO_OID $head_oid refs/remotes/origin/new-branch
+       EOF
+
+       test_hook -C atomic reference-transaction <<-\EOF &&
+               ( echo "$*" && cat ) >>actual
+       EOF
+
+       git -C atomic fetch --atomic --prune origin &&
+       test_cmp expected atomic/actual
+'
+
 test_expect_success '--refmap="" ignores configured refspec' '
        cd "$TRASH_DIRECTORY" &&
        git clone "$D" remote-refs &&