summaryrefslogtreecommitdiff
path: root/t/t1090-sparse-checkout-scope.sh
diff options
context:
space:
mode:
authorBen Peart <Ben.Peart@microsoft.com>2018-08-16 18:27:11 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-08-16 18:54:57 (GMT)
commitfa655d8411cc2d7ffcf898e53a1493c737d7de68 (patch)
tree80a88418d738aa4701155f7c3cf3cc38b6836052 /t/t1090-sparse-checkout-scope.sh
parentffc6fa0e396238de3a30623912980263b4f283ab (diff)
downloadgit-fa655d8411cc2d7ffcf898e53a1493c737d7de68.zip
git-fa655d8411cc2d7ffcf898e53a1493c737d7de68.tar.gz
git-fa655d8411cc2d7ffcf898e53a1493c737d7de68.tar.bz2
checkout: optimize "git checkout -b <new_branch>"
Skip merging the commit, updating the index and working directory if and only if we are creating a new branch via "git checkout -b <new_branch>." Any other checkout options will still go through the former code path. If sparse_checkout is on, require the user to manually opt in to this optimzed behavior by setting the config setting checkout.optimizeNewBranch to true as we will no longer update the skip-worktree bit in the index, nor add/remove files in the working directory to reflect the current sparse checkout settings. For comparison, running "git checkout -b <new_branch>" on a large repo takes: 14.6 seconds - without this patch 0.3 seconds - with this patch Signed-off-by: Ben Peart <Ben.Peart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1090-sparse-checkout-scope.sh')
-rwxr-xr-xt/t1090-sparse-checkout-scope.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/t/t1090-sparse-checkout-scope.sh b/t/t1090-sparse-checkout-scope.sh
index 1f61eb3..25d7c70 100755
--- a/t/t1090-sparse-checkout-scope.sh
+++ b/t/t1090-sparse-checkout-scope.sh
@@ -31,6 +31,20 @@ test_expect_success 'perform sparse checkout of master' '
test_path_is_file c
'
+test_expect_success 'checkout -b checkout.optimizeNewBranch interaction' '
+ cp .git/info/sparse-checkout .git/info/sparse-checkout.bak &&
+ test_when_finished "
+ mv -f .git/info/sparse-checkout.bak .git/info/sparse-checkout
+ git checkout master
+ " &&
+ echo "/b" >>.git/info/sparse-checkout &&
+ test "$(git ls-files -t b)" = "S b" &&
+ git -c checkout.optimizeNewBranch=true checkout -b fast &&
+ test "$(git ls-files -t b)" = "S b" &&
+ git checkout -b slow &&
+ test "$(git ls-files -t b)" = "H b"
+'
+
test_expect_success 'merge feature branch into sparse checkout of master' '
git merge feature &&
test_path_is_file a &&