[RFC PATCH] date: add --date=elapsed and %aX/%cX placeholders - #2368
[RFC PATCH] date: add --date=elapsed and %aX/%cX placeholders#2368airvzxf wants to merge 1 commit into
Conversation
Welcome to GitGitGadgetHi @airvzxf, and welcome to GitGitGadget, the GitHub App to send patch series to the Git mailing list from GitHub Pull Requests. Please make sure that either:
You can CC potential reviewers by adding a footer to the PR description with the following syntax: NOTE: DO NOT copy/paste your CC list from a previous GGG PR's description, Also, it is a good idea to review the commit messages one last time, as the Git project expects them in a quite specific form:
It is in general a good idea to await the automated test ("Checks") in this Pull Request before contributing the patches, e.g. to avoid trivial issues such as unportable code. Contributing the patchesBefore you can contribute the patches, your GitHub username needs to be added to the list of permitted users. Any already-permitted user can do that, by adding a comment to your PR of the form Both the person who commented An alternative is the channel Once on the list of permitted usernames, you can contribute the patches to the Git mailing list by adding a PR comment If you want to see what email(s) would be sent for a After you submit, GitGitGadget will respond with another comment that contains the link to the cover letter mail in the Git mailing list archive. Please make sure to monitor the discussion in that thread and to address comments and suggestions (while the comments and suggestions will be mirrored into the PR by GitGitGadget, you will still want to reply via mail). If you do not want to subscribe to the Git mailing list just to be able to respond to a mail, you can download the mbox from the Git mailing list archive (click the curl -g --user "<EMailAddress>:<Password>" \
--url "imaps://imap.gmail.com/INBOX" -T /path/to/raw.txtTo iterate on your change, i.e. send a revised patch or patch series, you will first want to (force-)push to the same branch. You probably also want to modify your Pull Request description (or title). It is a good idea to summarize the revision by adding something like this to the cover letter (read: by editing the first comment on the PR, i.e. the PR description): To send a new iteration, just add another PR comment with the contents: Need help?New contributors who want advice are encouraged to join git-mentoring@googlegroups.com, where volunteers who regularly contribute to Git are willing to answer newbie questions, give advice, or otherwise provide mentoring to interested contributors. You must join in order to post or view messages, but anyone can join. You may also be able to find help in real time in the developer IRC channel, |
|
@airvzxf please note that the PR description will be sent as kind of a "cover letter" between the diffstat and the patch. It is quite lengthy, and you will see that other PRs in this repository use much more succinct descriptions. Please consider condensing it dramatically (and maybe write it yourself instead of letting an LLM do that, as an LLM-generated cover letter will most likely scare away any potential reviewer, or worse, elicit angry responses?). |
|
/allow |
|
User airvzxf is now allowed to use GitGitGadget. |
The --date=human format and the %cr/%ch placeholders both produce a localized English phrase that hides the precise amount of time that has passed. A commit shown as "2 days ago" may in reality be 1 day 3 hours, or 1 day 23 hours. Switching to %ct and a calculator solves the problem but is not glance-friendly. Add an uptime(1)-style elapsed-time format: --date=elapsed --date=elapsed-pad 39s 39s 8h 7m 48s 08h 07m 48s 1y 11M 5d 13h 5m 13s 01y 11M 05d 13h 05m 13s The placeholder letter is X because the obvious choice E is already used for the mailmap-respecting email variants (%aE, %cE, %gE). Signed-off-by: Israel Roldan <israel.alberto.rv@gmail.com>
1f46741 to
48da106
Compare
|
/preview |
|
Preview email sent as pull.2368.git.git.1785389946001.gitgitgadget@gmail.com |
|
/preview |
|
Preview email sent as pull.2368.git.git.1785394693090.gitgitgadget@gmail.com |
|
/submit |
|
Submitted as pull.2368.git.git.1785394879459.gitgitgadget@gmail.com To fetch this version into To fetch this version to local tag |
Motivation
The
--date=humanformat and the%cr/%chplaceholders both producea localized English phrase that hides the precise amount of time
that has passed. A commit shown as "2 days ago" may in reality be
1 day 3 hours, or 1 day 23 hours. Switching to %ct and a calculator
solves the problem but is not glance-friendly.
The closest external tool that solves the same problem is
git-log-compactby Kyle J. McKay (2016), which the maintainerdeclined to merge into Git core because it was a heavyweight change
to the oneline output rather than a date format.
What this patch adds
A new date format
--date=elapsedand--date=elapsed-padmodelledon
uptime(1):The padded variant zero-pads every emitted unit to at least two digits.
A commit timestamp that is in the future is reported as "0s", not the
localized phrase "in the future" that
show_date_relative()emits.Months are fixed at 30 days and years at 365 days, matching the
uptime(1)convention. They are consistent, and the same approximationsare already in use by Git's own
show_date_relative()for therelative-time format.
Two new pretty-format placeholders,
%aX(author) and%cX(committer):The placeholders mirror
%chand%cr, which also ignore the caller's--date=and emit a fixed shape.Open questions
Q1. The placeholder letter. The natural mnemonic is
E(Elapsed), but
%aE,%cEand%gEare already taken(mailmap-respecting email variants). This patch uses
Xas a freeletter. Would the maintainer prefer a different letter? I am not
attached to
X.Q2. Should
--date=elapsed-padbe its own format name, or aseparate
--date=elapsedplus a flag? Which mirrors--date=human/--date=human-local/--date=iso/--date=iso-local.Q3. The "future timestamp" behaviour. This patch clamps a future
timestamp to "0s". An alternative would be to keep the relative
format's "in the future" wording.
Q4.
%aX/%cXare hard-coded compact; padded output requires%ad/%cdtogether with--date=elapsed-pad. Should apaired
%aY/%cYfor padded also exist, or is theasymmetry acceptable?
Patch
The patch modifies the existing
date_mode_typeenum, adds a newshow_date_elapsed()helper indate.c, wires it throughshow_date()andparse_date_format(), exposes two placeholdersvia
format_person_part()inpretty.c, handles the new format inbuiltin/blame.cfor column width, updates the documentation, andadds tests for both the date helper and the pretty-format
placeholder equivalence.
The full patch is attached below.
Testing
$ make DEVELOPER=1 && cd t &&
prove --no-color ./t0006-date.sh ./t4205-log-pretty-formats.sh
./t0006-date.sh ................ ok
./t4205-log-pretty-formats.sh .. ok
All tests successful.
The full test suite (1054 test files, 33832 tests) also passes on
this machine.
Thanks for your time. I am happy to iterate on any of the open
questions before posting a non-RFC version.