<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/object-name.c, branch v2.36.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.36.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.36.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2022-02-25T23:47:36Z</updated>
<entry>
<title>Merge branch 'ab/date-mode-release'</title>
<updated>2022-02-25T23:47:36Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-02-25T23:47:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0a01df08c03fe707e22795de7bd1d763ed02e9e1'/>
<id>urn:sha1:0a01df08c03fe707e22795de7bd1d763ed02e9e1</id>
<content type='text'>
Plug (some) memory leaks around parse_date_format().

* ab/date-mode-release:
  date API: add and use a date_mode_release()
  date API: add basic API docs
  date API: provide and use a DATE_MODE_INIT
  date API: create a date.h, split from cache.h
  cache.h: remove always unused show_date_human() declaration
</content>
</entry>
<entry>
<title>Merge branch 'ab/ambiguous-object-name'</title>
<updated>2022-02-25T23:47:33Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2022-02-25T23:47:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=268e6b8d4d95d9ade705666e152a4c054da32a47'/>
<id>urn:sha1:268e6b8d4d95d9ade705666e152a4c054da32a47</id>
<content type='text'>
Error output given in response to an ambiguous object name has been
improved.

* ab/ambiguous-object-name:
  object-name: re-use "struct strbuf" in show_ambiguous_object()
  object-name: iterate ambiguous objects before showing header
  object-name: show date for ambiguous tag objects
  object-name: make ambiguous object output translatable
  object-name: explicitly handle bad tags in show_ambiguous_object()
  object-name: explicitly handle OBJ_BAD in show_ambiguous_object()
  object-name tests: add tests for ambiguous object blind spots
</content>
</entry>
<entry>
<title>date API: create a date.h, split from cache.h</title>
<updated>2022-02-16T17:40:00Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-02-16T08:14:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=88c7b4c3c8d51510d20ebb9990750ad0e97afbfb'/>
<id>urn:sha1:88c7b4c3c8d51510d20ebb9990750ad0e97afbfb</id>
<content type='text'>
Move the declaration of the date.c functions from cache.h, and adjust
the relevant users to include the new date.h header.

The show_ident_date() function belonged in pretty.h (it's defined in
pretty.c), its two users outside of pretty.c didn't strictly need to
include pretty.h, as they get it indirectly, but let's add it to them
anyway.

Similarly, the change to "builtin/{fast-import,show-branch,tag}.c"
isn't needed as far as the compiler is concerned, but since they all
use the "DATE_MODE()" macro we now define in date.h, let's have them
include it.

We could simply include this new header in "cache.h", but as this
change shows these functions weren't common enough to warrant
including in it in the first place. By moving them out of cache.h
changes to this API will no longer cause a (mostly) full re-build of
the project when "make" is run.

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>object-name: re-use "struct strbuf" in show_ambiguous_object()</title>
<updated>2022-01-27T20:09:34Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-01-27T05:26:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=3a73c1dfafcc53831a252fc3aededeb59be476f1'/>
<id>urn:sha1:3a73c1dfafcc53831a252fc3aededeb59be476f1</id>
<content type='text'>
Reduce the allocations done by show_ambiguous_object() by moving the
"desc" strbuf into the "struct ambiguous_output" introduced in the
preceding commit.

This doesn't matter for optimization purposes, but since we're
accumulating a "struct strbuf advice" anyway let's follow that pattern
and add a "struct strbuf sb", we can then strbuf_reset() it rather
than calling strbuf_release() for each call to
show_ambiguous_object().

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>object-name: iterate ambiguous objects before showing header</title>
<updated>2022-01-27T20:09:34Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-01-27T05:26:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d2ef3cb7e29c35362125a61f1d96576c200076f6'/>
<id>urn:sha1:d2ef3cb7e29c35362125a61f1d96576c200076f6</id>
<content type='text'>
Change the "The candidates are" header that's shown for ambiguous
objects to be shown after we've iterated over all of the objects.

If we get any errors while doing so we don't want to split up the the
header and the list as a result. The two will now be printed together,
as shown in the updated testcase.

As we're accumulating the lines into as "struct strbuf" before
emitting them we need to add a trailing newline to the call in
show_ambiguous_object(). This and the change from "The candidates
are:" to "The candidates are:\n%s" helps to give translators more
context.

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>object-name: show date for ambiguous tag objects</title>
<updated>2022-01-27T20:09:33Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-01-27T05:26:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=851b3d7671778b74e40bf155c49f6b045f5eb4df'/>
<id>urn:sha1:851b3d7671778b74e40bf155c49f6b045f5eb4df</id>
<content type='text'>
Make the ambiguous tag object output nicer in the case of tag objects
such as ebf3c04b262 (Git 2.32, 2021-06-06) by including the date in
the "tagger" header. I.e.:

    $ git rev-parse b7e68
    error: short object ID b7e68 is ambiguous
    hint: The candidates are:
    hint:   b7e68c41d92 tag 2021-06-06 - v2.32.0
    hint:   b7e68ae18e0 commit 2019-12-23 - bisect: use the standard 'if (!var)' way to check for 0
    hint:   b7e68f6b413 tree
    hint:   b7e68490b97 blob
    b7e68
    [...]

