Skip to content

Commit caa227f

Browse files
committed
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
2 parents f560a4d + b7ce24d commit caa227f

15 files changed

+99
-51
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@
135135
/git-remote-ftps
136136
/git-remote-fd
137137
/git-remote-ext
138-
/git-remote-testgit
139138
/git-remote-testpy
140139
/git-remote-testsvn
141140
/git-repack

Documentation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ manpage-base-url.xsl
1414
SubmittingPatches.txt
1515
tmp-doc-diff/
1616
GIT-ASCIIDOCFLAGS
17+
/GIT-EXCLUDED-PROGRAMS

Documentation/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ ARTICLES =
77
SP_ARTICLES =
88
OBSOLETE_HTML =
99

10+
-include GIT-EXCLUDED-PROGRAMS
11+
1012
MAN1_TXT += $(filter-out \
13+
$(patsubst %,%.txt,$(EXCLUDED_PROGRAMS)) \
1114
$(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
1215
$(wildcard git-*.txt))
1316
MAN1_TXT += git.txt

Makefile

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ FUZZ_PROGRAMS =
592592
LIB_OBJS =
593593
PROGRAM_OBJS =
594594
PROGRAMS =
595+
EXCLUDED_PROGRAMS =
595596
SCRIPT_PERL =
596597
SCRIPT_PYTHON =
597598
SCRIPT_SH =
@@ -614,7 +615,6 @@ SCRIPT_SH += git-merge-resolve.sh
614615
SCRIPT_SH += git-mergetool.sh
615616
SCRIPT_SH += git-quiltimport.sh
616617
SCRIPT_SH += git-legacy-stash.sh
617-
SCRIPT_SH += git-remote-testgit.sh
618618
SCRIPT_SH += git-request-pull.sh
619619
SCRIPT_SH += git-submodule.sh
620620
SCRIPT_SH += git-web--browse.sh
@@ -637,17 +637,11 @@ SCRIPT_PERL += git-svn.perl
637637

638638
SCRIPT_PYTHON += git-p4.py
639639

640-
NO_INSTALL += git-remote-testgit
641-
642640
# Generated files for scripts
643641
SCRIPT_SH_GEN = $(patsubst %.sh,%,$(SCRIPT_SH))
644642
SCRIPT_PERL_GEN = $(patsubst %.perl,%,$(SCRIPT_PERL))
645643
SCRIPT_PYTHON_GEN = $(patsubst %.py,%,$(SCRIPT_PYTHON))
646644

647-
SCRIPT_SH_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_SH_GEN))
648-
SCRIPT_PERL_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_PERL_GEN))
649-
SCRIPT_PYTHON_INS = $(filter-out $(NO_INSTALL),$(SCRIPT_PYTHON_GEN))
650-
651645
# Individual rules to allow e.g.
652646
# "make -C ../.. SCRIPT_PERL=contrib/foo/bar.perl build-perl-script"
653647
# from subdirectories like contrib/*/
@@ -657,11 +651,11 @@ build-sh-script: $(SCRIPT_SH_GEN)
657651
build-python-script: $(SCRIPT_PYTHON_GEN)
658652

659653
.PHONY: install-perl-script install-sh-script install-python-script
660-
install-sh-script: $(SCRIPT_SH_INS)
654+
install-sh-script: $(SCRIPT_SH_GEN)
661655
$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
662-
install-perl-script: $(SCRIPT_PERL_INS)
656+
install-perl-script: $(SCRIPT_PERL_GEN)
663657
$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
664-
install-python-script: $(SCRIPT_PYTHON_INS)
658+
install-python-script: $(SCRIPT_PYTHON_GEN)
665659
$(INSTALL) $^ '$(DESTDIR_SQ)$(gitexec_instdir_SQ)'
666660

667661
.PHONY: clean-perl-script clean-sh-script clean-python-script
@@ -672,9 +666,9 @@ clean-perl-script:
672666
clean-python-script:
673667
$(RM) $(SCRIPT_PYTHON_GEN)
674668

