Skip to content

Commit

Permalink
Merge branch 'js/misc-doc-fixes'
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
gitster committed May 8, 2019
2 parents f560a4d b7ce24d commit caa227f
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 51 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 135,6 @@
/git-remote-ftps
/git-remote-fd
/git-remote-ext
/git-remote-testgit
/git-remote-testpy
/git-remote-testsvn
/git-repack
Expand Down
1 change: 1 addition & 0 deletions Documentation/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 14,4 @@ manpage-base-url.xsl
SubmittingPatches.txt
tmp-doc-diff/
GIT-ASCIIDOCFLAGS
/GIT-EXCLUDED-PROGRAMS
3 changes: 3 additions & 0 deletions Documentation/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 30 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 592,7 @@ FUZZ_PROGRAMS =
LIB_OBJS =
PROGRAM_OBJS =
PROGRAMS =
EXCLUDED_PROGRAMS =
SCRIPT_PERL =
SCRIPT_PYTHON =
SCRIPT_SH =
Expand All @@ -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
Expand All @@ -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/*/
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):\
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand Down Expand Up @@ -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/
Expand All @@ -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/
Expand Down Expand Up @@ -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" || \
Expand All @@ -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; \
Expand Down
1 change: 0 additions & 1 deletion builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion generate-cmdlist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ die () {
}

command_list () {
grep -v '^#' "$1"
eval "grep -ve '^#' $exclude_programs" <"$1"
}

get_categories () {
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
7 changes: 4 additions & 3 deletions builtin/serve.c → t/helper/test-serve-v2.c
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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,
Expand Down
20 changes: 20 additions & 0 deletions t/helper/test-tool.c
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 },
Expand Down Expand Up @@ -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 ;
Expand Down
1 change: 1 addition & 0 deletions t/helper/test-tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit caa227f

Please sign in to comment.