diff --git a/.gitignore b/.gitignore index 44c74402c8c6de..2374f77a1aae58 100644 --- a/.gitignore +++ b/.gitignore @@ -135,7 +135,6 @@ /git-remote-ftps /git-remote-fd /git-remote-ext -/git-remote-testgit /git-remote-testpy /git-remote-testsvn /git-repack diff --git a/Documentation/.gitignore b/Documentation/.gitignore index bf2bf271b56788..9022d4835545cb 100644 --- a/Documentation/.gitignore +++ b/Documentation/.gitignore @@ -14,3 +14,4 @@ manpage-base-url.xsl SubmittingPatches.txt tmp-doc-diff/ GIT-ASCIIDOCFLAGS +/GIT-EXCLUDED-PROGRAMS diff --git a/Documentation/Makefile b/Documentation/Makefile index 6d738f831ebaf3..dbf5a0f2762fba 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -7,7 +7,10 @@ ARTICLES = SP_ARTICLES = OBSOLETE_HTML = +-include GIT-EXCLUDED-PROGRAMS + MAN1_TXT += $(filter-out \ + $(patsubst %,%.txt,$(EXCLUDED_PROGRAMS)) \ $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \ $(wildcard git-*.txt)) MAN1_TXT += git.txt diff --git a/Makefile b/Makefile index 9f1b6e8926682c..5143cab9bdb2b3 100644 --- a/Makefile +++ b/Makefile @@ -592,6 +592,7 @@ FUZZ_PROGRAMS = LIB_OBJS = PROGRAM_OBJS = PROGRAMS = +EXCLUDED_PROGRAMS = SCRIPT_PERL = SCRIPT_PYTHON = SCRIPT_SH = @@ -614,7 +615,6 @@ SCRIPT_SH += git-merge-resolve.sh SCRIPT_SH += git-mergetool.sh SCRIPT_SH += git-quiltimport.sh SCRIPT_SH += git-legacy-stash.sh -SCRIPT_SH += git-remote-testgit.sh SCRIPT_SH += git-request-pull.sh SCRIPT_SH += git-submodule.sh SCRIPT_SH += git-web--browse.sh @@ -637,17 +637,11 @@ SCRIPT_PERL += git-svn.perl SCRIPT_PYTHON += git-p4.py -NO_INSTALL += git-remote-testgit - # Generated files for scripts SCRIPT_SH_GEN = $(patsubst %.sh,%,$(SCRIPT_SH)) SCRIPT_PERL_GEN = $(patsubst %.perl,%,$(SCRIPT_PERL)) SCRIPT_PYTHON_GEN = $(patsubst %.py,%,$(SCRIPT_PYTHON)) -SCRIPT_SH_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_SH_GEN)) -SCRIPT_PERL_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_PERL_GEN)) -SCRIPT_PYTHON_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_PYTHON_GEN)) - # Individual rules to allow e.g. # "make -C ../.. SCRIPT_PERL=contrib/foo/bar.perl build-perl-script" # from subdirectories like contrib/*/ @@ -657,11 +651,11 @@ build-sh-script: $(SCRIPT_SH_GEN) build-python-script: $(SCRIPT_PYTHON_GEN) .PHONY: install-perl-script install-sh-script install-python-script -install-sh-script: $(SCRIPT_SH_INS) +install-sh-script: $(SCRIPT_SH_GEN) $(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' -install-perl-script: $(SCRIPT_PERL_INS) +install-perl-script: $(SCRIPT_PERL_GEN) $(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' -install-python-script: $(SCRIPT_PYTHON_INS) +install-python-script: $(SCRIPT_PYTHON_GEN) $(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' .PHONY: clean-perl-script clean-sh-script clean-python-script @@ -672,9 +666,9 @@ clean-perl-script: clean-python-script: $(RM) $(SCRIPT_PYTHON_GEN) -SCRIPTS = $(SCRIPT_SH_INS) \ - $(SCRIPT_PERL_INS) \ - $(SCRIPT_PYTHON_INS) \ +SCRIPTS = $(SCRIPT_SH_GEN) \ + $(SCRIPT_PERL_GEN) \ + $(SCRIPT_PYTHON_GEN) \ git-instaweb ETAGS_TARGET = TAGS @@ -744,6 +738,7 @@ TEST_BUILTINS_OBJS += test-repository.o TEST_BUILTINS_OBJS += test-revision-walking.o TEST_BUILTINS_OBJS += test-run-command.o TEST_BUILTINS_OBJS += test-scrap-cache-tree.o +TEST_BUILTINS_OBJS += test-serve-v2.o TEST_BUILTINS_OBJS += test-sha1.o TEST_BUILTINS_OBJS += test-sha1-array.o TEST_BUILTINS_OBJS += test-sha256.o @@ -1125,7 +1120,6 @@ BUILTIN_OBJS += builtin/rev-parse.o BUILTIN_OBJS += builtin/revert.o BUILTIN_OBJS += builtin/rm.o BUILTIN_OBJS += builtin/send-pack.o -BUILTIN_OBJS += builtin/serve.o BUILTIN_OBJS += builtin/shortlog.o BUILTIN_OBJS += builtin/show-branch.o BUILTIN_OBJS += builtin/show-index.o @@ -1342,6 +1336,7 @@ ifdef NO_CURL REMOTE_CURL_PRIMARY = REMOTE_CURL_ALIASES = REMOTE_CURL_NAMES = + EXCLUDED_PROGRAMS += git-http-fetch git-http-push else ifdef CURLDIR # Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case. @@ -1366,7 +1361,11 @@ endif ifeq "$(curl_check)" "070908" ifndef NO_EXPAT PROGRAM_OBJS += http-push.o + else + EXCLUDED_PROGRAMS += git-http-push endif + else + EXCLUDED_PROGRAMS += git-http-push endif curl_check := $(shell (echo 072200; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p) ifeq "$(curl_check)" "072200" @@ -1614,6 +1613,7 @@ ifdef NO_INET_PTON endif ifdef NO_UNIX_SOCKETS BASIC_CFLAGS += -DNO_UNIX_SOCKETS + EXCLUDED_PROGRAMS += git-credential-cache git-credential-cache--daemon else LIB_OBJS += unix-socket.o PROGRAM_OBJS += credential-cache.o @@ -2133,7 +2133,9 @@ $(BUILT_INS): git$X command-list.h: generate-cmdlist.sh command-list.txt command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt - $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh command-list.txt >$@+ && mv $@+ $@ + $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ + $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ + command-list.txt >$@+ && mv $@+ $@ SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\ $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\ @@ -2466,6 +2468,14 @@ $(VCSSVN_LIB): $(VCSSVN_OBJS) export DEFAULT_EDITOR DEFAULT_PAGER +Documentation/GIT-EXCLUDED-PROGRAMS: FORCE + @EXCLUDED='EXCLUDED_PROGRAMS := $(EXCLUDED_PROGRAMS)'; \ + if test x"$$EXCLUDED" != \ + x"`cat Documentation/GIT-EXCLUDED-PROGRAMS 2>/dev/null`" ; then \ + echo >&2 " * new documentation flags"; \ + echo "$$EXCLUDED" >Documentation/GIT-EXCLUDED-PROGRAMS; \ + fi + .PHONY: doc man man-perl html info pdf doc: man-perl $(MAKE) -C Documentation all @@ -2704,7 +2714,6 @@ endif test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X)) all:: $(TEST_PROGRAMS) $(test_bindir_programs) -all:: $(NO_INSTALL) bin-wrappers/%: wrap-for-bin.sh @mkdir -p bin-wrappers @@ -2991,7 +3000,7 @@ rpm:: artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \ GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \ - $(NO_INSTALL) $(MOFILES) + $(MOFILES) $(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) \ SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)' test -n "$(ARTIFACTS_DIRECTORY)" @@ -3040,7 +3049,7 @@ clean: profile-clean coverage-clean cocciclean $(RM) $(OBJECTS) $(RM) $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB) $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X - $(RM) $(TEST_PROGRAMS) $(NO_INSTALL) + $(RM) $(TEST_PROGRAMS) $(RM) $(FUZZ_PROGRAMS) $(RM) -r bin-wrappers $(dep_dirs) $(RM) -r po/build/ @@ -3049,6 +3058,7 @@ clean: profile-clean coverage-clean cocciclean $(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz $(RM) $(htmldocs).tar.gz $(manpages).tar.gz $(MAKE) -C Documentation/ clean + $(RM) Documentation/GIT-EXCLUDED-PROGRAMS ifndef NO_PERL $(MAKE) -C gitweb clean $(RM) -r perl/build/ @@ -3084,7 +3094,7 @@ check-docs:: git-merge-octopus | git-merge-ours | git-merge-recursive | \ git-merge-resolve | git-merge-subtree | \ git-fsck-objects | git-init-db | \ - git-remote-* | git-stage | \ + git-remote-* | git-stage | git-legacy-* | \ git-?*--?* ) continue ;; \ esac ; \ test -f "Documentation/$$v.txt" || \ @@ -3108,7 +3118,7 @@ check-docs:: -e 's/\.txt//'; \ ) | while read how cmd; \ do \ - case " $(patsubst %$X,%,$(ALL_COMMANDS)) " in \ + case " $(patsubst %$X,%,$(ALL_COMMANDS) $(EXCLUDED_PROGRAMS)) " in \ *" $$cmd "*) ;; \ *) echo "removed but $$how: $$cmd" ;; \ esac; \ diff --git a/builtin.h b/builtin.h index b78ab6e30b26f6..ac552ff0d2ce1c 100644 --- a/builtin.h +++ b/builtin.h @@ -219,7 +219,6 @@ extern int cmd_rev_parse(int argc, const char **argv, const char *prefix); extern int cmd_revert(int argc, const char **argv, const char *prefix); extern int cmd_rm(int argc, const char **argv, const char *prefix); extern int cmd_send_pack(int argc, const char **argv, const char *prefix); -extern int cmd_serve(int argc, const char **argv, const char *prefix); extern int cmd_shortlog(int argc, const char **argv, const char *prefix); extern int cmd_show(int argc, const char **argv, const char *prefix); extern int cmd_show_branch(int argc, const char **argv, const char *prefix); diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh index 709d67405bba65..71158f7d8ba9c7 100755 --- a/generate-cmdlist.sh +++ b/generate-cmdlist.sh @@ -6,7 +6,7 @@ die () { } command_list () { - grep -v '^#' "$1" + eval "grep -ve '^#' $exclude_programs" <"$1" } get_categories () { @@ -93,6 +93,14 @@ EOF EOF } +exclude_programs= +while test "--exclude-program" = "$1" +do + shift + exclude_programs="$exclude_programs -e \"^$1 \"" + shift +done + echo "/* Automatically generated by generate-cmdlist.sh */ struct cmdname_help { const char *name; diff --git a/git.c b/git.c index 50da125c60a317..1bf9c94550d9c2 100644 --- a/git.c +++ b/git.c @@ -570,7 +570,6 @@ static struct cmd_struct commands[] = { { "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE }, { "rm", cmd_rm, RUN_SETUP }, { "send-pack", cmd_send_pack, RUN_SETUP }, - { "serve", cmd_serve, RUN_SETUP }, { "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER }, { "show", cmd_show, RUN_SETUP }, { "show-branch", cmd_show_branch, RUN_SETUP }, diff --git a/builtin/serve.c b/t/helper/test-serve-v2.c similarity index 81% rename from builtin/serve.c rename to t/helper/test-serve-v2.c index d3fd240bb30f2a..aee35e5aef4043 100644 --- a/builtin/serve.c +++ b/t/helper/test-serve-v2.c @@ -1,14 +1,14 @@ +#include "test-tool.h" #include "cache.h" -#include "builtin.h" #include "parse-options.h" #include "serve.h" static char const * const serve_usage[] = { - N_("git serve []"), + N_("test-tool serve-v2 []"), NULL }; -int cmd_serve(int argc, const char **argv, const char *prefix) +int cmd__serve_v2(int argc, const char **argv) { struct serve_options opts = SERVE_OPTIONS_INIT; @@ -19,6 +19,7 @@ int cmd_serve(int argc, const char **argv, const char *prefix) N_("exit immediately after advertising capabilities")), OPT_END() }; + const char *prefix = setup_git_directory(); /* ignore all unknown cmdline switches for now */ argc = parse_options(argc, argv, prefix, options, serve_usage, diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 53c06932c45c17..087a8c0cc9da64 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -1,6 +1,12 @@ #include "git-compat-util.h" #include "test-tool.h" #include "trace2.h" +#include "parse-options.h" + +static const char * const test_tool_usage[] = { + "test-tool [-C ] ...]]", + NULL +}; struct test_cmd { const char *name; @@ -43,6 +49,7 @@ static struct test_cmd cmds[] = { { "revision-walking", cmd__revision_walking }, { "run-command", cmd__run_command }, { "scrap-cache-tree", cmd__scrap_cache_tree }, + { "serve-v2", cmd__serve_v2 }, { "sha1", cmd__sha1 }, { "sha1-array", cmd__sha1_array }, { "sha256", cmd__sha256 }, @@ -75,11 +82,24 @@ static NORETURN void die_usage(void) int cmd_main(int argc, const char **argv) { int i; + const char *working_directory = NULL; + struct option options[] = { + OPT_STRING('C', NULL, &working_directory, "directory", + "change the working directory"), + OPT_END() + }; BUG_exit_code = 99; + argc = parse_options(argc, argv, NULL, options, test_tool_usage, + PARSE_OPT_STOP_AT_NON_OPTION | + PARSE_OPT_KEEP_ARGV0); + if (argc < 2) die_usage(); + if (working_directory && chdir(working_directory) < 0) + die("Could not cd to '%s'", working_directory); + for (i = 0; i < ARRAY_SIZE(cmds); i++) { if (!strcmp(cmds[i].name, argv[1])) { argv++; diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index ffab4d19d701e7..7e703f3038ae43 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -39,6 +39,7 @@ int cmd__repository(int argc, const char **argv); int cmd__revision_walking(int argc, const char **argv); int cmd__run_command(int argc, const char **argv); int cmd__scrap_cache_tree(int argc, const char **argv); +int cmd__serve_v2(int argc, const char **argv); int cmd__sha1(int argc, const char **argv); int cmd__sha1_array(int argc, const char **argv); int cmd__sha256(int argc, const char **argv); diff --git a/t/t5701-git-serve.sh b/t/t5701-git-serve.sh index fe45bf828d09cd..ffb9613885904e 100755 --- a/t/t5701-git-serve.sh +++ b/t/t5701-git-serve.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='test git-serve and server commands' +test_description='test protocol v2 server commands' . ./test-lib.sh @@ -14,7 +14,8 @@ test_expect_success 'test capability advertisement' ' 0000 EOF - GIT_TEST_SIDEBAND_ALL=0 git serve --advertise-capabilities >out && + GIT_TEST_SIDEBAND_ALL=0 test-tool serve-v2 \ + --advertise-capabilities >out && test-tool pkt-line unpack actual && test_cmp expect actual ' @@ -24,11 +25,11 @@ test_expect_success 'stateless-rpc flag does not list capabilities' ' test-tool pkt-line pack >in <<-EOF && 0000 EOF - git serve --stateless-rpc >out out out && + test-tool serve-v2 --stateless-rpc >out && test_must_be_empty out ' @@ -37,7 +38,7 @@ test_expect_success 'request invalid capability' ' foobar 0000 EOF - test_must_fail git serve --stateless-rpc 2>err err err err err err out && + test-tool serve-v2 --stateless-rpc out && test-tool pkt-line unpack actual && test_cmp expect actual ' @@ -107,7 +108,7 @@ test_expect_success 'basic ref-prefixes' ' 0000 EOF - git serve --stateless-rpc out && + test-tool serve-v2 --stateless-rpc out && test-tool pkt-line unpack actual && test_cmp expect actual ' @@ -127,7 +128,7 @@ test_expect_success 'refs/heads prefix' ' 0000 EOF - git serve --stateless-rpc out && + test-tool serve-v2 --stateless-rpc out && test-tool pkt-line unpack actual && test_cmp expect actual ' @@ -148,7 +149,7 @@ test_expect_success 'peel parameter' ' 0000 EOF - git serve --stateless-rpc out && + test-tool serve-v2 --stateless-rpc out && test-tool pkt-line unpack actual && test_cmp expect actual ' @@ -169,7 +170,7 @@ test_expect_success 'symrefs parameter' ' 0000 EOF - git serve --stateless-rpc out && + test-tool serve-v2 --stateless-rpc out && test-tool pkt-line unpack actual && test_cmp expect actual ' @@ -189,7 +190,7 @@ test_expect_success 'sending server-options' ' 0000 EOF - git serve --stateless-rpc out && + test-tool serve-v2 --stateless-rpc out && test-tool pkt-line unpack actual && test_cmp expect actual ' @@ -204,7 +205,10 @@ test_expect_success 'unexpected lines are not allowed in fetch request' ' 0000 EOF - test_must_fail git -C server serve --stateless-rpc /dev/null 2>err && + ( + cd server && + test_must_fail test-tool serve-v2 --stateless-rpc + ) /dev/null 2>err && grep "unexpected line: .this-is-not-a-command." err ' diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index dbb4cf88814902..5b33f625dddecc 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -400,12 +400,13 @@ test_expect_success 'even with handcrafted request, filter does not work if not 0000 EOF - test_must_fail git -C server serve --stateless-rpc /dev/null 2>err && + test_must_fail test-tool -C server serve-v2 --stateless-rpc \ + /dev/null 2>err && grep "unexpected line: .filter blob:none." err && # Exercise to ensure that if advertised, filter works git -C server config uploadpack.allowfilter 1 && - git -C server serve --stateless-rpc /dev/null + test-tool -C server serve-v2 --stateless-rpc /dev/null ' test_expect_success 'default refspec is used to filter ref when fetchcing' ' diff --git a/t/t5703-upload-pack-ref-in-want.sh b/t/t5703-upload-pack-ref-in-want.sh index b6a995e8579c91..0951d1bbdc26d9 100755 --- a/t/t5703-upload-pack-ref-in-want.sh +++ b/t/t5703-upload-pack-ref-in-want.sh @@ -48,15 +48,15 @@ test_expect_success 'setup repository' ' ' test_expect_success 'config controls ref-in-want advertisement' ' - git serve --advertise-capabilities >out && + test-tool serve-v2 --advertise-capabilities >out && ! grep -a ref-in-want out && git config uploadpack.allowRefInWant false && - git serve --advertise-capabilities >out && + test-tool serve-v2 --advertise-capabilities >out && ! grep -a ref-in-want out && git config uploadpack.allowRefInWant true && - git serve --advertise-capabilities >out && + test-tool serve-v2 --advertise-capabilities >out && grep -a ref-in-want out ' @@ -70,7 +70,7 @@ test_expect_success 'invalid want-ref line' ' 0000 EOF - test_must_fail git serve --stateless-rpc 2>out out out out out out out out out out expect && git --git-dir="$3/.git" rev-parse --verify $4 >actual && diff --git a/git-remote-testgit.sh b/t/t5801/git-remote-testgit similarity index 100% rename from git-remote-testgit.sh rename to t/t5801/git-remote-testgit