Git fork
1manpages = {
2 # Category 1.
3 'git-add.adoc' : 1,
4 'git-am.adoc' : 1,
5 'git-annotate.adoc' : 1,
6 'git-apply.adoc' : 1,
7 'git-archimport.adoc' : 1,
8 'git-archive.adoc' : 1,
9 'git-backfill.adoc' : 1,
10 'git-bisect.adoc' : 1,
11 'git-blame.adoc' : 1,
12 'git-branch.adoc' : 1,
13 'git-bugreport.adoc' : 1,
14 'git-bundle.adoc' : 1,
15 'git-cat-file.adoc' : 1,
16 'git-check-attr.adoc' : 1,
17 'git-check-ignore.adoc' : 1,
18 'git-check-mailmap.adoc' : 1,
19 'git-checkout-index.adoc' : 1,
20 'git-checkout.adoc' : 1,
21 'git-check-ref-format.adoc' : 1,
22 'git-cherry-pick.adoc' : 1,
23 'git-cherry.adoc' : 1,
24 'git-citool.adoc' : 1,
25 'git-clean.adoc' : 1,
26 'git-clone.adoc' : 1,
27 'git-column.adoc' : 1,
28 'git-commit-graph.adoc' : 1,
29 'git-commit-tree.adoc' : 1,
30 'git-commit.adoc' : 1,
31 'git-config.adoc' : 1,
32 'git-count-objects.adoc' : 1,
33 'git-credential-cache--daemon.adoc' : 1,
34 'git-credential-cache.adoc' : 1,
35 'git-credential-store.adoc' : 1,
36 'git-credential.adoc' : 1,
37 'git-cvsexportcommit.adoc' : 1,
38 'git-cvsimport.adoc' : 1,
39 'git-cvsserver.adoc' : 1,
40 'git-daemon.adoc' : 1,
41 'git-describe.adoc' : 1,
42 'git-diagnose.adoc' : 1,
43 'git-diff-files.adoc' : 1,
44 'git-diff-index.adoc' : 1,
45 'git-diff-pairs.adoc' : 1,
46 'git-difftool.adoc' : 1,
47 'git-diff-tree.adoc' : 1,
48 'git-diff.adoc' : 1,
49 'git-fast-export.adoc' : 1,
50 'git-fast-import.adoc' : 1,
51 'git-fetch-pack.adoc' : 1,
52 'git-fetch.adoc' : 1,
53 'git-filter-branch.adoc' : 1,
54 'git-fmt-merge-msg.adoc' : 1,
55 'git-for-each-ref.adoc' : 1,
56 'git-for-each-repo.adoc' : 1,
57 'git-format-patch.adoc' : 1,
58 'git-fsck-objects.adoc' : 1,
59 'git-fsck.adoc' : 1,
60 'git-fsmonitor--daemon.adoc' : 1,
61 'git-gc.adoc' : 1,
62 'git-get-tar-commit-id.adoc' : 1,
63 'git-grep.adoc' : 1,
64 'git-gui.adoc' : 1,
65 'git-hash-object.adoc' : 1,
66 'git-help.adoc' : 1,
67 'git-hook.adoc' : 1,
68 'git-http-backend.adoc' : 1,
69 'git-http-fetch.adoc' : 1,
70 'git-http-push.adoc' : 1,
71 'git-imap-send.adoc' : 1,
72 'git-index-pack.adoc' : 1,
73 'git-init-db.adoc' : 1,
74 'git-init.adoc' : 1,
75 'git-instaweb.adoc' : 1,
76 'git-interpret-trailers.adoc' : 1,
77 'git-last-modified.adoc' : 1,
78 'git-log.adoc' : 1,
79 'git-ls-files.adoc' : 1,
80 'git-ls-remote.adoc' : 1,
81 'git-ls-tree.adoc' : 1,
82 'git-mailinfo.adoc' : 1,
83 'git-mailsplit.adoc' : 1,
84 'git-maintenance.adoc' : 1,
85 'git-merge-base.adoc' : 1,
86 'git-merge-file.adoc' : 1,
87 'git-merge-index.adoc' : 1,
88 'git-merge-one-file.adoc' : 1,
89 'git-mergetool--lib.adoc' : 1,
90 'git-mergetool.adoc' : 1,
91 'git-merge-tree.adoc' : 1,
92 'git-merge.adoc' : 1,
93 'git-mktag.adoc' : 1,
94 'git-mktree.adoc' : 1,
95 'git-multi-pack-index.adoc' : 1,
96 'git-mv.adoc' : 1,
97 'git-name-rev.adoc' : 1,
98 'git-notes.adoc' : 1,
99 'git-p4.adoc' : 1,
100 'git-pack-objects.adoc' : 1,
101 'git-pack-refs.adoc' : 1,
102 'git-patch-id.adoc' : 1,
103 'git-prune-packed.adoc' : 1,
104 'git-prune.adoc' : 1,
105 'git-pull.adoc' : 1,
106 'git-push.adoc' : 1,
107 'git-quiltimport.adoc' : 1,
108 'git-range-diff.adoc' : 1,
109 'git-read-tree.adoc' : 1,
110 'git-rebase.adoc' : 1,
111 'git-receive-pack.adoc' : 1,
112 'git-reflog.adoc' : 1,
113 'git-refs.adoc' : 1,
114 'git-remote-ext.adoc' : 1,
115 'git-remote-fd.adoc' : 1,
116 'git-remote.adoc' : 1,
117 'git-repack.adoc' : 1,
118 'git-replace.adoc' : 1,
119 'git-replay.adoc' : 1,
120 'git-repo.adoc' : 1,
121 'git-request-pull.adoc' : 1,
122 'git-rerere.adoc' : 1,
123 'git-reset.adoc' : 1,
124 'git-restore.adoc' : 1,
125 'git-revert.adoc' : 1,
126 'git-rev-list.adoc' : 1,
127 'git-rev-parse.adoc' : 1,
128 'git-rm.adoc' : 1,
129 'git-send-email.adoc' : 1,
130 'git-send-pack.adoc' : 1,
131 'git-shell.adoc' : 1,
132 'git-sh-i18n--envsubst.adoc' : 1,
133 'git-sh-i18n.adoc' : 1,
134 'git-shortlog.adoc' : 1,
135 'git-show-branch.adoc' : 1,
136 'git-show-index.adoc' : 1,
137 'git-show-ref.adoc' : 1,
138 'git-show.adoc' : 1,
139 'git-sh-setup.adoc' : 1,
140 'git-sparse-checkout.adoc' : 1,
141 'git-stage.adoc' : 1,
142 'git-stash.adoc' : 1,
143 'git-status.adoc' : 1,
144 'git-stripspace.adoc' : 1,
145 'git-submodule.adoc' : 1,
146 'git-svn.adoc' : 1,
147 'git-switch.adoc' : 1,
148 'git-symbolic-ref.adoc' : 1,
149 'git-tag.adoc' : 1,
150 'git-unpack-file.adoc' : 1,
151 'git-unpack-objects.adoc' : 1,
152 'git-update-index.adoc' : 1,
153 'git-update-ref.adoc' : 1,
154 'git-update-server-info.adoc' : 1,
155 'git-upload-archive.adoc' : 1,
156 'git-upload-pack.adoc' : 1,
157 'git-var.adoc' : 1,
158 'git-verify-commit.adoc' : 1,
159 'git-verify-pack.adoc' : 1,
160 'git-verify-tag.adoc' : 1,
161 'git-version.adoc' : 1,
162 'git-web--browse.adoc' : 1,
163 'git-worktree.adoc' : 1,
164 'git-write-tree.adoc' : 1,
165 'git.adoc' : 1,
166 'gitk.adoc' : 1,
167 'gitweb.adoc' : 1,
168 'scalar.adoc' : 1,
169
170 # Category 5.
171 'gitattributes.adoc' : 5,
172 'gitformat-bundle.adoc' : 5,
173 'gitformat-chunk.adoc' : 5,
174 'gitformat-commit-graph.adoc' : 5,
175 'gitformat-index.adoc' : 5,
176 'gitformat-loose.adoc' : 5,
177 'gitformat-pack.adoc' : 5,
178 'gitformat-signature.adoc' : 5,
179 'githooks.adoc' : 5,
180 'gitignore.adoc' : 5,
181 'gitmailmap.adoc' : 5,
182 'gitmodules.adoc' : 5,
183 'gitprotocol-capabilities.adoc' : 5,
184 'gitprotocol-common.adoc' : 5,
185 'gitprotocol-http.adoc' : 5,
186 'gitprotocol-pack.adoc' : 5,
187 'gitprotocol-v2.adoc' : 5,
188 'gitrepository-layout.adoc' : 5,
189 'gitweb.conf.adoc' : 5,
190
191 # Category 7.
192 'gitcli.adoc' : 7,
193 'gitcore-tutorial.adoc' : 7,
194 'gitcredentials.adoc' : 7,
195 'gitcvs-migration.adoc' : 7,
196 'gitdiffcore.adoc' : 7,
197 'giteveryday.adoc' : 7,
198 'gitfaq.adoc' : 7,
199 'gitglossary.adoc' : 7,
200 'gitpacking.adoc' : 7,
201 'gitnamespaces.adoc' : 7,
202 'gitremote-helpers.adoc' : 7,
203 'gitrevisions.adoc' : 7,
204 'gitsubmodules.adoc' : 7,
205 'gittutorial-2.adoc' : 7,
206 'gittutorial.adoc' : 7,
207 'gitworkflows.adoc' : 7,
208}
209
210manpages_breaking_changes = {
211 'git-pack-redundant.adoc' : 1,
212 'git-whatchanged.adoc' : 1,
213}
214
215if not get_option('breaking_changes')
216 manpages += manpages_breaking_changes
217endif
218
219docs_backend = get_option('docs_backend')
220if docs_backend == 'auto'
221 if find_program('asciidoc', dirs: program_path, native: true, required: false).found()
222 docs_backend = 'asciidoc'
223 elif find_program('asciidoctor', dirs: program_path, native: true, required: false).found()
224 docs_backend = 'asciidoctor'
225 else
226 error('Neither asciidoc nor asciidoctor were found.')
227 endif
228endif
229
230if docs_backend == 'asciidoc'
231 asciidoc = find_program('asciidoc', dirs: program_path, native: true)
232 asciidoc_html = 'xhtml11'
233 asciidoc_docbook = 'docbook'
234 xmlto_extra = [ ]
235
236 asciidoc_conf = custom_target(
237 command: [
238 shell,
239 meson.project_source_root() / 'GIT-VERSION-GEN',
240 meson.project_source_root(),
241 '@INPUT@',
242 '@OUTPUT@',
243 ],
244 input: 'asciidoc.conf.in',
245 output: 'asciidoc.conf',
246 depends: [git_version_file],
247 env: version_gen_environment,
248 )
249
250 asciidoc_common_options = [
251 asciidoc,
252 '--conf-file=' + asciidoc_conf.full_path(),
253 '--attribute=build_dir=' + meson.current_build_dir(),
254 ]
255
256 pager_opt = get_option('default_pager')
257 if pager_opt != '' and pager_opt != 'less'
258 asciidoc_common_options += '-agit-default-pager=' + pager_opt
259 endif
260
261 editor_opt = get_option('default_editor')
262 if editor_opt != '' and editor_opt != 'vi'
263 asciidoc_common_options += '-agit-default-editor=' + editor_opt
264 endif
265
266 documentation_deps = [
267 asciidoc_conf,
268 ]
269elif docs_backend == 'asciidoctor'
270 asciidoctor = find_program('asciidoctor', dirs: program_path, native: true)
271 asciidoc_html = 'xhtml5'
272 asciidoc_docbook = 'docbook5'
273 xmlto_extra = [
274 '--skip-validation',
275 '-x', meson.current_source_dir() / 'manpage.xsl',
276 ]
277
278 asciidoctor_extensions = custom_target(
279 command: [
280 shell,
281 meson.project_source_root() / 'GIT-VERSION-GEN',
282 meson.project_source_root(),
283 '@INPUT@',
284 '@OUTPUT@',
285 ],
286 input: 'asciidoctor-extensions.rb.in',
287 output: 'asciidoctor-extensions.rb',
288 depends: [git_version_file],
289 env: version_gen_environment,
290 )
291
292 asciidoc_common_options = [
293 asciidoctor,
294 '--attribute', 'compat-mode',
295 '--attribute', 'tabsize=8',
296 '--attribute', 'litdd=--',
297 '--attribute', 'docinfo=shared',
298 '--attribute', 'build_dir=' + meson.current_build_dir(),
299 '--load-path', meson.current_build_dir(),
300 '--require', 'asciidoctor-extensions',
301 ]
302
303 pager_opt = get_option('default_pager')
304 if pager_opt != '' and pager_opt != 'less'
305 asciidoc_common_options += '-agit-default-pager=' + pager_opt
306 endif
307
308 editor_opt = get_option('default_editor')
309 if editor_opt != '' and editor_opt != 'vi'
310 asciidoc_common_options += '-agit-default-editor=' + editor_opt
311 endif
312
313 documentation_deps = [
314 asciidoctor_extensions,
315 ]
316endif
317
318if get_option('breaking_changes')
319 asciidoc_common_options += ['--attribute', 'with-breaking-changes']
320endif
321
322xmlto = find_program('xmlto', dirs: program_path, native: true)
323
324cmd_lists = [
325 'cmds-ancillaryinterrogators.adoc',
326 'cmds-ancillarymanipulators.adoc',
327 'cmds-mainporcelain.adoc',
328 'cmds-plumbinginterrogators.adoc',
329 'cmds-plumbingmanipulators.adoc',
330 'cmds-synchingrepositories.adoc',
331 'cmds-synchelpers.adoc',
332 'cmds-guide.adoc',
333 'cmds-developerinterfaces.adoc',
334 'cmds-userinterfaces.adoc',
335 'cmds-purehelpers.adoc',
336 'cmds-foreignscminterface.adoc',
337]
338
339documentation_deps += custom_target(
340 command: [
341 shell,
342 '@INPUT@',
343 meson.project_source_root(),
344 meson.current_build_dir(),
345 ] + cmd_lists,
346 input: 'cmd-list.sh',
347 output: cmd_lists
348)
349
350foreach mode : [ 'diff', 'merge' ]
351 documentation_deps += custom_target(
352 command: [
353 shell,
354 '@INPUT@',
355 '..',
356 mode,
357 '@OUTPUT@'
358 ],
359 env: [
360 'MERGE_TOOLS_DIR=' + meson.project_source_root() / 'mergetools',
361 ],
362 input: 'generate-mergetool-list.sh',
363 output: 'mergetools-' + mode + '.adoc',
364 )
365endforeach
366
367foreach manpage, category : manpages
368 if get_option('docs').contains('man')
369 manpage_xml_target = custom_target(
370 command: asciidoc_common_options + [
371 '--backend=' + asciidoc_docbook,
372 '--doctype=manpage',
373 '--out-file=@OUTPUT@',
374 '@INPUT@',
375 ],
376 depends: documentation_deps,
377 input: manpage,
378 output: fs.stem(manpage) + '.xml',
379 )
380
381 doc_targets += custom_target(
382 command: [
383 xmlto,
384 '-m', '@INPUT0@',
385 '-m', '@INPUT1@',
386 '--stringparam',
387 'man.base.url.for.relative.links=' + get_option('prefix') / get_option('mandir'),
388 'man',
389 manpage_xml_target,
390 '-o',
391 meson.current_build_dir(),
392 ] + xmlto_extra,
393 input: [
394 'manpage-normal.xsl',
395 'manpage-bold-literal.xsl',
396 ],
397 output: fs.stem(manpage) + '.' + category.to_string(),
398 install: true,
399 install_dir: get_option('mandir') / 'man' + category.to_string(),
400 )
401 endif
402
403 if get_option('docs').contains('html')
404 doc_targets += custom_target(
405 command: asciidoc_common_options + [
406 '--backend=' + asciidoc_html,
407 '--doctype=manpage',
408 '--out-file=@OUTPUT@',
409 '@INPUT@',
410 ],
411 depends: documentation_deps,
412 input: manpage,
413 output: fs.stem(manpage) + '.html',
414 install: true,
415 install_dir: get_option('datadir') / 'doc/git-doc',
416 )
417 endif
418endforeach
419
420if get_option('docs').contains('html')
421 configure_file(
422 input: 'docinfo-html.in',
423 output: 'docinfo.html',
424 copy: true,
425 install: true,
426 install_dir: get_option('datadir') / 'doc/git-doc',
427 )
428
429 configure_file(
430 input: 'docbook-xsl.css',
431 output: 'docbook-xsl.css',
432 copy: true,
433 install: true,
434 install_dir: get_option('datadir') / 'doc/git-doc',
435 )
436
437 install_symlink('index.html',
438 install_dir: get_option('datadir') / 'doc/git-doc',
439 pointing_to: 'git.html',
440 )
441
442 xsltproc = find_program('xsltproc', dirs: program_path, native: true)
443
444 user_manual_xml = custom_target(
445 command: asciidoc_common_options + [
446 '--backend=' + asciidoc_docbook,
447 '--doctype=book',
448 '--out-file=@OUTPUT@',
449 '@INPUT@',
450 ],
451 input: 'user-manual.adoc',
452 output: 'user-manual.xml',
453 depends: documentation_deps,
454 )
455
456 doc_targets += custom_target(
457 command: [
458 xsltproc,
459 '--xinclude',
460 '--stringparam', 'html.stylesheet', 'docbook-xsl.css',
461 '--param', 'generate.consistent.ids', '1',
462 '--output', '@OUTPUT@',
463 '@INPUT@',
464 user_manual_xml,
465 ],
466 input: 'docbook.xsl',
467 output: 'user-manual.html',
468 install: true,
469 install_dir: get_option('datadir') / 'doc/git-doc',
470 )
471
472 articles = [
473 'BreakingChanges.adoc',
474 'DecisionMaking.adoc',
475 'MyFirstContribution.adoc',
476 'MyFirstObjectWalk.adoc',
477 'ReviewingGuidelines.adoc',
478 'SubmittingPatches',
479 'ToolsForGit.adoc',
480 'git-bisect-lk2009.adoc',
481 'git-tools.adoc',
482 ]
483
484 foreach article : articles
485 doc_targets += custom_target(
486 command: asciidoc_common_options + [
487 '--backend=' + asciidoc_html,
488 '--out-file=@OUTPUT@',
489 '@INPUT@',
490 ],
491 input: article,
492 output: fs.stem(article) + '.html',
493 depends: documentation_deps,
494 install: true,
495 install_dir: get_option('datadir') / 'doc/git-doc',
496 )
497 endforeach
498
499 asciidoc_html_options = asciidoc_common_options + [
500 '--backend=' + asciidoc_html,
501 '--out-file=@OUTPUT@',
502 '--attribute', 'git-relative-html-prefix=../',
503 '@INPUT@',
504 ]
505
506 subdir('howto')
507 subdir('technical')
508endif
509
510# Sanity check that we are not missing any tests present in 't/'. This check
511# only runs once at configure time and is thus best-effort, only. Furthermore,
512# it only verifies man pages for the sake of simplicity.
513configured_manpages = manpages.keys()
514configured_manpages += manpages_breaking_changes.keys()
515configured_manpages += [ 'git-bisect-lk2009.adoc', 'git-tools.adoc' ]
516actual_manpages = run_command(shell, '-c', 'ls git*.adoc scalar.adoc',
517 check: true,
518 env: script_environment,
519).stdout().strip().split('\n')
520
521if configured_manpages != actual_manpages
522 missing_manpage = [ ]
523 foreach actual_manpage : actual_manpages
524 if actual_manpage not in configured_manpages
525 missing_manpage += actual_manpage
526 endif
527 endforeach
528 if missing_manpage.length() > 0
529 error('Man page found, but not configured:\n\n - ' + '\n - '.join(missing_manpage))
530 endif
531
532 superfluous_manpage = [ ]
533 foreach configured_manpage : configured_manpages
534 if configured_manpage not in actual_manpages
535 superfluous_manpage += configured_manpage
536 endif
537 endforeach
538 if superfluous_manpage.length() > 0
539 error('Man page configured, but not found:\n\n - ' + '\n - '.join(superfluous_manpage))
540 endif
541endif