Skip to content

Commit 019064e

Browse files
pks-tgitster
authored andcommitted
Documentation: extract script to generate a list of mergetools
We include the list of available mergetools into our manpages. Extract the script that performs this logic such that we can reuse it in other build systems. While at it, refactor the Makefile targets such that we don't create "mergetools-list.made" anymore. It shouldn't be necessary, as we can instead have other targets depend on "mergetools-{diff,merge}.txt" directly. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 10d333e commit 019064e

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

Documentation/Makefile

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,13 @@ ifneq ($(filter-out lint-docs clean,$(MAKECMDGOALS)),)
276276
-include ../GIT-VERSION-FILE
277277
endif
278278

279+
mergetools_txt = mergetools-diff.txt mergetools-merge.txt
280+
279281
#
280282
# Determine "include::" file references in asciidoc files.
281283
#
282284
docdep_prereqs = \
283-
mergetools-list.made $(mergetools_txt) \
285+
$(mergetools_txt) \
284286
cmd-list.made $(cmds_txt)
285287

286288
doc.dep : $(docdep_prereqs) $(DOC_DEP_TXT) build-docdep.perl
@@ -309,19 +311,11 @@ cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
309311
$(QUIET_GEN)$(PERL_PATH) ./cmd-list.perl .. . $(cmds_txt) && \
310312
date >$@
311313

312-
mergetools_txt = mergetools-diff.txt mergetools-merge.txt
313-
314-
$(mergetools_txt): mergetools-list.made
315-
316-
mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
317-
$(QUIET_GEN) \
318-
$(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && TOOL_MODE=diff && \
319-
. ../git-mergetool--lib.sh && \
320-
show_tool_names can_diff' | sed -e "s/\([a-z0-9]*\)/\`\1\`;;/" >mergetools-diff.txt && \
321-
$(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && TOOL_MODE=merge && \
322-
. ../git-mergetool--lib.sh && \
323-
show_tool_names can_merge' | sed -e "s/\([a-z0-9]*\)/\`\1\`;;/" >mergetools-merge.txt && \
324-
date >$@
314+
mergetools-%.txt: generate-mergetool-list.sh ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
315+
mergetools-diff.txt:
316+
$(QUIET_GEN)$(SHELL_PATH) ./generate-mergetool-list.sh .. diff $@
317+
mergetools-merge.txt:
318+
$(QUIET_GEN)$(SHELL_PATH) ./generate-mergetool-list.sh .. merge $@
325319

326320
TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
327321

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
if test "$#" -ne 3
4+
then
5+
echo "USAGE: $0 <SOURCE_DIR> <MODE> <OUTPUT>" >&2
6+
exit 1
7+
fi
8+
9+
SOURCE_DIR="$1"
10+
TOOL_MODE="$2"
11+
OUTPUT="$3"
12+
MERGE_TOOLS_DIR="$SOURCE_DIR/mergetools"
13+
14+
(
15+
. "$SOURCE_DIR"/git-mergetool--lib.sh &&
16+
show_tool_names can_$TOOL_MODE
17+
) | sed -e "s/\([a-z0-9]*\)/\`\1\`;;/" >"$OUTPUT"

0 commit comments

Comments
 (0)