Skip to content

Commit

Permalink
pretty: add a "reference" format
Browse files Browse the repository at this point in the history
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
  • Loading branch information
szeder committed Nov 5, 2019
1 parent 0194c62 commit 3604d0c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
7 changes: 3 additions & 4 deletions Documentation/SubmittingPatches
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,18 @@ archive, summarize the relevant points of the discussion.

[[commit-reference]]
If you want to reference a previous commit in the history of a stable
branch, use the format "abbreviated sha1 (subject, date)",
with the subject enclosed in a pair of double-quotes, like this:
branch, use the format "abbreviated sha1 (subject, date)", like this:

....
Commit f86a374 ("pack-bitmap.c: fix a memleak", 2015-03-30)
Commit f86a374 (pack-bitmap.c: fix a memleak, 2015-03-30)
noticed that ...
....

The "Copy commit summary" command of gitk can be used to obtain this
format, or this invocation of `git show`:

....
git show -s --date=short --pretty='format:%h ("%s", %ad)' <commit>
git show -s --pretty=reference <commit>
....

[[git-tools]]
Expand Down
6 changes: 6 additions & 0 deletions Documentation/pretty-formats.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ This is designed to be as compact as possible.

<full commit message>

* 'reference'

<abbreviated hash> (<title line>, <short author date>)
+
Use this format to refer to a commit in a log message.

* 'raw'
+
The 'raw' format shows the entire commit exactly as
Expand Down
2 changes: 1 addition & 1 deletion contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1749,7 +1749,7 @@ __git_log_shortlog_options="
--all-match --invert-grep
"

__git_log_pretty_formats="oneline short medium full fuller email raw format: mboxrd"
__git_log_pretty_formats="oneline short medium full fuller email raw reference format: mboxrd"
__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"

_git_log ()
Expand Down
3 changes: 2 additions & 1 deletion pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ static void setup_commit_formats(void)
{ "mboxrd", CMIT_FMT_MBOXRD, 0, 0 },
{ "fuller", CMIT_FMT_FULLER, 0, 8 },
{ "full", CMIT_FMT_FULL, 0, 8 },
{ "oneline", CMIT_FMT_ONELINE, 1, 0 }
{ "oneline", CMIT_FMT_ONELINE, 1, 0 },
{ "reference", CMIT_FMT_USERFORMAT, 1, 0, 0, "%C(auto)%h (%s, %as)" }
/*
* Please update $__git_log_pretty_formats in
* git-completion.bash when you add new formats.
Expand Down

0 comments on commit 3604d0c

Please sign in to comment.