Browse Source
Hoist the remainder of "scalar" out of contrib/ to the main part of the codebase. * vd/scalar-to-main: Documentation/technical: include Scalar technical doc t/perf: add 'GIT_PERF_USE_SCALAR' run option t/perf: add Scalar performance tests scalar-clone: add test coverage scalar: add to 'git help -a' command list scalar: implement the `help` subcommand git help: special-case `scalar` scalar: include in standard Git build & installation scalar: fix command documentation section headermaint

19 changed files with 264 additions and 207 deletions
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
/*.exe |
||||
/scalar |
@ -1,35 +0,0 @@
@@ -1,35 +0,0 @@
|
||||
# The default target of this Makefile is... |
||||
all:: |
||||
|
||||
# Import tree-wide shared Makefile behavior and libraries |
||||
include ../../shared.mak |
||||
|
||||
include ../../config.mak.uname |
||||
-include ../../config.mak.autogen |
||||
-include ../../config.mak |
||||
|
||||
TARGETS = scalar$(X) scalar.o |
||||
GITLIBS = ../../common-main.o ../../libgit.a ../../xdiff/lib.a |
||||
|
||||
all:: scalar$(X) ../../bin-wrappers/scalar |
||||
|
||||
$(GITLIBS): |
||||
$(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) $(subst ../../,,$@) |
||||
|
||||
$(TARGETS): $(GITLIBS) scalar.c |
||||
$(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) $(patsubst %,contrib/scalar/%,$@) |
||||
|
||||
clean: |
||||
$(RM) $(TARGETS) ../../bin-wrappers/scalar |
||||
|
||||
../../bin-wrappers/scalar: ../../wrap-for-bin.sh Makefile |
||||
@mkdir -p ../../bin-wrappers |
||||
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ |
||||
-e 's|@@BUILD_DIR@@|$(shell cd ../.. && pwd)|' \ |
||||
-e 's|@@PROG@@|contrib/scalar/scalar$(X)|' < $< > $@ && \ |
||||
chmod +x $@ |
||||
|
||||
test: all |
||||
$(MAKE) -C t |
||||
|
||||
.PHONY: $(GITLIBS) all clean test FORCE |
@ -1,81 +0,0 @@
@@ -1,81 +0,0 @@
|
||||
# Import tree-wide shared Makefile behavior and libraries |
||||
include ../../../shared.mak |
||||
|
||||
# Run scalar tests |
||||
# |
||||
# Copyright (c) 2005,2021 Junio C Hamano, Johannes Schindelin |
||||
# |
||||
|
||||
-include ../../../config.mak.autogen |
||||
-include ../../../config.mak |
||||
|
||||
SHELL_PATH ?= $(SHELL) |
||||
PERL_PATH ?= /usr/bin/perl |
||||
RM ?= rm -f |
||||
PROVE ?= prove |
||||
DEFAULT_TEST_TARGET ?= test |
||||
TEST_LINT ?= test-lint |
||||
|
||||
ifdef TEST_OUTPUT_DIRECTORY |
||||
TEST_RESULTS_DIRECTORY = $(TEST_OUTPUT_DIRECTORY)/test-results |
||||
else |
||||
TEST_RESULTS_DIRECTORY = ../../../t/test-results |
||||
endif |
||||
|
||||
# Shell quote; |
||||
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) |
||||
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH)) |
||||
TEST_RESULTS_DIRECTORY_SQ = $(subst ','\'',$(TEST_RESULTS_DIRECTORY)) |
||||
|
||||
T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) |
||||
|
||||
all: $(DEFAULT_TEST_TARGET) |
||||
|
||||
test: $(TEST_LINT) |
||||
$(MAKE) aggregate-results-and-cleanup |
||||
|
||||
prove: $(TEST_LINT) |
||||
@echo "*** prove ***"; GIT_CONFIG=.git/config $(PROVE) --exec '$(SHELL_PATH_SQ)' $(GIT_PROVE_OPTS) $(T) :: $(GIT_TEST_OPTS) |
||||
$(MAKE) clean-except-prove-cache |
||||
|
||||
$(T): |
||||
@echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS) |
||||
|
||||
clean-except-prove-cache: |
||||
$(RM) -r 'trash directory'.* |
||||
$(RM) -r valgrind/bin |
||||
|
||||
clean: clean-except-prove-cache |
||||
$(RM) .prove |
||||
|
||||
test-lint: test-lint-duplicates test-lint-executable test-lint-shell-syntax |
||||
|
||||
test-lint-duplicates: |
||||
@dups=`echo $(T) | tr ' ' '\n' | sed 's/-.*//' | sort | uniq -d` && \ |
||||
test -z "$$dups" || { \ |
||||
echo >&2 "duplicate test numbers:" $$dups; exit 1; } |
||||
|
||||
test-lint-executable: |
||||
@bad=`for i in $(T); do test -x "$$i" || echo $$i; done` && \ |
||||
test -z "$$bad" || { \ |
||||
echo >&2 "non-executable tests:" $$bad; exit 1; } |
||||
|
||||
test-lint-shell-syntax: |
||||
@'$(PERL_PATH_SQ)' ../../../t/check-non-portable-shell.pl $(T) |
||||
|
||||
aggregate-results-and-cleanup: $(T) |
||||
$(MAKE) aggregate-results |
||||
$(MAKE) clean |
||||
|
||||
aggregate-results: |
||||
for f in '$(TEST_RESULTS_DIRECTORY_SQ)'/t*-*.counts; do \ |
||||
echo "$$f"; \ |
||||
done | '$(SHELL_PATH_SQ)' ../../../t/aggregate-results.sh |
||||
|
||||
valgrind: |
||||
$(MAKE) GIT_TEST_OPTS="$(GIT_TEST_OPTS) --valgrind" |
||||
|
||||
test-results: |
||||
mkdir -p test-results |
||||
|
||||
.PHONY: $(T) aggregate-results clean valgrind |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh |
||||
|
||||
test_description='test scalar performance' |
||||
. ./perf-lib.sh |
||||
|
||||
test_perf_large_repo "$TRASH_DIRECTORY/to-clone" |
||||
|
||||
test_expect_success 'enable server-side partial clone' ' |
||||
git -C to-clone config uploadpack.allowFilter true && |
||||
git -C to-clone config uploadpack.allowAnySHA1InWant true |
||||
' |
||||
|
||||
test_perf 'scalar clone' ' |
||||
rm -rf scalar-clone && |
||||
scalar clone "file://$(pwd)/to-clone" scalar-clone |
||||
' |
||||
|
||||
test_perf 'git clone' ' |
||||
rm -rf git-clone && |
||||
git clone "file://$(pwd)/to-clone" git-clone |
||||
' |
||||
|
||||
test_compare_perf () { |
||||
command=$1 |
||||
shift |
||||
args=$* |
||||
test_perf "$command $args (scalar)" " |
||||
$command -C scalar-clone/src $args |
||||
" |
||||
|
||||
test_perf "$command $args (non-scalar)" " |
||||
$command -C git-clone $args |
||||
" |
||||
} |
||||
|
||||
test_compare_perf git status |
||||
test_compare_perf test_commit --append --no-tag A |
||||
|
||||
test_done |
@ -0,0 +1,151 @@
@@ -0,0 +1,151 @@
|
||||
#!/bin/sh |
||||
|
||||
test_description='test the `scalar clone` subcommand' |
||||
|
||||
. ./test-lib.sh |
||||
|
||||
GIT_TEST_MAINT_SCHEDULER="crontab:test-tool crontab cron.txt,launchctl:true,schtasks:true" |
||||
export GIT_TEST_MAINT_SCHEDULER |
||||
|
||||
test_expect_success 'set up repository to clone' ' |
||||
rm -rf .git && |
||||
git init to-clone && |
||||
( |
||||
cd to-clone && |
||||
git branch -m base && |
||||
|
||||
test_commit first && |
||||
test_commit second && |
||||
test_commit third && |
||||
|
||||
git switch -c parallel first && |
||||
mkdir -p 1/2 && |
||||
test_commit 1/2/3 && |
||||
|
||||
git switch base && |
||||
|
||||
# By default, permit |
||||
git config uploadpack.allowfilter true && |
||||
git config uploadpack.allowanysha1inwant true |
||||
) |
||||
' |
||||
|
||||
cleanup_clone () { |
||||
rm -rf "$1" |
||||
} |
||||
|
||||
test_expect_success 'creates content in enlistment root' ' |
||||
enlistment=cloned && |
||||
|
||||
scalar clone "file://$(pwd)/to-clone" $enlistment && |
||||
ls -A $enlistment >enlistment-root && |
||||
test_line_count = 1 enlistment-root && |
||||
test_path_is_dir $enlistment/src && |
||||
test_path_is_dir $enlistment/src/.git && |
||||
|
||||
cleanup_clone $enlistment |
||||
' |
||||
|
||||
test_expect_success 'with spaces' ' |
||||
enlistment="cloned with space" && |
||||
|
||||
scalar clone "file://$(pwd)/to-clone" "$enlistment" && |
||||
test_path_is_dir "$enlistment" && |
||||
test_path_is_dir "$enlistment/src" && |
||||
test_path_is_dir "$enlistment/src/.git" && |
||||
|
||||
cleanup_clone "$enlistment" |
||||
' |
||||
|
||||
test_expect_success 'partial clone if supported by server' ' |
||||
enlistment=partial-clone && |
||||
|
||||
scalar clone "file://$(pwd)/to-clone" $enlistment && |
||||
|
||||
( |
||||
cd $enlistment/src && |
||||
|
||||
# Two promisor packs: one for refs, the other for blobs |
||||
ls .git/objects/pack/pack-*.promisor >promisorlist && |
||||
test_line_count = 2 promisorlist |
||||
) && |
||||
|
||||
cleanup_clone $enlistment |
||||
' |
||||
|
||||
test_expect_success 'fall back on full clone if partial unsupported' ' |
||||
enlistment=no-partial-support && |
||||
|
||||
test_config -C to-clone uploadpack.allowfilter false && |
||||
test_config -C to-clone uploadpack.allowanysha1inwant false && |
||||
|
||||
scalar clone "file://$(pwd)/to-clone" $enlistment 2>err && |
||||
grep "filtering not recognized by server, ignoring" err && |
||||
|
||||
( |
||||
cd $enlistment/src && |
||||
|
||||
# Still get a refs promisor file, but none for blobs |
||||
ls .git/objects/pack/pack-*.promisor >promisorlist && |
||||
test_line_count = 1 promisorlist |
||||
) && |
||||
|
||||
cleanup_clone $enlistment |
||||
' |
||||
|
||||
test_expect_success 'initializes sparse-checkout by default' ' |
||||
enlistment=sparse && |
||||
|
||||
scalar clone "file://$(pwd)/to-clone" $enlistment && |
||||
( |
||||
cd $enlistment/src && |
||||
test_cmp_config true core.sparseCheckout && |
||||
test_cmp_config true core.sparseCheckoutCone |
||||
) && |
||||
|
||||
cleanup_clone $enlistment |
||||
' |
||||
|
||||
test_expect_success '--full-clone does not create sparse-checkout' ' |
||||
enlistment=full-clone && |
||||
|
||||
scalar clone --full-clone "file://$(pwd)/to-clone" $enlistment && |
||||
( |
||||
cd $enlistment/src && |
||||
test_cmp_config "" --default "" core.sparseCheckout && |
||||
test_cmp_config "" --default "" core.sparseCheckoutCone |
||||
) && |
||||
|
||||
cleanup_clone $enlistment |
||||
' |
||||
|
||||
test_expect_success '--single-branch clones HEAD only' ' |
||||
enlistment=single-branch && |
||||
|
||||
scalar clone --single-branch "file://$(pwd)/to-clone" $enlistment && |
||||
( |
||||
cd $enlistment/src && |
||||
git for-each-ref refs/remotes/origin >out && |
||||
test_line_count = 1 out && |
||||
grep "refs/remotes/origin/base" out |
||||
) && |
||||
|
||||
cleanup_clone $enlistment |
||||
' |
||||
|
||||
test_expect_success '--no-single-branch clones all branches' ' |
||||
enlistment=no-single-branch && |
||||
|
||||
scalar clone --no-single-branch "file://$(pwd)/to-clone" $enlistment && |
||||
( |
||||
cd $enlistment/src && |
||||
git for-each-ref refs/remotes/origin >out && |
||||
test_line_count = 2 out && |
||||
grep "refs/remotes/origin/base" out && |
||||
grep "refs/remotes/origin/parallel" out |
||||
) && |
||||
|
||||
cleanup_clone $enlistment |
||||
' |
||||
|
||||
test_done |
Loading…
Reference in new issue