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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Dec 6, 2024 at 14:24 UTC
023c3370ac330760aaf399cf6f6d9dbd7350e8e5
2 files changed
+25
-14
Documentation/Makefile
+8
-14
@@ -282,11 +282,13 @@ ifneq ($(filter-out lint-docs clean,$(MAKECMDGOALS)),)
282
-include ../GIT-VERSION-FILE
283
endif
284
285
+mergetools_txt = mergetools-diff.txt mergetools-merge.txt
286
+
287
#
288
# Determine "include::" file references in asciidoc files.
289
#
290
docdep_prereqs = \
289
- mergetools-list.made $(mergetools_txt) \
291
+ $(mergetools_txt) \
292
cmd-list.made $(cmds_txt)
293
294
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)
317
$(QUIET_GEN)$(PERL_PATH) ./cmd-list.perl .. . $(cmds_txt) && \
318
date >$@
319
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 $@
325
326
TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
327
Documentation/generate-mergetool-list.sh
new
+17
@@ -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"