docs: fix cross-directory linkgit references

Most of our documentation is in a single directory, so using linkgit:git-config[1] just generates a relative link in the same directory. However, this is not the case with the API documentation in technical/*, which need to refer to git-config from the parent directory. We can fix this by passing a special prefix attribute when building in a subdirectory, and respecting that prefix in our linkgit definitions. We only have to modify the html linkgit definition. For manpages, we can ignore this for two reasons: 1. we do not generate actual links to the file in manpages, but instead just give the name and section of the linked manpage 2. we do not currently build manpages for subdirectories, only html Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jun 7, 2012 at 23:03 UTC fe77b416c774a469a585c4b58fcae5e7a5f3545d
5 files changed +8 -6
Documentation/Makefile
+2
@@ -270,6 +270,7 @@ technical/api-index.txt: technical/api-index-skel.txt \
270 technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
271 $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
272
273 +technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
274 $(patsubst %,%.html,$(API_DOCS) technical/api-index): %.html : %.txt
275 $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
276 $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
@@ -323,6 +324,7 @@ $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
324
325 WEBDOC_DEST = /pub/software/scm/git/docs
326
327 +howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
328 $(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
329 $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
330 sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
Documentation/asciidoc.conf
+1 -1
@@ -91,5 +91,5 @@ endif::doctype-manpage[]
91
92 ifdef::backend-xhtml11[]
93 [linkgit-inlinemacro]
94 -<a href="{target}.html">{target}{0?({0})}</a>
94 +<a href="{git-relative-html-prefix}{target}.html">{target}{0?({0})}</a>
95 endif::backend-xhtml11[]
Documentation/technical/api-config.txt
+1 -1
@@ -2,7 +2,7 @@ config API
2 ==========
3
4 The config API gives callers a way to access git configuration files
5 -(and files which have the same syntax). See linkgit:../git-config[1] for a
5 +(and files which have the same syntax). See linkgit:git-config[1] for a
6 discussion of the config file syntax.
7
8 General Usage
Documentation/technical/api-credentials.txt
+3 -3
@@ -180,7 +180,7 @@ longer than a single git process; e.g., credentials may be stored
180 in-memory for a few minutes, or indefinitely on disk).
181
182 Each helper is specified by a single string in the configuration
183 -variable `credential.helper` (and others, see linkgit:../git-config[1]).
183 +variable `credential.helper` (and others, see linkgit:git-config[1]).
184 The string is transformed by git into a command to be executed using
185 these rules:
186
@@ -293,6 +293,6 @@ helpers will just ignore the new requests).
293 See also
294 --------
295
296 -linkgit:../gitcredentials[7]
296 +linkgit:gitcredentials[7]
297
298 -linkgit:../git-config[5] (See configuration variables `credential.*`)
298 +linkgit:git-config[5] (See configuration variables `credential.*`)
Documentation/technical/api-merge.txt
+1 -1
@@ -36,7 +36,7 @@ the operation of a low-level (single file) merge. Some options:
36 ancestors in a recursive merge.
37 If a helper program is specified by the
38 `[merge "<driver>"] recursive` configuration, it will
39 - be used (see linkgit:../gitattributes[5]).
39 + be used (see linkgit:gitattributes[5]).
40
41 `variant`::
42 Resolve local conflicts automatically in favor