git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] [GSOC] cat-file: fix --batch report changed-type bug

From
Jeff King <peff@peff.net>
Date
May 31, 2021, 14:44 UTC
Message-ID
<YLT2UfCZyQIXWIOv@coredump.intra.peff.net>
In-Reply-To
<CAOLTT8Q0zbxh8X03ZmgAzHadTbE4-Af+AB3POOUF2n22u8RExw@mail.gmail.com>
On Mon, May 31, 2021 at 09:20:34PM +0800, ZheNing Hu wrote:
Show 5 quoted lines
> > But I think we'd want to solve it by swapping the two conditionals I
> > showed above, which restores the assumption made in print_object_or_die().
> 
> This method is correct. This will ensure that skip_object_info will not
> be set when print_contents is set.
OK, good, it sounds like we are on the same page. :)
> By the way, maybe we can merge this two "if (opt->all_objects)" block to one.
> [...]

Yes, I think that would make sense to do. It might be worth doing as a separate patch on top of the bug-fix, though, to make it clear that it's just cosmetic and separate from the bug-fix.

Show 13 quoted lines
> > > +test_expect_success 'cat-file --batch="batman" with --batch-all-objects will work' '
> > > +     git -C all-two cat-file --batch-all-objects --batch="%(objectname)" | wc -l >expect &&
> > > +     git -C all-two cat-file --batch-all-objects --batch="batman" | wc -l >actual &&
> > > +     test_cmp expect actual
> > > +'
> >
> > Is it worth testing both of these? The %(objectname) one will fail in
> > the same way (because we do not need to run oid_object_info() to get the
> > oid, which we already have). I'm OK doing both for better coverage, but
> > it may be worth mentioning either in a comment or in the commit message
> > that we expect both to fail, and why.
> 
> Yes, these damages need to be pointed out in the commit message.

I think what confused me here is that you are using "%(objectname)" as the "expect" output, but it also exhibits the bug. So I'd expect this test to pass even before your patch (though I didn't try it).

Really, the symptom of the bug is that _neither_ of those cat-file invocations will exit with a success code. But because they're on the left-hand side of a pipe, we wouldn't even notice.

The simplest test is just:
  git -C all-two cat-file --batch-all-objects --batch="%(objectname)" >/dev/null

which will currently fail. It would be nice to verify that its output is sensible, but I'm not sure how to easily do that (it will spew a bunch of binary tree data, and it cannot even be parsed reliably since we haven't output the sizes).

-Peff
Previous: ZheNing HuNext: ZheNing Hu
Message 4 of 15 in “[GSOC] cat-file: fix --batch report changed-type bug”
  1. [GSOC] cat-file: fix --batch report changed-type bugZheNing Hu via GitGitGadget, May 30, 2021
  2. Jeff KingMay 30, 2021
  3. ZheNing HuMay 31, 2021
  4. Jeff KingMay 31, 2021
  5. ZheNing HuMay 31, 2021
  6. Felipe ContrerasMay 31, 2021
  7. Jeff KingJun 1, 2021
  8. Felipe ContrerasJun 1, 2021
  9. Jeff KingJun 1, 2021
  10. Felipe ContrerasJun 1, 2021
  11. ZheNing HuJun 1, 2021
  12. Junio C HamanoMay 30, 2021
  13. Jeff KingMay 30, 2021
  14. Junio C HamanoJun 1, 2021
  15. ZheNing HuMay 31, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.