]> git.ipfire.org Git - thirdparty/git.git/commit - object-name.c
object-name: mark unused parameters in disambiguate callbacks
authorJeff King <peff@peff.net>
Fri, 24 Feb 2023 06:38:30 +0000 (01:38 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 24 Feb 2023 17:13:29 +0000 (09:13 -0800)
commit07ffb954b3421f78c5789477a540d400bbe647a2
treeadcf7d2f4b7681df30acdcecd8e92382868d830a
parent74595cca21a41e4be6ca8d578d805b70b7653e98
object-name: mark unused parameters in disambiguate callbacks

The object-name disambiguation code triggers a callback for each
possible object id we find. This is really used for two purposes:

  - "hint" functions like disambiguate_commit_only report back on
    whether the value is usable

  - iterator functions like repo_for_each_abbrev() use it to collect
    and report matching names.

Compiling with -Wunused-parameter generates several warnings, but
they're distinct for each type. The "hint" functions never look at the
void cb_data pointer; they only care whether the oid matches our hint.
The iterator functions never look at the "struct repository" parameter;
they're just reporting back the oids they see, and always return 0.

So arguably these could be two separate interfaces:

  int (*hint)(struct repository *r, const struct object_id *oid);
  void (*iter)(const struct object_id *oid, void *cb_data);

But doing so would complicate the disambiguation code, which now has to
accept and call the two different types. Since we can easily squelch the
compiler warnings by annotating the functions, let's just do that.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
object-name.c