<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/date.c, branch v2.20.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.20.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.20.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-11-07T02:04:06Z</updated>
<entry>
<title>approxidate: fix NULL dereference in date_time()</title>
<updated>2018-11-07T02:04:06Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-11-07T01:12:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=aa097b88e91bd748c4508b042e618e8292e15ad5'/>
<id>urn:sha1:aa097b88e91bd748c4508b042e618e8292e15ad5</id>
<content type='text'>
When we see a time like "noon", we pass "12" to our date_time() helper,
which sets the hour to 12pm. If the current time is before noon, then we
wrap around to yesterday using date_yesterday(). But unlike the normal
calls to date_yesterday() from approxidate_alpha(), we pass a NULL "num"
parameter. Since c27cc94fad (approxidate: handle pending number for
"specials", 2018-11-02), that causes a segfault.

One way to fix this is by checking for NULL. But arguably date_time() is
abusing our helper by passing NULL in the first place (and this is the
only case where one of these "special" parsers is used this way). So
instead, let's have it just do the 1-day subtraction itself. It's still
just a one-liner due to our update_tm() helper.

Note that the test added here is a little funny, as we say "10am noon",
which makes the "10am" seem pointless.  But this bug can only be
triggered when it the currently-parsed hour is before the special time.
The latest special time is "tea" at 1700, but t0006 uses a hard-coded
TEST_DATE_NOW of 1900. We could reset TEST_DATE_NOW, but that may lead
to confusion in other tests. Just saying "10am noon" makes this test
self-contained.

Reported-by: Carlo Arenas &lt;carenas@gmail.com&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>approxidate: handle pending number for "specials"</title>
<updated>2018-11-02T11:49:53Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-11-02T05:23:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c27cc94fad36ba46fea4a031d6df9d45b931f421'/>
<id>urn:sha1:c27cc94fad36ba46fea4a031d6df9d45b931f421</id>
<content type='text'>
The approxidate parser has a table of special keywords like
"yesterday", "noon", "pm", etc. Some of these, like "pm", do
the right thing if we've recently seen a number: "3pm" is
what you'd think.

However, most of them do not look at or modify the
pending-number flag at all, which means a number may "jump"
across a significant keyword and be used unexpectedly. For
example, when parsing:

  January 5th noon pm

we'd connect the "5" to "pm", and ignore it as a
day-of-month. This is obviously a bit silly, as "noon"
already implies "pm". And other mis-parsed things are
generally as silly ("January 5th noon, years ago" would
connect the 5 to "years", but probably nobody would type
that).

However, the fix is simple: when we see a keyword like
"noon", we should flush the pending number (as we would if
we hit another number, or the end of the string). In a few
of the specials that actually modify the day, we can simply
throw away the number (saying "Jan 5 yesterday" should not
respect the number at all).

Note that we have to either move or forward-declare the
static pending_number() to make it accessible to these
functions; this patch moves it.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Replace all die("BUG: ...") calls by BUG() ones</title>
<updated>2018-05-06T10:06:13Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2018-05-02T09:38:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=033abf97fcbc247eabf915780181d947cfb66205'/>
<id>urn:sha1:033abf97fcbc247eabf915780181d947cfb66205</id>
<content type='text'>
In d8193743e08 (usage.c: add BUG() function, 2017-05-12), a new macro
was introduced to use for reporting bugs instead of die(). It was then
subsequently used to convert one single caller in 588a538ae55
(setup_git_env: convert die("BUG") to BUG(), 2017-05-12).

The cover letter of the patch series containing this patch
(cf 20170513032414.mfrwabt4hovujde2@sigill.intra.peff.net) is not
terribly clear why only one call site was converted, or what the plan
is for other, similar calls to die() to report bugs.

Let's just convert all remaining ones in one fell swoop.

This trick was performed by this invocation:

	sed -i 's/die("BUG: /BUG("/g' $(git grep -l 'die("BUG' \*.c)

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/strbuf-addftime-tzname-boolify'</title>
<updated>2017-07-07T01:14:47Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-07-07T01:14:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6ba649e4085bd7b8c80fd2080ca003bf450c9f53'/>
<id>urn:sha1:6ba649e4085bd7b8c80fd2080ca003bf450c9f53</id>
<content type='text'>
strbuf_addftime() is further getting tweaked.

* ab/strbuf-addftime-tzname-boolify:
  strbuf: change an always NULL/"" strbuf_addftime() param to bool
  strbuf.h comment: discuss strbuf_addftime() arguments in order
</content>
</entry>
<entry>
<title>strbuf: change an always NULL/"" strbuf_addftime() param to bool</title>
<updated>2017-07-01T17:47:05Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2017-07-01T13:15:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3b702239d6399685aa69539b83be5f744cfa10e3'/>
<id>urn:sha1:3b702239d6399685aa69539b83be5f744cfa10e3</id>
<content type='text'>
strbuf_addftime() allows callers to pass a time zone name for
expanding %Z. The only current caller either passes the empty string
or NULL, in which case %Z is handed over verbatim to strftime(3).
Replace that string parameter with a flag controlling whether to
remove %Z from the format specification. This simplifies the code.