675-
SCRIPTS = $(SCRIPT_SH_INS) \
676-
$(SCRIPT_PERL_INS) \
677-
$(SCRIPT_PYTHON_INS) \
669+
SCRIPTS = $(SCRIPT_SH_GEN) \
670+
$(SCRIPT_PERL_GEN) \
671+
$(SCRIPT_PYTHON_GEN) \
678672
git-instaweb
679673

680674
ETAGS_TARGET = TAGS
@@ -744,6 +738,7 @@ TEST_BUILTINS_OBJS += test-repository.o
744738
TEST_BUILTINS_OBJS += test-revision-walking.o
745739
TEST_BUILTINS_OBJS += test-run-command.o
746740
TEST_BUILTINS_OBJS += test-scrap-cache-tree.o
741+
TEST_BUILTINS_OBJS += test-serve-v2.o
747742
TEST_BUILTINS_OBJS += test-sha1.o
748743
TEST_BUILTINS_OBJS += test-sha1-array.o
749744
TEST_BUILTINS_OBJS += test-sha256.o
@@ -1125,7 +1120,6 @@ BUILTIN_OBJS += builtin/rev-parse.o
11251120
BUILTIN_OBJS += builtin/revert.o
11261121
BUILTIN_OBJS += builtin/rm.o
11271122
BUILTIN_OBJS += builtin/send-pack.o
1128-
BUILTIN_OBJS += builtin/serve.o
11291123
BUILTIN_OBJS += builtin/shortlog.o
11301124
BUILTIN_OBJS += builtin/show-branch.o
11311125
BUILTIN_OBJS += builtin/show-index.o
@@ -1342,6 +1336,7 @@ ifdef NO_CURL
13421336
REMOTE_CURL_PRIMARY =
13431337
REMOTE_CURL_ALIASES =
13441338
REMOTE_CURL_NAMES =
1339+
EXCLUDED_PROGRAMS += git-http-fetch git-http-push
13451340
else
13461341
ifdef CURLDIR
13471342
# Try "-Wl,-rpath=$(CURLDIR)/$(lib)" in such a case.
@@ -1366,7 +1361,11 @@ endif
13661361
ifeq "$(curl_check)" "070908"
13671362
ifndef NO_EXPAT
13681363
PROGRAM_OBJS += http-push.o
1364+
else
1365+
EXCLUDED_PROGRAMS += git-http-push
13691366
endif
1367+
else
1368+
EXCLUDED_PROGRAMS += git-http-push
13701369
endif
13711370
curl_check := $(shell (echo 072200; $(CURL_CONFIG) --vernum | sed -e '/^70[BC]/s/^/0/') 2>/dev/null | sort -r | sed -ne 2p)
13721371
ifeq "$(curl_check)" "072200"
@@ -1614,6 +1613,7 @@ ifdef NO_INET_PTON
16141613
endif
16151614
ifdef NO_UNIX_SOCKETS
16161615
BASIC_CFLAGS += -DNO_UNIX_SOCKETS
1616+
EXCLUDED_PROGRAMS += git-credential-cache git-credential-cache--daemon
16171617
else
16181618
LIB_OBJS += unix-socket.o
16191619
PROGRAM_OBJS += credential-cache.o
@@ -2133,7 +2133,9 @@ $(BUILT_INS): git$X
21332133
command-list.h: generate-cmdlist.sh command-list.txt
21342134

