Home Explore Blog CI



git

3rd chunk of `Documentation/git-interpret-trailers.adoc`
982037fc1ea22c6e34602249ed18e96330dfb9f69e90d5f10000000100000d5d
 occurrence of
	'--if-exists' or '--no-if-exists'. Upon encountering '--no-if-exists, clear the
	effect of any previous use of '--if-exists, such that the relevant configuration
	variables are no longer overridden. Possible actions are `addIfDifferent`,
	`addIfDifferentNeighbor`, `add`, `replace` and `doNothing`.

--if-missing <action>::
--no-if-missing::
	Specify what action will be performed when there is no other
	trailer with the same <key> in the input.  A setting
	provided with '--if-missing' overrides the `trailer.ifMissing` and any
	applicable `trailer.<keyAlias>.ifMissing` configuration variables
	and applies to all '--trailer' options until the next occurrence of
	'--if-missing' or '--no-if-missing'. Upon encountering '--no-if-missing,
	clear the effect of any previous use of '--if-missing, such that the relevant
	configuration variables are no longer overridden. Possible actions are `doNothing`
	or `add`.

--only-trailers::
	Output only the trailers, not any other parts of the input.

--only-input::
	Output only trailers that exist in the input; do not add any
	from the command-line or by applying `trailer.*` configuration
	variables.

--unfold::
	If a trailer has a value that runs over multiple lines (aka "folded"),
	reformat the value into a single line.

--parse::
	A convenience alias for `--only-trailers --only-input
	--unfold`. This makes it easier to only see the trailers coming from the
	input without influencing them with any command line options or
	configuration variables, while also making the output machine-friendly with
	--unfold.

--no-divider::
	Do not treat `---` as the end of the commit message. Use this
	when you know your input contains just the commit message itself
	(and not an email or the output of `git format-patch`).

CONFIGURATION VARIABLES
-----------------------

include::includes/cmd-config-section-all.adoc[]

include::config/trailer.adoc[]

EXAMPLES
--------

* Configure a 'sign' trailer with a 'Signed-off-by' key, and then
  add two of these trailers to a commit message file:
+
------------
$ git config trailer.sign.key "Signed-off-by"
$ cat msg.txt
subject

body text
$ git interpret-trailers --trailer 'sign: Alice <alice@example.com>' --trailer 'sign: Bob <bob@example.com>' <msg.txt
subject

body text

Signed-off-by: Alice <alice@example.com>
Signed-off-by: Bob <bob@example.com>
------------

* Use the `--in-place` option to edit a commit message file in place:
+
------------
$ cat msg.txt
subject

body text

Signed-off-by: Bob <bob@example.com>
$ git interpret-trailers --trailer 'Acked-by: Alice <alice@example.com>' --in-place msg.txt
$ cat msg.txt
subject

body text

Signed-off-by: Bob <bob@example.com>
Acked-by: Alice <alice@example.com>
------------

* Extract the last commit as a patch, and add a 'Cc' and a
  'Reviewed-by' trailer to it:
+
------------
$ git format-patch -1
0001-foo.patch
$ git interpret-trailers --trailer 'Cc: Alice <alice@example.com>' --trailer 'Reviewed-by: Bob <bob@example.com>' 0001-foo.patch >0001-bar.patch
------------

* Configure a 'sign' trailer with a command to automatically add a
  'Signed-off-by: ' with the author information only if there is no
  'Signed-off-by: ' already, and show how it works:
+
------------
$ cat msg1.txt
subject

body text
$ git config trailer.sign.key "Signed-off-by: "
$ git config trailer.sign.ifmissing add
$ git config trailer.sign.ifexists doNothing
$ git

Title: Git Interpret Trailers Command Options and Configuration
Summary
The git-interpret-trailers command provides various options and configuration variables to customize the behavior of adding, parsing, and outputting trailers in commit messages, including settings for placement, actions, and formatting, with examples demonstrating how to use these features to manage trailers in commit messages and patches.