Commit-message-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/strbuf-addftime-zZ'</title>
<updated>2017-06-22T21:15:25Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-06-22T21:15:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9eafe86d58a2d2b30e8b33f6697519fc7f104443'/>
<id>urn:sha1:9eafe86d58a2d2b30e8b33f6697519fc7f104443</id>
<content type='text'>
As there is no portable way to pass timezone information to
strftime, some output format from "git log" and friends are
impossible to produce.  Teach our own strbuf_addftime to replace %z
and %Z with caller-supplied values to help working around this.

* rs/strbuf-addftime-zZ:
  date: use localtime() for "-local" time formats
  t0006: check --date=format zone offsets
  strbuf: let strbuf_addftime handle %z and %Z itself
</content>
</entry>
<entry>
<title>date: use localtime() for "-local" time formats</title>
<updated>2017-06-15T21:39:15Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-06-15T13:52:17Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6eced3ec5e5d7fbe61de2791e2627b1acf1246b3'/>
<id>urn:sha1:6eced3ec5e5d7fbe61de2791e2627b1acf1246b3</id>
<content type='text'>
When we convert seconds-since-epochs timestamps into a
broken-down "struct tm", we do so by adjusting the timestamp
according to the known offset and then using gmtime() to
break down the result. This means that the resulting struct
"knows" that it's in GMT, even though the time it represents
is adjusted for a different zone. The fields where it stores
this data are not portably accessible, so we have no way to
override them to tell them the real zone info.

For the most part, this works. Our date-formatting routines
don't pay attention to these inaccessible fields, and use
the same tz info we provided for adjustment. The one
exception is when we call strftime(), whose %Z format
reveals this hidden timezone data.

We solved that by always showing the empty string for %Z.
This is allowed by POSIX, but not very helpful to the user.
We can't make this work in the general case, as there's no
portable function for setting an arbitrary timezone (and
anyway, we don't have the zone name for the author zones,
only their offsets).

But for the special case of the "-local" formats, we can
just skip the adjustment and use localtime() instead of
gmtime(). This makes --date=format-local:%Z work correctly,
showing the local timezone instead of an empty string.

The new test checks the result for "UTC", our default
test-lib value for $TZ. Using something like EST5 might be
more interesting, but the actual zone string is
system-dependent (for instance, on my system it expands to
just EST). Hopefully "UTC" is vanilla enough that every
system treats it the same.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>strbuf: let strbuf_addftime handle %z and %Z itself</title>
<updated>2017-06-15T21:34:37Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-06-15T12:29:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c3fbf81a8534cf88ff948d12004eb94929ec1174'/>
<id>urn:sha1:c3fbf81a8534cf88ff948d12004eb94929ec1174</id>
<content type='text'>
There is no portable way to pass timezone information to strftime.  Add
parameters for timezone offset and name to strbuf_addftime and let it
handle the timezone-related format specifiers %z and %Z internally.

Callers can opt out for %Z by passing NULL as timezone name.  %z is
always handled internally -- this helps on Windows, where strftime would
expand it to a timezone name (same as %Z), in violation of POSIX.
Modifiers are not handled, e.g. %Ez is still passed to strftime.

Use an empty string as timezone name in show_date (the only current
caller) for now because we only have the timezone offset in non-local
mode.  POSIX allows %Z to resolve to an empty string in case of missing
information.

Helped-by: Ulrich Mueller &lt;ulm@gentoo.org&gt;
Helped-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>date.c: abort if the system time cannot handle one of our timestamps</title>
<updated>2017-04-27T04:07:40Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2017-04-26T19:29:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e65a982da0e9dd4eac440e82392a8b7c72b3def'/>
<id>urn:sha1:1e65a982da0e9dd4eac440e82392a8b7c72b3def</id>
<content type='text'>
We are about to switch to a new data type for time stamps that is
definitely not smaller or equal, but larger or equal to time_t.

So before using the system functions to process or format timestamps,
let's make extra certain that they can handle what we feed them.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>timestamp_t: a new data type for timestamps</title>
<updated>2017-04-27T04:07:39Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2017-04-26T19:29:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dddbad728c93280fe54ef86699b6d70e2aab44d1'/>
<id>urn:sha1:dddbad728c93280fe54ef86699b6d70e2aab44d1</id>
<content type='text'>
Git's source code assumes that unsigned long is at least as precise as
time_t. Which is incorrect, and causes a lot of problems, in particular
where unsigned long is only 32-bit (notably on Windows, even in 64-bit
versions).

So let's just use a more appropriate data type instead. In preparation
for this, we introduce the new `timestamp_t` data type.

By necessity, this is a very, very large patch, as it has to replace all
timestamps' data type in one go.

As we will use a data type that is not necessarily identical to `time_t`,
we need to be very careful to use `time_t` whenever we interact with the
system functions, and `timestamp_t` everywhere else.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
