Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 1 | git-for-each-ref(1) |
| 2 | =================== |
| 3 | |
| 4 | NAME |
| 5 | ---- |
| 6 | git-for-each-ref - Output information on each ref |
| 7 | |
| 8 | SYNOPSIS |
| 9 | -------- |
Junio C Hamano | a9b8d24 | 2007-05-19 04:51:55 | [diff] [blame] | 10 | [verse] |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 11 | 'git for-each-ref' [--count=<count>] [--shell|--perl|--python|--tcl] |
Junio C Hamano | d2179ef | 2010-10-22 04:12:17 | [diff] [blame] | 12 | [(--sort=<key>)...] [--format=<format>] [<pattern>...] |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 13 | [--points-at=<object>] |
| 14 | (--merged[=<object>] | --no-merged[=<object>]) |
| 15 | [--contains[=<object>]] [--no-contains[=<object>]] |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 16 | |
| 17 | DESCRIPTION |
| 18 | ----------- |
| 19 | |
| 20 | Iterate over all refs that match `<pattern>` and show them |
| 21 | according to the given `<format>`, after sorting them according |
Junio C Hamano | a2f4662 | 2008-09-03 05:20:31 | [diff] [blame] | 22 | to the given set of `<key>`. If `<count>` is given, stop after |
Junio C Hamano | f9771f6 | 2007-01-17 17:42:30 | [diff] [blame] | 23 | showing that many refs. The interpolated values in `<format>` |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 24 | can optionally be quoted as string literals in the specified |
| 25 | host language allowing their direct evaluation in that language. |
| 26 | |
| 27 | OPTIONS |
| 28 | ------- |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 29 | <pattern>...:: |
| 30 | If one or more patterns are given, only refs are shown that |
| 31 | match against at least one pattern, either using fnmatch(3) or |
| 32 | literally, in the latter case matching completely or from the |
| 33 | beginning up to a slash. |
| 34 | |
| 35 | --count=<count>:: |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 36 | By default the command shows all refs that match |
| 37 | `<pattern>`. This option makes it stop after showing |
| 38 | that many refs. |
| 39 | |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 40 | --sort=<key>:: |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 41 | A field name to sort on. Prefix `-` to sort in |
| 42 | descending order of the value. When unspecified, |
Junio C Hamano | f7c042d | 2008-06-06 22:50:53 | [diff] [blame] | 43 | `refname` is used. You may use the --sort=<key> option |
| 44 | multiple times, in which case the last key becomes the primary |
| 45 | key. |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 46 | |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 47 | --format=<format>:: |
Junio C Hamano | a4ff729 | 2017-08-23 21:56:43 | [diff] [blame] | 48 | A string that interpolates `%(fieldname)` from a ref being shown |
| 49 | and the object it points at. If `fieldname` |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 50 | is prefixed with an asterisk (`*`) and the ref points |
Junio C Hamano | a4ff729 | 2017-08-23 21:56:43 | [diff] [blame] | 51 | at a tag object, use the value for the field in the object |
| 52 | which the tag object refers to (instead of the field in the tag object). |
| 53 | When unspecified, `<format>` defaults to |
Junio C Hamano | 4de43af | 2006-10-28 21:29:01 | [diff] [blame] | 54 | `%(objectname) SPC %(objecttype) TAB %(refname)`. |
| 55 | It also interpolates `%%` to `%`, and `%xx` where `xx` |
| 56 | are hex digits interpolates to character with hex code |
| 57 | `xx`; for example `%00` interpolates to `\0` (NUL), |
| 58 | `%09` to `\t` (TAB) and `%0a` to `\n` (LF). |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 59 | |
Junio C Hamano | bfd91f4 | 2018-08-17 22:21:16 | [diff] [blame^] | 60 | --color[=<when>]:: |
Junio C Hamano | d8dc0b5 | 2017-10-07 07:47:19 | [diff] [blame] | 61 | Respect any colors specified in the `--format` option. The |
| 62 | `<when>` field must be one of `always`, `never`, or `auto` (if |
| 63 | `<when>` is absent, behave as if `always` was given). |
| 64 | |
Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 65 | --shell:: |
| 66 | --perl:: |
| 67 | --python:: |
| 68 | --tcl:: |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 69 | If given, strings that substitute `%(fieldname)` |
| 70 | placeholders are quoted as string literals suitable for |
| 71 | the specified host language. This is meant to produce |
| 72 | a scriptlet that can directly be `eval`ed. |
| 73 | |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 74 | --points-at=<object>:: |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 75 | Only list refs which points at the given object. |
| 76 | |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 77 | --merged[=<object>]:: |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 78 | Only list refs whose tips are reachable from the |
Junio C Hamano | 59a5f53 | 2017-04-11 08:38:02 | [diff] [blame] | 79 | specified commit (HEAD if not specified), |
| 80 | incompatible with `--no-merged`. |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 81 | |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 82 | --no-merged[=<object>]:: |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 83 | Only list refs whose tips are not reachable from the |
Junio C Hamano | 59a5f53 | 2017-04-11 08:38:02 | [diff] [blame] | 84 | specified commit (HEAD if not specified), |
| 85 | incompatible with `--merged`. |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 86 | |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 87 | --contains[=<object>]:: |
Junio C Hamano | 5996b67 | 2016-04-13 22:01:41 | [diff] [blame] | 88 | Only list refs which contain the specified commit (HEAD if not |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 89 | specified). |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 90 | |
Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 91 | --no-contains[=<object>]:: |
Junio C Hamano | 59a5f53 | 2017-04-11 08:38:02 | [diff] [blame] | 92 | Only list refs which don't contain the specified commit (HEAD |
| 93 | if not specified). |
| 94 | |
Junio C Hamano | 52b1cfb | 2016-12-20 00:18:36 | [diff] [blame] | 95 | --ignore-case:: |
| 96 | Sorting and filtering refs are case insensitive. |
| 97 | |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 98 | FIELD NAMES |
| 99 | ----------- |
| 100 | |
| 101 | Various values from structured fields in referenced objects can |
| 102 | be used to interpolate into the resulting output, or as sort |
| 103 | keys. |
| 104 | |
| 105 | For all objects, the following names can be used: |
| 106 | |
| 107 | refname:: |
Junio C Hamano | 42f855f | 2007-02-06 00:09:38 | [diff] [blame] | 108 | The name of the ref (the part after $GIT_DIR/). |
Junio C Hamano | 5e4d8de | 2008-09-19 06:27:02 | [diff] [blame] | 109 | For a non-ambiguous short name of the ref append `:short`. |
Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 110 | The option core.warnAmbiguousRefs is used to select the strict |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 111 | abbreviation mode. If `lstrip=<N>` (`rstrip=<N>`) is appended, strips `<N>` |
| 112 | slash-separated path components from the front (back) of the refname |
| 113 | (e.g. `%(refname:lstrip=2)` turns `refs/tags/foo` into `foo` and |
| 114 | `%(refname:rstrip=2)` turns `refs/tags/foo` into `refs`). |
| 115 | If `<N>` is a negative number, strip as many path components as |
| 116 | necessary from the specified end to leave `-<N>` path components |
| 117 | (e.g. `%(refname:lstrip=-2)` turns |
| 118 | `refs/tags/foo` into `tags/foo` and `%(refname:rstrip=-1)` |
| 119 | turns `refs/tags/foo` into `refs`). When the ref does not have |
| 120 | enough components, the result becomes an empty string if |
| 121 | stripping with positive <N>, or it becomes the full refname if |
| 122 | stripping with negative <N>. Neither is an error. |
| 123 | + |
Junio C Hamano | 96153bf | 2018-04-25 08:25:34 | [diff] [blame] | 124 | `strip` can be used as a synonym to `lstrip`. |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 125 | |
| 126 | objecttype:: |
| 127 | The type of the object (`blob`, `tree`, `commit`, `tag`). |
| 128 | |
| 129 | objectsize:: |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 130 | The size of the object (the same as 'git cat-file -s' reports). |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 131 | |
| 132 | objectname:: |
| 133 | The object name (aka SHA-1). |
Junio C Hamano | e97d577 | 2010-05-19 08:13:58 | [diff] [blame] | 134 | For a non-ambiguous abbreviation of the object name append `:short`. |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 135 | For an abbreviation of the object name with desired length append |
| 136 | `:short=<length>`, where the minimum length is MINIMUM_ABBREV. The |
| 137 | length may be exceeded to ensure unique object names. |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 138 | |
Junio C Hamano | 98e32c3 | 2009-04-13 02:39:53 | [diff] [blame] | 139 | upstream:: |
| 140 | The name of a local ref which can be considered ``upstream'' |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 141 | from the displayed ref. Respects `:short`, `:lstrip` and |
| 142 | `:rstrip` in the same way as `refname` above. Additionally |
| 143 | respects `:track` to show "[ahead N, behind M]" and |
| 144 | `:trackshort` to show the terse version: ">" (ahead), "<" |
| 145 | (behind), "<>" (ahead and behind), or "=" (in sync). `:track` |
| 146 | also prints "[gone]" whenever unknown upstream ref is |
| 147 | encountered. Append `:track,nobracket` to show tracking |
Junio C Hamano | b72f603 | 2017-11-15 05:57:08 | [diff] [blame] | 148 | information without brackets (i.e "ahead N, behind M"). |
| 149 | + |
| 150 | For any remote-tracking branch `%(upstream)`, `%(upstream:remotename)` |
| 151 | and `%(upstream:remoteref)` refer to the name of the remote and the |
| 152 | name of the tracked remote ref, respectively. In other words, the |
| 153 | remote-tracking branch can be updated explicitly and individually by |
| 154 | using the refspec `%(upstream:remoteref):%(upstream)` to fetch from |
| 155 | `%(upstream:remotename)`. |
| 156 | + |
| 157 | Has no effect if the ref does not have tracking information associated |
| 158 | with it. All the options apart from `nobracket` are mutually exclusive, |
| 159 | but if used together the last option is selected. |
Junio C Hamano | f079f70 | 2013-12-06 23:43:18 | [diff] [blame] | 160 | |
Junio C Hamano | 975f4db | 2015-06-05 20:28:29 | [diff] [blame] | 161 | push:: |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 162 | The name of a local ref which represents the `@{push}` |
| 163 | location for the displayed ref. Respects `:short`, `:lstrip`, |
Junio C Hamano | b72f603 | 2017-11-15 05:57:08 | [diff] [blame] | 164 | `:rstrip`, `:track`, `:trackshort`, `:remotename`, and `:remoteref` |
| 165 | options as `upstream` does. Produces an empty string if no `@{push}` |
| 166 | ref is configured. |
Junio C Hamano | 975f4db | 2015-06-05 20:28:29 | [diff] [blame] | 167 | |
Junio C Hamano | f079f70 | 2013-12-06 23:43:18 | [diff] [blame] | 168 | HEAD:: |
| 169 | '*' if HEAD matches current ref (the checked out branch), ' ' |
| 170 | otherwise. |
| 171 | |
| 172 | color:: |
Junio C Hamano | 4b2a6c1 | 2017-08-22 18:32:37 | [diff] [blame] | 173 | Change output color. Followed by `:<colorname>`, where color |
| 174 | names are described under Values in the "CONFIGURATION FILE" |
| 175 | section of linkgit:git-config[1]. For example, |
| 176 | `%(color:bold red)`. |
Junio C Hamano | 98e32c3 | 2009-04-13 02:39:53 | [diff] [blame] | 177 | |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 178 | align:: |
| 179 | Left-, middle-, or right-align the content between |
Junio C Hamano | 76df4f7 | 2016-02-26 22:13:10 | [diff] [blame] | 180 | %(align:...) and %(end). The "align:" is followed by |
| 181 | `width=<width>` and `position=<position>` in any order |
| 182 | separated by a comma, where the `<position>` is either left, |
| 183 | right or middle, default being left and `<width>` is the total |
| 184 | length of the content with alignment. For brevity, the |
| 185 | "width=" and/or "position=" prefixes may be omitted, and bare |
| 186 | <width> and <position> used instead. For instance, |
| 187 | `%(align:<width>,<position>)`. If the contents length is more |
| 188 | than the width then no alignment is performed. If used with |
Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 189 | `--quote` everything in between %(align:...) and %(end) is |
Junio C Hamano | 76df4f7 | 2016-02-26 22:13:10 | [diff] [blame] | 190 | quoted, but if nested then only the topmost level performs |
| 191 | quoting. |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 192 | |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 193 | if:: |
| 194 | Used as %(if)...%(then)...%(end) or |
| 195 | %(if)...%(then)...%(else)...%(end). If there is an atom with |
| 196 | value or string literal after the %(if) then everything after |
| 197 | the %(then) is printed, else if the %(else) atom is used, then |
| 198 | everything after %(else) is printed. We ignore space when |
| 199 | evaluating the string before %(then), this is useful when we |
| 200 | use the %(HEAD) atom which prints either "*" or " " and we |
| 201 | want to apply the 'if' condition only on the 'HEAD' ref. |
| 202 | Append ":equals=<string>" or ":notequals=<string>" to compare |
| 203 | the value between the %(if:...) and %(then) atoms with the |
| 204 | given string. |
| 205 | |
| 206 | symref:: |
| 207 | The ref which the given symbolic ref refers to. If not a |
| 208 | symbolic ref, nothing is printed. Respects the `:short`, |
| 209 | `:lstrip` and `:rstrip` options in the same way as `refname` |
| 210 | above. |
| 211 | |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 212 | In addition to the above, for commit and tag objects, the header |
| 213 | field names (`tree`, `parent`, `object`, `type`, and `tag`) can |
| 214 | be used to specify the value in the header field. |
| 215 | |
Junio C Hamano | 4e6ba27 | 2016-01-20 23:23:19 | [diff] [blame] | 216 | For commit and tag objects, the special `creatordate` and `creator` |
| 217 | fields will correspond to the appropriate date or name-email-date tuple |
| 218 | from the `committer` or `tagger` fields depending on the object type. |
| 219 | These are intended for working on a mix of annotated and lightweight tags. |
| 220 | |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 221 | Fields that have name-email-date tuple as its value (`author`, |
| 222 | `committer`, and `tagger`) can be suffixed with `name`, `email`, |
| 223 | and `date` to extract the named component. |
| 224 | |
Junio C Hamano | 8fb66e5 | 2011-10-05 20:59:51 | [diff] [blame] | 225 | The complete message in a commit and tag object is `contents`. |
Junio C Hamano | 281fd39 | 2012-09-17 23:57:41 | [diff] [blame] | 226 | Its first line is `contents:subject`, where subject is the concatenation |
| 227 | of all lines of the commit message up to the first blank line. The next |
Junio C Hamano | 1171ab4 | 2017-10-11 06:33:37 | [diff] [blame] | 228 | line is `contents:body`, where body is all of the lines after the first |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 229 | blank line. The optional GPG signature is `contents:signature`. The |
| 230 | first `N` lines of the message is obtained using `contents:lines=N`. |
Junio C Hamano | 52b1cfb | 2016-12-20 00:18:36 | [diff] [blame] | 231 | Additionally, the trailers as interpreted by linkgit:git-interpret-trailers[1] |
Junio C Hamano | 1171ab4 | 2017-10-11 06:33:37 | [diff] [blame] | 232 | are obtained as `trailers` (or by using the historical alias |
| 233 | `contents:trailers`). Non-trailer lines from the trailer block can be omitted |
| 234 | with `trailers:only`. Whitespace-continuations can be removed from trailers so |
| 235 | that each trailer appears on a line by itself with its full content with |
| 236 | `trailers:unfold`. Both can be used together as `trailers:unfold,only`. |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 237 | |
Junio C Hamano | 4e6ba27 | 2016-01-20 23:23:19 | [diff] [blame] | 238 | For sorting purposes, fields with numeric values sort in numeric order |
| 239 | (`objectsize`, `authordate`, `committerdate`, `creatordate`, `taggerdate`). |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 240 | All other fields are used to sort in their byte-value order. |
| 241 | |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 242 | There is also an option to sort by versions, this can be done by using |
| 243 | the fieldname `version:refname` or its alias `v:refname`. |
| 244 | |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 245 | In any case, a field name that refers to a field inapplicable to |
| 246 | the object referred by the ref does not cause an error. It |
| 247 | returns an empty string instead. |
| 248 | |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 249 | As a special case for the date-type fields, you may specify a format for |
Junio C Hamano | 1eb5609 | 2015-10-05 20:39:53 | [diff] [blame] | 250 | the date by adding `:` followed by date format name (see the |
Junio C Hamano | 198b1f1 | 2016-05-17 22:27:24 | [diff] [blame] | 251 | values the `--date` option to linkgit:git-rev-list[1] takes). |
Junio C Hamano | 1b50ce9 | 2007-10-03 12:05:53 | [diff] [blame] | 252 | |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 253 | Some atoms like %(align) and %(if) always require a matching %(end). |
| 254 | We call them "opening atoms" and sometimes denote them as %($open). |
| 255 | |
| 256 | When a scripting language specific quoting is in effect, everything |
| 257 | between a top-level opening atom and its matching %(end) is evaluated |
| 258 | according to the semantics of the opening atom and only its result |
| 259 | from the top-level is quoted. |
| 260 | |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 261 | |
| 262 | EXAMPLES |
| 263 | -------- |
| 264 | |
| 265 | An example directly producing formatted text. Show the most recent |
Junio C Hamano | a8cc1d8 | 2011-03-10 01:18:12 | [diff] [blame] | 266 | 3 tagged commits: |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 267 | |
| 268 | ------------ |
| 269 | #!/bin/sh |
| 270 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 271 | git for-each-ref --count=3 --sort='-*authordate' \ |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 272 | --format='From: %(*authorname) %(*authoremail) |
| 273 | Subject: %(*subject) |
| 274 | Date: %(*authordate) |
| 275 | Ref: %(*refname) |
| 276 | |
| 277 | %(*body) |
| 278 | ' 'refs/tags' |
| 279 | ------------ |
| 280 | |
| 281 | |
| 282 | A simple example showing the use of shell eval on the output, |
Junio C Hamano | a8cc1d8 | 2011-03-10 01:18:12 | [diff] [blame] | 283 | demonstrating the use of --shell. List the prefixes of all heads: |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 284 | ------------ |
| 285 | #!/bin/sh |
| 286 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 287 | git for-each-ref --shell --format="ref=%(refname)" refs/heads | \ |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 288 | while read entry |
| 289 | do |
| 290 | eval "$entry" |
| 291 | echo `dirname $ref` |
| 292 | done |
| 293 | ------------ |
| 294 | |
| 295 | |
| 296 | A bit more elaborate report on tags, demonstrating that the format |
Junio C Hamano | a8cc1d8 | 2011-03-10 01:18:12 | [diff] [blame] | 297 | may be an entire script: |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 298 | ------------ |
| 299 | #!/bin/sh |
| 300 | |
| 301 | fmt=' |
| 302 | r=%(refname) |
| 303 | t=%(*objecttype) |
| 304 | T=${r#refs/tags/} |
| 305 | |
| 306 | o=%(*objectname) |
| 307 | n=%(*authorname) |
| 308 | e=%(*authoremail) |
| 309 | s=%(*subject) |
| 310 | d=%(*authordate) |
| 311 | b=%(*body) |
| 312 | |
| 313 | kind=Tag |
| 314 | if test "z$t" = z |
| 315 | then |
| 316 | # could be a lightweight tag |
| 317 | t=%(objecttype) |
| 318 | kind="Lightweight tag" |
| 319 | o=%(objectname) |
| 320 | n=%(authorname) |
| 321 | e=%(authoremail) |
| 322 | s=%(subject) |
| 323 | d=%(authordate) |
| 324 | b=%(body) |
| 325 | fi |
| 326 | echo "$kind $T points at a $t object $o" |
| 327 | if test "z$t" = zcommit |
| 328 | then |
| 329 | echo "The commit was authored by $n $e |
| 330 | at $d, and titled |
| 331 | |
| 332 | $s |
| 333 | |
| 334 | Its message reads as: |
| 335 | " |
| 336 | echo "$b" | sed -e "s/^/ /" |
| 337 | echo |
| 338 | fi |
| 339 | ' |
| 340 | |
Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 341 | eval=`git for-each-ref --shell --format="$fmt" \ |
Junio C Hamano | ff4b431 | 2006-10-25 22:55:31 | [diff] [blame] | 342 | --sort='*objecttype' \ |
| 343 | --sort=-taggerdate \ |
| 344 | refs/tags` |
| 345 | eval "$eval" |
| 346 | ------------ |
Junio C Hamano | a8cc1d8 | 2011-03-10 01:18:12 | [diff] [blame] | 347 | |
Junio C Hamano | cbe0eb2 | 2017-02-27 23:37:49 | [diff] [blame] | 348 | |
| 349 | An example to show the usage of %(if)...%(then)...%(else)...%(end). |
| 350 | This prefixes the current branch with a star. |
| 351 | |
| 352 | ------------ |
| 353 | git for-each-ref --format="%(if)%(HEAD)%(then)* %(else) %(end)%(refname:short)" refs/heads/ |
| 354 | ------------ |
| 355 | |
| 356 | |
| 357 | An example to show the usage of %(if)...%(then)...%(end). |
| 358 | This prints the authorname, if present. |
| 359 | |
| 360 | ------------ |
| 361 | git for-each-ref --format="%(refname)%(if)%(authorname)%(then) Authored by: %(authorname)%(end)" |
| 362 | ------------ |
| 363 | |
Junio C Hamano | fd98be8 | 2014-01-22 22:45:38 | [diff] [blame] | 364 | SEE ALSO |
| 365 | -------- |
| 366 | linkgit:git-show-ref[1] |
| 367 | |
Junio C Hamano | a8cc1d8 | 2011-03-10 01:18:12 | [diff] [blame] | 368 | GIT |
| 369 | --- |
| 370 | Part of the linkgit:git[1] suite |