All of lore.kernel.org
 help / color / mirror / Atom feed
From: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Christian Couder <christian.couder@gmail.com>,
	Hariom Verma <hariom18599@gmail.com>, Jeff King <peff@peff.net>,
	Felipe Contreras <felipe.contreras@gmail.com>,
	ZheNing Hu <adlternative@gmail.com>
Subject: [PATCH v2 0/2] [GSOC] cat-file: fix --batch report changed-type bug
Date: Thu, 03 Jun 2021 16:29:24 +0000	[thread overview]
Message-ID: <pull.967.v2.git.1622737766.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.967.git.1622558157.gitgitgadget@gmail.com>

Change from last version:

 1. Modified the test structure under the recommendation of Peff.
 2. Use clearer and more concise commit message help by Peff.

ZheNing Hu (2):
  [GSOC] cat-file: handle trivial --batch format with
    --batch-all-objects
  [GSOC] cat-file: merge two block into one

 builtin/cat-file.c  | 10 ++++------
 t/t1006-cat-file.sh | 22 ++++++++++++++++++++++
 2 files changed, 26 insertions(+), 6 deletions(-)


base-commit: 5d5b1473453400224ebb126bf3947e0a3276bdf5
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-967%2Fadlternative%2Fcat-file-batch-bug-fix-v2-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-967/adlternative/cat-file-batch-bug-fix-v2-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/967

Range-diff vs v1:

 1:  495cd90dbaf4 ! 1:  4af3b958dd05 [GSOC] cat-file: fix --batch report changed-type bug
     @@ Metadata
      Author: ZheNing Hu <adlternative@gmail.com>
      
       ## Commit message ##
     -    [GSOC] cat-file: fix --batch report changed-type bug
     +    [GSOC] cat-file: handle trivial --batch format with --batch-all-objects
      
     -    When `--batch` used with `--batch-all-objects`,
     -    with some format atoms like %(objectname), %(rest)
     -    or even no atoms may cause Git exit and report
     -    "object xxx changed type!?".
     +    The --batch code to print an object assumes we found out the type of
     +    the object from calling oid_object_info_extended(). This is true for
     +    the default format, but even in a custom format, we manually modify
     +    the object_info struct to ask for the type.
      
     -    E.g. `git cat-file --batch="batman" --batch-all-objects`
     +    This assumption was broken by 845de33a5b (cat-file: avoid noop calls
     +    to sha1_object_info_extended, 2016-05-18). That commit skips the call
     +    to oid_object_info_extended() entirely when --batch-all-objects is in
     +    use, and the custom format does not include any placeholders that
     +    require calling it.
      
     -    This is because we did not get the object type through
     -    oid_object_info_extended(), it's composed of two
     -    situations:
     +    Or when the custom format only include placeholders like %(objectname) or
     +    %(rest), oid_object_info_extended() will not get the type of the object.
      
     -    1. Since object_info is empty, skip_object_info is
     -    set to true, We skipped collecting the object type.
     +    This results in an error when we try to confirm that the type didn't
     +    change:
      
     -    2. The formatting atom like %(objectname) does not require
     -    oid_object_info_extended() to collect object types.
     +    $ git cat-file --batch=batman --batch-all-objects
     +    batman
     +    fatal: object 000023961a0c02d6e21dc51ea3484ff71abf1c74 changed type!?
      
     -    The correct way to deal with it is to swap the order
     -    of setting skip_object_info and setting typep. This
     -    will ensure that we must get the type of the object
     -    when using --batch.
     +    and also has other subtle effects (e.g., we'd fail to stream a blob,
     +    since we don't realize it's a blob in the first place).
     +
     +    We can fix this by flipping the order of the setup. The check for "do
     +    we need to get the object info" must come _after_ we've decided
     +    whether we need to look up the type.
      
          Helped-by: Jeff King <peff@peff.net>
          Signed-off-by: ZheNing Hu <adlternative@gmail.com>
     @@ t/t1006-cat-file.sh: test_expect_success 'cat-file --unordered works' '
       	test_cmp expect actual
       '
       
     ++test_expect_success 'set up object list for --batch-all-objects tests' '
     ++	git -C all-two cat-file --batch-all-objects --batch-check="%(objectname)" >objects
     ++'
     ++
      +test_expect_success 'cat-file --batch="%(objectname)" with --batch-all-objects will work' '
     -+	git -C all-two cat-file --batch-all-objects --batch-check="%(objectname)" >objects &&
      +	git -C all-two cat-file --batch="%(objectname)" <objects >expect &&
      +	git -C all-two cat-file --batch-all-objects --batch="%(objectname)" >actual &&
      +	cmp expect actual
 2:  f02c1144d916 ! 2:  759451e784de  [GSOC] cat-file: merge two block into one
     @@ Metadata
      Author: ZheNing Hu <adlternative@gmail.com>
      
       ## Commit message ##
     -     [GSOC] cat-file: merge two block into one
     +    [GSOC] cat-file: merge two block into one
      
     -     Because the two "if (opt->all_objects)" block
     -     are redundant, merge them into one, to provide
     -     better readability.
     +    There are two "if (opt->all_objects)" blocks next
     +    to each other, merge them into one to provide better
     +    readability.
      
          Helped-by: Jeff King <peff@peff.net>
          Signed-off-by: ZheNing Hu <adlternative@gmail.com>

-- 
gitgitgadget

  parent reply	other threads:[~2021-06-03 16:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 14:35 [PATCH " ZheNing Hu via GitGitGadget
2021-06-01 14:35 ` [PATCH 1/2] " ZheNing Hu via GitGitGadget
2021-06-01 15:52   ` Jeff King
2021-06-02 13:15     ` ZheNing Hu
2021-06-02 20:00       ` Jeff King
2021-06-03  6:28         ` ZheNing Hu
2021-06-03  7:18         ` ZheNing Hu
2021-06-03 19:28           ` Jeff King
2021-06-01 14:35 ` [PATCH 2/2] [GSOC] cat-file: merge two block into one ZheNing Hu via GitGitGadget
2021-06-01 15:55   ` Jeff King
2021-06-02 13:27     ` ZheNing Hu
2021-06-03 16:29 ` ZheNing Hu via GitGitGadget [this message]
2021-06-03 16:29   ` [PATCH v2 1/2] [GSOC] cat-file: handle trivial --batch format with --batch-all-objects ZheNing Hu via GitGitGadget
2021-06-03 16:29   ` [PATCH v2 2/2] [GSOC] cat-file: merge two block into one ZheNing Hu via GitGitGadget
2021-06-03 19:29   ` [PATCH v2 0/2] [GSOC] cat-file: fix --batch report changed-type bug Jeff King
2021-06-03 22:51   ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.967.v2.git.1622737766.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=adlternative@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hariom18599@gmail.com \
    --cc=peff@peff.net \
    --subject='Re: [PATCH v2 0/2] [GSOC] cat-file: fix --batch report changed-type bug' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.