Re: [PATCH v2 0/4] cat-file: optionally convert to worktree version
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 24, 2016, 16:09 UTC
- Message-ID
- <xmqqk2f6rvx9.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <cover.1472041389.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 24 quoted lines
> diff --git a/builtin/cat-file.c b/builtin/cat-file.c
> index 5f91cf4..f8a3a08 100644
> --- a/builtin/cat-file.c
> +++ b/builtin/cat-file.c
> @@ -61,6 +61,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
> struct object_info oi = {NULL};
> struct strbuf sb = STRBUF_INIT;
> unsigned flags = LOOKUP_REPLACE_OBJECT;
> + const char *path = force_path;
>
> if (unknown_type)
> flags |= LOOKUP_UNKNOWN_OBJECT;
> @@ -68,6 +69,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
> if (get_sha1_with_context(obj_name, 0, sha1, &obj_context))
> die("Not a valid object name %s", obj_name);
>
> + if (!path)
> + path = obj_context.path;
> + else if (obj_context.mode == S_IFINVALID)
> + obj_context.mode = 0100644;
> +
> buf = NULL;
> switch (opt) {
> case 't':The above two hunks make all the difference in the ease of reading the remainder of the function. Very good.
Show 6 quoted lines
> +test_expect_success '----path=<path> complains without --textconv/--filters' ' > + sha1=$(git rev-parse -q --verify HEAD:world.txt) && > + test_must_fail git cat-file --path=hello.txt blob $sha1 >actual 2>err && > + test ! -s actual && > + grep "path.*needs.*filters" err > +'
This will need to become test_i18ngrep once the error message is made translatable, but it is correct for now. I personally think there is no need to check "actual" or "err", though---just running cat-file under test_must_fail should be sufficient.
Thanks, will queue.