diff options
author | Victoria Dye <vdye@github.com> | 2024-02-08 01:57:19 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-02-07 21:33:37 -0800 |
commit | 46176d77c9e0b219a78d64cb99d8dbf4d9bcde2d (patch) | |
tree | 92e90882f3a31f6104345813c3ed18ba3cbfc713 /Documentation/git-for-each-ref.txt | |
parent | 235986be822c9f8689be2e9a0b7804d0b1b6d821 (diff) | |
download | git-46176d77c9e0b219a78d64cb99d8dbf4d9bcde2d.tar.gz |
ref-filter.c: sort formatted dates by byte value
Update the ref sorting functions of 'ref-filter.c' so that when date fields
are specified with a format string (such as in 'git for-each-ref
--sort=creatordate:<something>'), they are sorted by their formatted string
value rather than by the underlying numeric timestamp. Currently, date
fields are always sorted by timestamp, regardless of whether formatting
information is included in the '--sort' key.
Leaving the default (unformatted) date sorting unchanged, sorting by the
formatted date string adds some flexibility to 'for-each-ref' by allowing
for behavior like "sort by year, then by refname within each year" or "sort
by time of day". Because the inclusion of a format string previously had no
effect on sort behavior, this change likely will not affect existing usage
of 'for-each-ref' or other ref listing commands.
Additionally, update documentation & tests to document the new sorting
mechanism.
Signed-off-by: Victoria Dye <vdye@github.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/git-for-each-ref.txt')
-rw-r--r-- | Documentation/git-for-each-ref.txt | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index be9543f684..3a9ad91b7a 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -359,9 +359,11 @@ In any case, a field name that refers to a field inapplicable to the object referred by the ref does not cause an error. It returns an empty string instead. -As a special case for the date-type fields, you may specify a format for -the date by adding `:` followed by date format name (see the -values the `--date` option to linkgit:git-rev-list[1] takes). +As a special case for the date-type fields, you may specify a format for the +date by adding `:` followed by date format name (see the values the `--date` +option to linkgit:git-rev-list[1] takes). If this formatting is provided in +a `--sort` key, references will be sorted according to the byte-value of the +formatted string rather than the numeric value of the underlying timestamp. Some atoms like %(align) and %(if) always require a matching %(end). We call them "opening atoms" and sometimes denote them as %($open). |