Re: [PATCH v3 3/4] parse_commit(): handle broken whitespace-only timestamp
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Apr 27, 2023, 11:55 UTC
- Message-ID
- <ad4f927f-607a-5391-ce50-a342d09934d6@gmail.com>
- In-Reply-To
- <a04e7950-b74e-d43f-4d19-86def079748c@gmail.com>
On 27/04/2023 11:11, Phillip Wood wrote:
Show 9 quoted lines
>> + test_commit 1234567890 && >> + git cat-file commit HEAD >commit.orig && >> + sed "s/>.*/> /" <commit.orig >commit.munge && >> + ws_commit=$(git hash-object --literally -w -t commit >> commit.munge) && >> + sed "s/>.*/> $(printf "\013")/" <commit.orig >commit.munge && > > Does the shell eat the '\v' when it trims trailing whitespace from the > command substitution (I can't remember the rules off the top of my head)?
Having looked it up, the shell trims newlines but not other whitespace so this should be fine.
Best Wishes
Phillip
Show 34 quoted lines
> > Best Wishes > > Phillip > >> + vt_commit=$(git hash-object --literally -w -t commit commit.munge) >> +' >> + >> +test_expect_success '--until treats whitespace date as sentinel' ' >> + echo $ws_commit >expect && >> + git rev-list --until=1980-01-01 $ws_commit >actual && >> + test_cmp expect actual && >> + >> + echo $vt_commit >expect && >> + git rev-list --until=1980-01-01 $vt_commit >actual && >> + test_cmp expect actual >> +' >> + >> +test_expect_success 'pretty-printer handles whitespace date' ' >> + # as with the %ad test above, we will show these as the empty >> string, >> + # not the 1970 epoch date. This is intentional; see 7d9a281941 >> (t4212: >> + # test bogus timestamps with git-log, 2014-02-24) for more >> discussion. >> + echo : >expect && >> + git log -1 --format="%at:%ct" $ws_commit >actual && >> + test_cmp expect actual && >> + git log -1 --format="%at:%ct" $vt_commit >actual && >> + test_cmp expect actual >> +' >> + >> test_done >