From: Junio C Hamano <gitster@pobox•com>
To: karthik nayak <karthik.188@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH v3 2/3] sha1_file: implement changes for "cat-file --literally -t"
Date: Fri, 06 Mar 2015 11:28:59 -0800 [thread overview]
Message-ID: <xmqq1tl2ylfo.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <54F9E6B6.4070105@gmail.com> (karthik nayak's message of "Fri, 06 Mar 2015 23:11:10 +0530")
karthik nayak <karthik.188@gmail•com> writes:
>> ... I suspect that the caller should supply a pointer to struct
>> object_info, i.e. something along these lines:
>>
>> struct object_info oi = { NULL };
>> struct strbuf sb = STRBUF_INIT;
>> enum object_type type;
>>
>> ...
>>
>> oi.typename = &sb;
>> sha1_object_info_literally(sha1, &oi);
>> if (!sb.len)
>> that is an error;
>> else
>> use sb.buf as the name;
>>
>> strbuf_release(&sb);
> I thought I could get the calling function "cat_one_file()" to send
> the address to a struct strbuf. Like this ..
>
> struct strbuf sb = STRBUF_INIT;
> length = sha1_object_info_literally(sha1, &sb);
> if (length < 0)
> die("git cat-file --literally -t %s: failed",
> obj_name);
> printf("%s\n", sb.buf);
> strbuf_release(&sb);
> return 0;
>
> What do you think? Is this ok?
When I gave you $gmane/264420, I was actually hoping that we do not
have to have "object-info-literally" helper at all, and instead the
caller in cat-file that deals with "-t" option can become something
like this:
struct object_info oi = { NULL };
struct strbuf typename = STRBUF_INIT;
unsigned flags = LOOKUP_REPLACE_OBJECT;
if (doing the --literally stuff)
flags |= LOOKUP_LITERALLY;
...
switch (...) {
case 't':
oi.typename = &typename;
sha1_object_info_extended(sha1, &oi, flags);
if (typename.len) {
printf("%s\n", typename.buf);
return 0;
}
break;
...
The change illustrated in $gmane/264420 is probably incomplete and
some calls from the sha1_object_info_extended() after that change
may still need to be tweaked to pay attention to LOOKUP_LITERALLY
bit (e.g. parse_sha1_header() may want to learn not to barf when
seeing an unexpected typename in the header when the caller asks to
look up "literally").
next prev parent reply other threads:[~2015-03-06 19:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 18:16 [PATCH v3 0/3] cat-file: add "--literally" option karthik nayak
2015-03-05 18:18 ` [PATCH v3 1/3] cache: modify for "cat-file --literally -t" Karthik Nayak
2015-03-08 22:25 ` Eric Sunshine
2015-03-09 12:56 ` karthik nayak
2015-03-05 18:19 ` [PATCH v3 2/3] sha1_file: implement changes " Karthik Nayak
2015-03-05 23:45 ` Junio C Hamano
2015-03-06 17:41 ` karthik nayak
2015-03-06 19:28 ` Junio C Hamano [this message]
2015-03-07 10:04 ` karthik nayak
2015-03-08 8:09 ` Junio C Hamano
2015-03-08 8:48 ` karthik nayak
2015-03-08 9:03 ` Junio C Hamano
2015-03-08 10:49 ` karthik nayak
2015-03-08 19:09 ` Junio C Hamano
2015-03-09 13:08 ` karthik nayak
2015-03-05 18:19 ` [PATCH v3 3/3] cat-file: add "--literally" option Karthik Nayak
2015-03-08 22:50 ` Eric Sunshine
2015-03-09 12:53 ` karthik nayak
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=xmqq1tl2ylfo.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=karthik.188@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox