summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-01-16 12:40:27 -0800
committerJunio C Hamano <gitster@pobox.com>2026-01-16 12:40:27 -0800
commitc813513c731c83ce80871cad58772402975b0af4 (patch)
tree0ffaf8e546c8583d45d0f958dd9614c4be7d09c1
parent5058dc1ec1bfde19f64eda266793ced25d5aec9b (diff)
parent2ac93bfcbc28e28a4844095648988558dad02aa3 (diff)
downloadgit-c813513c731c83ce80871cad58772402975b0af4.tar.xz
Merge branch 'ds/builtin-doc-update'
Update in-code comment doc to match the current API. * ds/builtin-doc-update: builtin.h: update documentation
-rw-r--r--builtin.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/builtin.h b/builtin.h
index 1b35565fbd..e5e16ecaa6 100644
--- a/builtin.h
+++ b/builtin.h
@@ -17,7 +17,8 @@
* . Define the implementation of the built-in command `foo` with
* signature:
*
- * int cmd_foo(int argc, const char **argv, const char *prefix);
+ * int cmd_foo(int argc, const char **argv,
+ * const char *prefix, struct repository *repo);
*
* . Add the external declaration for the function to `builtin.h`.
*
@@ -29,12 +30,14 @@
* where options is the bitwise-or of:
*
* `RUN_SETUP`:
+ *
* If there is not a Git directory to work on, abort. If there
* is a work tree, chdir to the top of it if the command was
* invoked in a subdirectory. If there is no work tree, no
* chdir() is done.
*
* `RUN_SETUP_GENTLY`:
+ *
* If there is a Git directory, chdir as per RUN_SETUP, otherwise,
* don't chdir anywhere.
*
@@ -57,6 +60,12 @@
* more informed decision, e.g., by ignoring `pager.<cmd>` for
* certain subcommands.
*
+ * `NO_PARSEOPT`:
+ *
+ * Most Git builtins use the parseopt library for parsing options.
+ * This flag indicates that a custom parser is used and thus the
+ * builtin would not appear in 'git --list-cmds=parseopt'.
+ *
* . Add `builtin/foo.o` to `BUILTIN_OBJS` in `Makefile`.
*
* Additionally, if `foo` is a new command, there are 4 more things to do:
@@ -69,6 +78,21 @@
*
* . Add an entry for `/git-foo` to `.gitignore`.
*
+ * As you work on implementing your builtin, be mindful that the
+ * following tests will check different aspects of the builtin's
+ * readiness and adherence to matching the documentation:
+ *
+ * * t0012-help.sh checks that the builtin can handle -h, which comes
+ * automatically with the parseopt API.
+ *
+ * * t0450-txt-doc-vs-help.sh checks that the -h help output matches the
+ * SYNOPSIS in the documentation for the builtin.
+ *
+ * * t1517-outside-repo.sh checks that the builtin can handle -h when
+ * run outside of the context of a repository. Note that this test
+ * requires that the usage has a space after the builtin name, so some
+ * minimum description of options is required.
+ *
*
* How a built-in is called
* ------------------------