Re: [PATCH 09/23] fsck: unify object-name code
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 24, 2019, 06:05 UTC
- Message-ID
- <xmqq8spafzjt.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20191018045613.GI17879@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> +/* > + * Subsystem for storing human-readable names for each object. > + * > + * If fsck_enable_object_names() has not been called, all other functions are > + * noops.
I think it is clear from the context that put_ and get_ we see below refer to functions whose true names have fsck_ prefix, but the fact that this one has fsck_ spelled out disrupts that context.
IOW, s/fsck_// for consistency, perhaps.
Show 31 quoted lines
> + * Use put_object_name() to seed initial names (e.g. from refnames); the fsck
> + * code will extend that while walking trees, etc.
> + *
> + * Use get_object_name() to get a single name (or NULL if none). Or the more
> + * convenient describe_object(), which always produces an output string with
> + * the oid combined with the name (if any). Note that the return value points
> + * to a rotating array of static buffers, and may be invalidated by a
> + * subsequent call.
> + */
> +void fsck_enable_object_names(struct fsck_options *options);
> +const char *fsck_get_object_name(struct fsck_options *options,
> + struct object *obj);
> +__attribute__((format (printf,3,4)))
> +void fsck_put_object_name(struct fsck_options *options, struct object *obj,
> + const char *fmt, ...);
> +const char *fsck_describe_object(struct fsck_options *options,
> + struct object *obj);
> +
> #endif
> diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
> index 50d28e6fdb..7c7ff7e961 100755
> --- a/t/t1450-fsck.sh
> +++ b/t/t1450-fsck.sh
> @@ -616,7 +616,7 @@ test_expect_success 'fsck --name-objects' '
> remove_object $(git rev-parse julius:caesar.t) &&
> test_must_fail git fsck --name-objects >out &&
> tree=$(git rev-parse --verify julius:) &&
> - test_i18ngrep -E "$tree \((refs/heads/master|HEAD)@\{[0-9]*\}:" out
> + test_i18ngrep "$tree (refs/tags/julius:" out
> )
> '