1Integrating new subcommands 2=========================== 3 4This is how-to documentation for people who want to add extension 5commands to git. It should be read alongside api-builtin.txt. 6 7Runtime environment 8------------------- 9 10git subcommands are standalone executables that live in the git exec 11path, normally /usr/lib/git-core. The git executable itself is a 12thin wrapper that knows where the subcommands live, and runs them by 13passing command-line arguments to them. 14 15(If "git foo" is not found in the git exec path, the wrapper 16will look in the rest of your $PATH for it. Thus, it's possible 17to write local git extensions that don't live in system space.) 18 19Implementation languages 20------------------------ 21 22Most subcommands are written in C or shell. A few are written in 23Perl. 24 25While we strongly encourage coding in portable C for portability, 26these specific scripting languages are also acceptable. We won't 27accept more without a very strong technical case, as we don't want 28to broaden the git suite's required dependencies. Import utilities, 29surgical tools, remote helpers and other code at the edges of the 30git suite are more lenient and we allow Python (and even Tcl/tk), 31but they should not be used for core functions. 32 33This may change in the future. Especially Python is not allowed in 34core because we need better Python integration in the git Windows 35installer before we can be confident people in that environment 36won't experience an unacceptably large loss of capability. 37 38C commands are normally written as single modules, named after the 39command, that link a collection of functions called libgit. Thus, 40your command 'git-foo' would normally be implemented as a single 41"git-foo.c" (or "builtin/foo.c" if it is to be linked to the main 42binary); this organization makes it easy for people reading the code 43to find things. 44 45See the CodingGuidelines document for other guidance on what we consider 46good practice in C and shell, and api-builtin.txt for the support 47functions available to built-in commands written in C. 48 49What every extension command needs 50---------------------------------- 51 52You must have a man page, written in asciidoc (this is what git help 53followed by your subcommand name will display). Be aware that there is 54a local asciidoc configuration and macros which you should use. It's 55often helpful to start by cloning an existing page and replacing the 56text content. 57 58You must have a test, written to report in TAP (Test Anything Protocol). 59Tests are executables (usually shell scripts) that live in the 't' 60subdirectory of the tree. Each test name begins with 't' and a sequence 61number that controls where in the test sequence it will be executed; 62conventionally the rest of the name stem is that of the command 63being tested. 64 65Read the file t/README to learn more about the conventions to be used 66in writing tests, and the test support library. 67 68Integrating a command 69--------------------- 70 71Here are the things you need to do when you want to merge a new 72subcommand into the git tree. 73 740. Don't forget to sign off your patch! 75 761. Append your command name to one of the variables BUILTIN_OBJS, 77EXTRA_PROGRAMS, SCRIPT_SH, SCRIPT_PERL or SCRIPT_PYTHON. 78 792. Drop its test in the t directory. 80 813. If your command is implemented in an interpreted language with a 82p-code intermediate form, make sure .gitignore in the main directory 83includes a pattern entry that ignores such files. Python .pyc and 84.pyo files will already be covered. 85 864. If your command has any dependency on a particular version of 87your language, document it in the INSTALL file. 88 895. There is a file command-list.txt in the distribution main directory 90that categorizes commands by type, so they can be listed in appropriate 91subsections in the documentation's summary command list. Add an entry 92for yours. To understand the categories, look at git-cmmands.txt 93in the main directory. 94 956. Give the maintainer one paragraph to include in the RelNotes file 96to describe the new feature; a good place to do so is in the cover 97letter [PATCH 0/n]. 98 99That's all there is to it.