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

Re: [PATCH v7 4/4] t1006: add tests for git cat-file --literally

From
karthik nayak <karthik.188@gmail.com>
Date
Apr 8, 2015, 17:42 UTC
Message-ID
<5525689F.5040306@gmail.com>
In-Reply-To
<CAPig+cQ8SqtjRHRp=po0uXHWp3TFDXBsu5W6EUTs=ZWtR-br1A@mail.gmail.com>
On 04/08/2015 02:19 AM, Eric Sunshine wrote:
Show 47 quoted lines
> On Sat, Apr 4, 2015 at 1:44 AM, Karthik Nayak <karthik.188@gmail.com> wrote:
> > Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
> > ---
> > diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> > index ab36b1e..5b74044 100755
> > --- a/t/t1006-cat-file.sh
> > +++ b/t/t1006-cat-file.sh
> > @@ -47,6 +47,18 @@ $content"
> >          test_cmp expect actual
> >       '
> >
> > +    test_expect_success "Type of $type is correct using --literally" '
> > +       echo $type >expect &&
> > +       git cat-file -t --literally $sha1 >actual &&
> > +       test_cmp expect actual
> > +    '
> > +
> > +    test_expect_success "Size of $type is correct using --literally" '
> > +       echo $size >expect &&
> > +       git cat-file -s --literally $sha1 >actual &&
> > +       test_cmp expect actual
> > +    '
> > +
> >       test -z "$content" ||
> >       test_expect_success "Content of $type is correct" '
> >          maybe_remove_timestamp "$content" $no_ts >expect &&
> > @@ -296,4 +308,19 @@ test_expect_success '%(deltabase) reports packed delta bases' '
> >          }
> >   '
> >
> > +bogus_type="bogus"
> > +bogus_sha1=$(git hash-object -t $bogus_type --literally -w --stdin </dev/null)
> > +
> > +test_expect_success "Type of broken object is correct" '
> > +       echo $bogus_type >expect &&
> > +       git cat-file -t --literally $bogus_sha1 >actual &&
> > +       test_cmp expect actual
> > +'
> > +
> > +test_expect_success "Size of broken object is correct" '
> > +       echo "0" >expect &&
>
> Zero is such a common fallback value when things go wrong that it may
> not be the best choice for this test. Consequently, it might be better
> to create the bogus object with non-zero length. Take a look at how
> 'hello_length' and 'hello_sha1' are computed elsewhere in this script
> for inspiration.

The first part of this patch contains tests which make use of 'hello_length' adn 'hello_sha1', but I get what you're saying, will look into it. Thanks.

Show 8 quoted lines
>
> > +       git cat-file -s --literally $bogus_sha1 >actual &&
> > +       test_cmp expect actual
> > +'
> > +
> >   test_done
> > --
> > 2.4.0.rc1.249.g9f2ee54
Previous: Eric SunshineNext: Eric Sunshine
Message 17 of 19 in “cat-file: teach cat-file a '--literally' option”
  1. 0/4 cat-file: teach cat-file a '--literally' optionkarthik nayak, Apr 4, 2015
  2. 1/4 sha1_file.c: support reading from a loose object of unknown typeKarthik Nayak, Apr 4, 2015
  3. Junio C HamanoApr 4, 2015
  4. karthik nayakApr 4, 2015
  5. Junio C HamanoApr 5, 2015
  6. karthik nayakApr 5, 2015
  7. Junio C HamanoApr 5, 2015
  8. karthik nayakApr 7, 2015
  9. 1/4 sha1_file.c: support reading from a loose object of unknown typeKarthik Nayak, Apr 5, 2015
  10. Eric SunshineApr 7, 2015
  11. 2/4 cat-file: teach cat-file a '--literally' optionKarthik Nayak, Apr 4, 2015
  12. Eric SunshineApr 7, 2015
  13. 3/4 cat-file: add documentation for '--literally' option.Karthik Nayak, Apr 4, 2015
  14. Eric SunshineApr 7, 2015
  15. 4/4 t1006: add tests for git cat-file --literallyKarthik Nayak, Apr 4, 2015
  16. Eric SunshineApr 7, 2015
  17. karthik nayakApr 8, 2015
  18. Eric SunshineApr 8, 2015
  19. Karthik NayakApr 9, 2015

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.