21352135
command-list.h: $(wildcard Documentation/git*.txt) Documentation/*config.txt Documentation/config/*.txt
2136-
$(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh command-list.txt >$@+ && mv $@+ $@
2136+
$(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \
2137+
$(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \
2138+
command-list.txt >$@+ && mv $@+ $@
21372139

21382140
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
21392141
$(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
@@ -2466,6 +2468,14 @@ $(VCSSVN_LIB): $(VCSSVN_OBJS)
24662468

24672469
export DEFAULT_EDITOR DEFAULT_PAGER
24682470

2471+
Documentation/GIT-EXCLUDED-PROGRAMS: FORCE
2472+
@EXCLUDED='EXCLUDED_PROGRAMS := $(EXCLUDED_PROGRAMS)'; \
2473+
if test x"$$EXCLUDED" != \
2474+
x"`cat Documentation/GIT-EXCLUDED-PROGRAMS 2>/dev/null`" ; then \
2475+
echo >&2 " * new documentation flags"; \
2476+
echo "$$EXCLUDED" >Documentation/GIT-EXCLUDED-PROGRAMS; \
2477+
fi
2478+
24692479
.PHONY: doc man man-perl html info pdf
24702480
doc: man-perl
24712481
$(MAKE) -C Documentation all
@@ -2704,7 +2714,6 @@ endif
27042714
test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
27052715

27062716
all:: $(TEST_PROGRAMS) $(test_bindir_programs)
2707-
all:: $(NO_INSTALL)
27082717

27092718
bin-wrappers/%: wrap-for-bin.sh
27102719
@mkdir -p bin-wrappers
@@ -2991,7 +3000,7 @@ rpm::
29913000

29923001
artifacts-tar:: $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) $(OTHER_PROGRAMS) \
29933002
GIT-BUILD-OPTIONS $(TEST_PROGRAMS) $(test_bindir_programs) \
2994-
$(NO_INSTALL) $(MOFILES)
3003+
$(MOFILES)
29953004
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) \
29963005
SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
29973006
test -n "$(ARTIFACTS_DIRECTORY)"
@@ -3040,7 +3049,7 @@ clean: profile-clean coverage-clean cocciclean
30403049
$(RM) $(OBJECTS)
30413050
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
30423051
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X
3043-
$(RM) $(TEST_PROGRAMS) $(NO_INSTALL)
3052+
$(RM) $(TEST_PROGRAMS)
30443053
$(RM) $(FUZZ_PROGRAMS)
30453054
$(RM) -r bin-wrappers $(dep_dirs)
30463055
$(RM) -r po/build/
@@ -3049,6 +3058,7 @@ clean: profile-clean coverage-clean cocciclean
30493058
$(RM) $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
30503059
$(RM) $(htmldocs).tar.gz $(manpages).tar.gz
30513060
$(MAKE) -C Documentation/ clean
3061+
$(RM) Documentation/GIT-EXCLUDED-PROGRAMS
30523062
ifndef NO_PERL
30533063
$(MAKE) -C gitweb clean
30543064
$(RM) -r perl/build/
@@ -3084,7 +3094,7 @@ check-docs::
30843094
git-merge-octopus | git-merge-ours | git-merge-recursive | \
30853095
git-merge-resolve | git-merge-subtree | \
30863096
git-fsck-objects | git-init-db | \
3087-
git-remote-* | git-stage | \
3097+
git-remote-* | git-stage | git-legacy-* | \
30883098
git-?*--?* ) continue ;; \
30893099
esac ; \
30903100
test -f "Documentation/$$v.txt" || \
@@ -3108,7 +3118,7 @@ check-docs::
31083118
-e 's/\.txt//'; \
31093119
) | while read how cmd; \
31103120
do \
3111-
case " $(patsubst %$X,%,$(ALL_COMMANDS)) " in \
3121+
case " $(patsubst %$X,%,$(ALL_COMMANDS) $(EXCLUDED_PROGRAMS)) " in \
31123122
*" $$cmd "*) ;; \
31133123
*) echo "removed but $$how: $$cmd" ;; \
31143124
esac; \

builtin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ extern int cmd_rev_parse(int argc, const char **argv, const char *prefix);
219219
extern int cmd_revert(int argc, const char **argv, const char *prefix);
220220
extern int cmd_rm(int argc, const char **argv, const char *prefix);
221221
extern int cmd_send_pack(int argc, const char **argv, const char *prefix);
222-
extern int cmd_serve(int argc, const char **argv, const char *prefix);
223222
extern int cmd_shortlog(int argc, const char **argv, const char *prefix);
224223
extern int cmd_show(int argc, const char **argv, const char *prefix);
225224
extern int cmd_show_branch(int argc, const char **argv, const char *prefix);

generate-cmdlist.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ die () {
66
}
77

88
command_list () {
9-
grep -v '^#' "$1"
9+
eval "grep -ve '^#' $exclude_programs" <"$1"
1010
}
1111

1212
get_categories () {
@@ -93,6 +93,14 @@ EOF
9393
EOF
9494
}
9595

96+
exclude_programs=
97+
while test "--exclude-program" = "$1"
98+
do
99+
shift
100+
exclude_programs="$exclude_programs -e \"^$1 \""
101+
shift
102+
done
103+
96104
echo "/* Automatically generated by generate-cmdlist.sh */
97105
struct cmdname_help {
98106
const char *name;

git.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,6 @@ static struct cmd_struct commands[] = {
570570
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
571571
{ "rm", cmd_rm, RUN_SETUP },
572572
{ "send-pack", cmd_send_pack, RUN_SETUP },
573-
{ "serve", cmd_serve, RUN_SETUP },
574573
{ "shortlog", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },
575574
{ "show", cmd_show, RUN_SETUP },
576575
{ "show-branch", cmd_show_branch, RUN_SETUP },

builtin/serve.c renamed to t/helper/test-serve-v2.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
#include "test-tool.h"
12
#include "cache.h"
2-
#include "builtin.h"
33
#include "parse-options.h"
44
#include "serve.h"
55

66
static char const * const serve_usage[] = {
7-
N_("git serve [<options>]"),
7+
N_("test-tool serve-v2 [<options>]"),
88
NULL
99
};
1010

11-
int cmd_serve(int argc, const char **argv, const char *prefix)
11+
int cmd__serve_v2(int argc, const char **argv)
1212
{
1313
struct serve_options opts = SERVE_OPTIONS_INIT;
1414

@@ -19,6 +19,7 @@ int cmd_serve(int argc, const char **argv, const char *prefix)
1919
N_("exit immediately after advertising capabilities")),
2020
OPT_END()
2121
};
22+
const char *prefix = setup_git_directory();
2223

2324
/* ignore all unknown cmdline switches for now */
2425
argc = parse_options(argc, argv, prefix, options, serve_usage,

t/helper/test-tool.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#include "git-compat-util.h"
22
#include "test-tool.h"
33
#include "trace2.h"
4+
#include "parse-options.h"
5+
6+
static const char * const test_tool_usage[] = {
7+
"test-tool [-C <directory>] <command [<arguments>...]]",
8+
NULL
9+
};
410

511
struct test_cmd {
612
const char *name;
@@ -43,6 +49,7 @@ static struct test_cmd cmds[] = {
4349
{ "revision-walking", cmd__revision_walking },
4450
{ "run-command", cmd__run_command },
4551
{ "scrap-cache-tree", cmd__scrap_cache_tree },
52+
{ "serve-v2", cmd__serve_v2 },
4653
{ "sha1", cmd__sha1 },
4754
{ "sha1-array", cmd__sha1_array },
4855
{ "sha256", cmd__sha256 },
@@ -75,11 +82,24 @@ static NORETURN void die_usage(void)
7582
int cmd_main(int argc, const char **argv)
7683
{
7784
int i;
85+
const char *working_directory = NULL;
86+
struct option options[] = {
87+
OPT_STRING('C', NULL, &working_directory, "directory",
88+
"change the working directory"),
89+
OPT_END()
90+
};
7891

7992
BUG_exit_code = 99;
93+
argc = parse_options(argc, argv, NULL, options, test_tool_usage,
94+
PARSE_OPT_STOP_AT_NON_OPTION |
95+
PARSE_OPT_KEEP_ARGV0);
96+
8097
if (argc < 2)
8198
die_usage();
8299

100+
if (working_directory && chdir(working_directory) < 0)
101+
die("Could not cd to '%s'", working_directory);
102+
83103
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
84104
if (!strcmp(cmds[i].name, argv[1])) {
85105
argv++;

t/helper/test-tool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int cmd__repository(int argc, const char **argv);
3939
int cmd__revision_walking(int argc, const char **argv);
4040
int cmd__run_command(int argc, const char **argv);
4141
int cmd__scrap_cache_tree(int argc, const char **argv);
42+
int cmd__serve_v2(int argc, const char **argv);
4243
int cmd__sha1(int argc, const char **argv);
4344
int cmd__sha1_array(int argc, const char **argv);
4445
int cmd__sha256(int argc, const char **argv);

0 commit comments

Comments
 (0)