Merge branch 'js/misc-doc-fixes'

"make check-docs", "git help -a", etc. did not account for cases
where a particular build may deliberately omit some subcommands,
which has been corrected.

* js/misc-doc-fixes:
  Turn `git serve` into a test helper
  test-tool: handle the `-C <directory>` option just like `git`
  check-docs: do not bother checking for legacy scripts' documentation
  docs: exclude documentation for commands that have been excluded
  check-docs: allow command-list.txt to contain excluded commands
  help -a: do not list commands that are excluded from the build
  Makefile: drop the NO_INSTALL variable
  remote-testgit: move it into the support directory for t5801
This commit is contained in:
Junio C Hamano 2019-05-09 00:37:27 +09:00
commit caa227ff45
15 changed files with 99 additions and 51 deletions

1
.gitignore vendored
View File

@ -135,7 +135,6 @@
/git-remote-ftps
/git-remote-fd
/git-remote-ext
/git-remote-testgit
/git-remote-testpy
/git-remote-testsvn
/git-repack

View File

@ -14,3 +14,4 @@ manpage-base-url.xsl
SubmittingPatches.txt
tmp-doc-diff/
GIT-ASCIIDOCFLAGS
/GIT-EXCLUDED-PROGRAMS

View File

@ -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

View File

@ -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; \

View File

@ -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);

View File

@ -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;

1
git.c
View File

@ -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 },

View File

@ -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 [<options>]"),
N_("test-tool serve-v2 [<options>]"),
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,

View File

@ -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 <directory>] <command [<arguments>...]]",
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++;

View File

@ -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);

View File

@ -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 <out >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 <in &&
test-tool serve-v2 --stateless-rpc >out <in &&
test_must_be_empty out &&
# EOF
git serve --stateless-rpc >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 <in &&
test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
test_i18ngrep "unknown capability" err
'
@ -46,7 +47,7 @@ test_expect_success 'request with no command' '
agent=git/test
0000
EOF
test_must_fail git serve --stateless-rpc 2>err <in &&
test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
test_i18ngrep "no command requested" err
'
@ -56,7 +57,7 @@ test_expect_success 'request invalid command' '
agent=git/test
0000
EOF
test_must_fail git serve --stateless-rpc 2>err <in &&
test_must_fail test-tool serve-v2 --stateless-rpc 2>err <in &&
test_i18ngrep "invalid command" err
'
@ -87,7 +88,7 @@ test_expect_success 'basics of ls-refs' '
0000
EOF
git serve --stateless-rpc <in >out &&
test-tool serve-v2 --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual &&
test_cmp expect actual
'
@ -107,7 +108,7 @@ test_expect_success 'basic ref-prefixes' '
0000
EOF
git serve --stateless-rpc <in >out &&
test-tool serve-v2 --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual &&
test_cmp expect actual
'
@ -127,7 +128,7 @@ test_expect_success 'refs/heads prefix' '
0000
EOF
git serve --stateless-rpc <in >out &&
test-tool serve-v2 --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual &&
test_cmp expect actual
'
@ -148,7 +149,7 @@ test_expect_success 'peel parameter' '
0000
EOF
git serve --stateless-rpc <in >out &&
test-tool serve-v2 --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual &&
test_cmp expect actual
'
@ -169,7 +170,7 @@ test_expect_success 'symrefs parameter' '
0000
EOF
git serve --stateless-rpc <in >out &&
test-tool serve-v2 --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >actual &&
test_cmp expect actual
'
@ -189,7 +190,7 @@ test_expect_success 'sending server-options' '
0000
EOF
git serve --stateless-rpc <in >out &&
test-tool serve-v2 --stateless-rpc <in >out &&
test-tool pkt-line unpack <out >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 <in >/dev/null 2>err &&
(
cd server &&
test_must_fail test-tool serve-v2 --stateless-rpc
) <in >/dev/null 2>err &&
grep "unexpected line: .this-is-not-a-command." err
'

View File

@ -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 <in >/dev/null 2>err &&
test_must_fail test-tool -C server serve-v2 --stateless-rpc \
<in >/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 <in >/dev/null
test-tool -C server serve-v2 --stateless-rpc <in >/dev/null
'
test_expect_success 'default refspec is used to filter ref when fetchcing' '

View File

@ -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 <in &&
test_must_fail test-tool serve-v2 --stateless-rpc 2>out <in &&
grep "unknown ref" out
'
@ -90,7 +90,7 @@ test_expect_success 'basic want-ref' '
0000
EOF
git serve --stateless-rpc >out <in &&
test-tool serve-v2 --stateless-rpc >out <in &&
check_output
'
@ -112,7 +112,7 @@ test_expect_success 'multiple want-ref lines' '
0000
EOF
git serve --stateless-rpc >out <in &&
test-tool serve-v2 --stateless-rpc >out <in &&
check_output
'
@ -133,7 +133,7 @@ test_expect_success 'mix want and want-ref' '
0000
EOF
git serve --stateless-rpc >out <in &&
test-tool serve-v2 --stateless-rpc >out <in &&
check_output
'
@ -153,7 +153,7 @@ test_expect_success 'want-ref with ref we already have commit for' '
0000
EOF
git serve --stateless-rpc >out <in &&
test-tool serve-v2 --stateless-rpc >out <in &&
check_output
'

View File

@ -8,6 +8,8 @@ test_description='Test remote-helper import and export commands'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-gpg.sh
PATH="$TEST_DIRECTORY/t5801:$PATH"
compare_refs() {
git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
git --git-dir="$3/.git" rev-parse --verify $4 >actual &&