Before this we'd emit a "tag" line without a date, e.g.:

    hint:   b7e68c41d92 tag v2.32.0

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>object-name: make ambiguous object output translatable</title>
<updated>2022-01-27T20:09:33Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-01-27T05:26:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ba5e8a0eb8011f7ffb246804e91c9ba0db3befe4'/>
<id>urn:sha1:ba5e8a0eb8011f7ffb246804e91c9ba0db3befe4</id>
<content type='text'>
Change the output of show_ambiguous_object() added in [1] and last
tweaked in [2] and the preceding commit to be more friendly to
translators.

By being able to customize the "&lt;SP&gt;&lt;SP&gt;%s\n" format we're even ready
for RTL languages, who'd presumably like to change that to
"%s&lt;SP&gt;&lt;SP&gt;\n".

In the case of the existing "tag [tag could not be parsed]" output
we'll now instead emit "[bad tag, could not parse it]". This is
consistent with the "[bad object]" output. Rephrasing the message like
this is possible because we're not unconditionally adding the
type_name() at the beginning.

1. 1ffa26c461 (get_short_sha1: list ambiguous objects on error,
   2016-09-26)
2. 5cc044e0257 (get_short_oid: sort ambiguous objects by type,
   then SHA-1, 2018-05-10)

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Josh Steadmon &lt;steadmon@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>object-name: explicitly handle bad tags in show_ambiguous_object()</title>
<updated>2022-01-27T20:09:33Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-01-27T05:26:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=667a560be7ae977e61d81ca4bcb95ded1cdacc9c'/>
<id>urn:sha1:667a560be7ae977e61d81ca4bcb95ded1cdacc9c</id>
<content type='text'>
Follow-up the handling of OBJ_BAD in the preceding commit and
explicitly handle those cases where parse_tag() fails, or we don't end
up with a non-NULL pointer in in tag-&gt;tag.

If we run into such a tag we'd previously be silent about it. We
really should also be handling these batter in parse_tag_buffer() by
being more eager to emit an error(), instead of silently aborting with
"return -1;".

One example of such a tag is the one that's tested for in
"t3800-mktag.sh", where the code takes the "size &lt;
the_hash_algo-&gt;hexsz + 24" branch.

But in lieu of earlier missing "error" output let's show the user
something to indicate why we're not showing a tag message in these
cases, now instead of showing:

    hint:   deadbeef tag

We'll instead display:

    hint:   deadbeef tag [tag could not be parsed]

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>object-name: explicitly handle OBJ_BAD in show_ambiguous_object()</title>
<updated>2022-01-27T20:09:33Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-01-27T05:26:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=6780e6804087a89bddfb0333171d005b309941a1'/>
<id>urn:sha1:6780e6804087a89bddfb0333171d005b309941a1</id>
<content type='text'>
Amend the "unknown type" handling in the code that displays the
ambiguous object list to assert() that we're either going to get the
"real" object types we can pass to type_name(), or a -1 (OBJ_BAD)
return value from oid_object_info().

See [1] for the current output, and [1] for the commit that added the
"unknown type" handling.

We are never going to get an "unknown type" in the sense of custom
types crafted with "hash-object --literally", since we're not using
the OBJECT_INFO_ALLOW_UNKNOWN_TYPE flag.

If we manage to otherwise unpack such an object without errors we'll
die() in parse_loose_header_extended() called by sort_ambiguous()
before we get to show_ambiguous_object(), as is asserted by the test
added in the preceding commit.

So saying "unknown type" here was always misleading, we really meant
to say that we had a failure parsing the object at all, i.e. that we
had repository corruption. If the problem is only that it's type is
unknown we won't reach this code.

So let's emit a generic "[bad object]" instead. As our tests added in
the preceding commit show, we'll have emitted various "error" output
already in those cases.

We should do better in the truly "unknown type" cases, which we'd need
to handle if we were passing down the OBJECT_INFO_ALLOW_UNKNOWN_TYPE
flag. But let's leave that for some future improvement. In a
subsequent commit I'll improve the output we do show, and not having
to handle the "unknown type" (as in OBJECT_INFO_ALLOW_UNKNOWN_TYPE)
simplifies that change.

1. 5cc044e0257 (get_short_oid: sort ambiguous objects by type,
   then SHA-1, 2018-05-10)
2. 1ffa26c461 (get_short_sha1: list ambiguous objects on error,
   2016-09-26)

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>cat-file: use GET_OID_ONLY_TO_DIE in --(textconv|filters)</title>
<updated>2021-12-30T21:05:29Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-12-28T13:28:50Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=245b948815048821e73edc1a2b4224eaa94a8fc0'/>
<id>urn:sha1:245b948815048821e73edc1a2b4224eaa94a8fc0</id>
<content type='text'>
Change the cat_one_file() logic that calls get_oid_with_context()
under --textconv and --filters to use the GET_OID_ONLY_TO_DIE flag,
thus improving the error messaging emitted when e.g. &lt;path&gt; is missing
but &lt;rev&gt; is not.

To service the "cat-file" use-case we need to introduce a new
"GET_OID_REQUIRE_PATH" flag, otherwise it would exit early as soon as
a valid "HEAD" was resolved, but in the "cat-file" case being changed
we always need a valid revision and path.

This arguably makes the "&lt;bad rev&gt;:&lt;bad path&gt;" and "&lt;bad
rev&gt;:&lt;good (in HEAD) path&gt;" use cases worse, as we won't quote the
&lt;path&gt; component at the user anymore, but let's just use the existing
logic "git log" et al use for now. We can improve the messaging for
those cases as a follow-up for all callers.

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>
</feed>
