Home Explore Blog CI



git

4th chunk of `Documentation/git-interpret-trailers.adoc`
d219044d48b66372e23e4decb0deda034ff089a7723be58700000001000008b4
 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 config trailer.sign.cmd 'echo "$(git config user.name) <$(git config user.email)>"'
$ git interpret-trailers --trailer sign <msg1.txt
subject

body text

Signed-off-by: Bob <bob@example.com>
$ cat msg2.txt
subject

body text

Signed-off-by: Alice <alice@example.com>
$ git interpret-trailers --trailer sign <msg2.txt
subject

body text

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

* Configure a 'fix' trailer with a key that contains a '#' and no
  space after this character, and show how it works:
+
------------
$ git config trailer.separators ":#"
$ git config trailer.fix.key "Fix #"
$ echo "subject" | git interpret-trailers --trailer fix=42
subject

Fix #42
------------

* Configure a 'help' trailer with a cmd use a script `glog-find-author`
  which search specified author identity from git log in git repository
  and show how it works:
+
------------
$ cat ~/bin/glog-find-author
#!/bin/sh
test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true
$ cat msg.txt
subject

body text
$ git config trailer.help.key "Helped-by: "
$ git config trailer.help.ifExists "addIfDifferentNeighbor"
$ git config trailer.help.cmd "~/bin/glog-find-author"
$ git interpret-trailers --trailer="help:Junio"

Title: Examples of Using Git Interpret Trailers
Summary
The text provides several examples of using the git-interpret-trailers command to add, modify, and configure trailers in commit messages, including in-place editing, extracting patches, and using custom scripts and configuration settings to automate trailer management, demonstrating various use cases and scenarios for working with trailers in Git.