Skip to content

Commit 023c337

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 628d49f commit 023c337

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
@@ -282,11 +282,13 @@ ifneq ($(filter-out lint-docs clean,$(MAKECMDGOALS)),)
282282
-include ../GIT-VERSION-FILE
283283
endif
284284

285+
mergetools_txt = mergetools-diff.txt mergetools-merge.txt
286+
285287
#
286288
# Determine "include::" file references in asciidoc files.
287289
#
288290
docdep_prereqs = \
289-
mergetools-list.made $(mergetools_txt) \
291+
$(mergetools_txt) \
290292
cmd-list.made $(cmds_txt)
291293

292294
doc.dep : $(docdep_prereqs) $(DOC_DEP_TXT) build-docdep.perl
@@ -315,19 +317,11 @@ cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
315317
$(QUIET_GEN)$(PERL_PATH) ./cmd-list.perl .. . $(cmds_txt) && \
316318
date >$@
317319

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

332326
TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
333327

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 >&2 "USAGE: $0 <SOURCE_DIR> <MODE> <OUTPUT>"
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)