326
$ git config trailer.sign.ifmissing add
327
$ git config trailer.sign.ifexists doNothing
328
$ git config trailer.sign.command 'echo "$(git config user.name) <$(git config user.email)>"'
329
-$ git interpret-trailers <<EOF
330
-> EOF
329
+$ git interpret-trailers </dev/null
330
331
Signed-off-by: Bob <bob@example.com>
333
-$ git interpret-trailers <<EOF
334
-> Signed-off-by: Alice <alice@example.com>
335
-> EOF
332
+$ cat msg.txt
333
+Signed-off-by: Alice <alice@example.com>
334
+$ git interpret-trailers <msg.txt
335
336
Signed-off-by: Alice <alice@example.com>
337
------------
356
$ cat ~/bin/glog-find-author
357
#!/bin/sh
358
test -n "$1" && git log --author="$1" --pretty="%an <%ae>" -1 || true
359
+$ cat msg.txt
360
+subject
361
+
362
+message
363
$ git config trailer.help.key "Helped-by: "
364
$ git config trailer.help.ifExists "addIfDifferentNeighbor"
365
$ git config trailer.help.cmd "~/bin/glog-find-author"
363
-$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <<EOF
364
-> subject
365
->
366
-> message
367
->
368
-> EOF
366
+$ git interpret-trailers --trailer="help:Junio" --trailer="help:Couder" <msg.txt
367
subject
368
369
message
380
$ cat ~/bin/glog-grep
381
#!/bin/sh
382
test -n "$1" && git log --grep "$1" --pretty=reference -1 || true
383
+$ cat msg.txt
384
+subject
385
+
386
+message
387
$ git config trailer.ref.key "Reference-to: "
388
$ git config trailer.ref.ifExists "replace"
389
$ git config trailer.ref.cmd "~/bin/glog-grep"
388
-$ git interpret-trailers --trailer="ref:Add copyright notices." <<EOF
389
-> subject
390
->
391
-> message
392
->
393
-> EOF
390
+$ git interpret-trailers --trailer="ref:Add copyright notices." <msg.txt
391
subject
392
393
message
399
commit that is related, and show how it works:
400
+
401
------------
402
+$ cat msg.txt
403
+subject
404
+
405
+message
406
+
407
+see: HEAD~2
408
$ git config trailer.see.key "See-also: "
409
$ git config trailer.see.ifExists "replace"
410
$ git config trailer.see.ifMissing "doNothing"
411
$ git config trailer.see.command "git log -1 --oneline --format=\"%h (%s)\" --abbrev-commit --abbrev=14 \$ARG"
409
-$ git interpret-trailers <<EOF
410
-> subject
411
->
412
-> message
413
->
414
-> see: HEAD~2
415
-> EOF
412
+$ git interpret-trailers <msg.txt
413
subject
414
415
message
424
to add a 'git-version' trailer:
425
+
426
------------
430
-$ sed -e 's/ Z$/ /' >commit_template.txt <<EOF
431
-> ***subject***
432
->
433
-> ***message***
434
->
435
-> Fixes: Z
436
-> Cc: Z
437
-> Reviewed-by: Z
438
-> Signed-off-by: Z
439
-> EOF
427
+$ cat temp.txt
428
+***subject***
429
+
430
+***message***
431
+
432
+Fixes: Z
433
+Cc: Z
434
+Reviewed-by: Z
435
+Signed-off-by: Z
436
+$ sed -e 's/ Z$/ /' temp.txt > commit_template.txt
437
$ git config commit.template commit_template.txt
441
-$ cat >.git/hooks/commit-msg <<EOF
442
-> #!/bin/sh
443
-> git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new"
444
-> mv "\$1.new" "\$1"
445
-> EOF
438
+$ cat .git/hooks/commit-msg
439
+#!/bin/sh
440
+git interpret-trailers --trim-empty --trailer "git-version: \$(git describe)" "\$1" > "\$1.new"
441
+mv "\$1.new" "\$1"
442
$ chmod +x .git/hooks/commit-msg
443
------------
444