From: Christian Couder <christian.couder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Joey Hess <joey@kitenet.net>, git <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] drop support for "experimental" loose objects
Date: Fri, 22 Nov 2013 12:04:01 +0100 [thread overview]
Message-ID: <CAP8UFD1fMTrJGo9Z4+jdWqc-=UmPG1jQjwTij4962WDoh_a1DA@mail.gmail.com> (raw)
In-Reply-To: <20131122095801.GB12042@sigill.intra.peff.net>
On Fri, Nov 22, 2013 at 10:58 AM, Jeff King <peff@peff.net> wrote:
> On Thu, Nov 21, 2013 at 09:19:25PM +0100, Christian Couder wrote:
>
>> Yeah, I think it might report wrong size in case of replaced objects
>> for example.
>> I looked at that following Junio's comment about the
>> sha1_object_info() API, which,
>> unlike read_sha1_file() API, does not interact with the "replace" mechanism:
>>
>> http://thread.gmane.org/gmane.comp.version-control.git/234023/
>>
>> I started to work on a patch about this but didn't take the time to
>> finish and post it.
>
> That seems kind of crazy. Would the fix be as simple as this:
>
> diff --git a/sha1_file.c b/sha1_file.c
> index 10676ba..a051d6c 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -2529,6 +2529,8 @@ int sha1_object_info_extended(const unsigned char *sha1, struct object_info *oi)
> struct pack_entry e;
> int rtype;
>
> + sha1 = lookup_replace_object(sha1);
> +
> co = find_cached_object(sha1);
> if (co) {
> if (oi->typep)
>
> or do we need some way for callers to turn off replacement? I notice
> that read_sha1_file has such a feature, but it is only used in one
> place.
Yeah, indeed, I asked myself such a question and that's why it is not
so simple unfortunately.
In "sha1_file.c", there is:
void *read_sha1_file_extended(const unsigned char *sha1,
enum object_type *type,
unsigned long *size,
unsigned flag)
{
void *data;
char *path;
const struct packed_git *p;
const unsigned char *repl = (flag & READ_SHA1_FILE_REPLACE)
? lookup_replace_object(sha1) : sha1;
errno = 0;
data = read_object(repl, type, size);
...
And in cache.h, there is:
#define READ_SHA1_FILE_REPLACE 1
static inline void *read_sha1_file(const unsigned char *sha1, enum
object_type *type, unsigned long *size)
{
return read_sha1_file_extended(sha1, type, size,
READ_SHA1_FILE_REPLACE);
}
So the READ_SHA1_FILE_REPLACE is a way to disable replacement at compile time.
But in my opinion if we want such a knob, we should use it when we set
the "read_replace_refs" global variable.
For example with something like this:
diff --git a/environment.c b/environment.c
index 0a15349..7c99af8 100644
--- a/environment.c
+++ b/environment.c
@@ -44,7 +44,7 @@ const char *editor_program;
const char *askpass_program;
const char *excludes_file;
enum auto_crlf auto_crlf = AUTO_CRLF_FALSE;
-int read_replace_refs = 1; /* NEEDSWORK: rename to use_replace_refs */
+int read_replace_refs = READ_SHA1_FILE_REPLACE; /* NEEDSWORK: rename
to use_replace_refs */
enum eol core_eol = EOL_UNSET;
enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
@Junio what would you think about such a change?
> I guess we would need to audit all the sha1_object_info callers.
Yeah but when I looked at them, there were not many that looked dangerous.
Thanks,
Christian.
next prev parent reply other threads:[~2013-11-22 11:04 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-20 20:33 corrupt object memory allocation error Joey Hess
2013-11-20 21:33 ` Jeff King
2013-11-20 22:28 ` Joey Hess
2013-11-21 11:41 ` [PATCH] drop support for "experimental" loose objects Jeff King
2013-11-21 11:48 ` Jeff King
2013-11-21 12:43 ` Duy Nguyen
2013-11-21 14:42 ` Keshav Kini
2013-11-21 22:41 ` Jeff King
2013-11-21 19:44 ` Junio C Hamano
2013-11-23 0:24 ` Jonathan Nieder
2013-11-23 0:30 ` Jeff King
2013-11-23 0:47 ` Jonathan Nieder
2013-11-21 16:04 ` Joey Hess
2013-11-21 20:19 ` Christian Couder
2013-11-22 9:58 ` Jeff King
2013-11-22 11:04 ` Christian Couder [this message]
2013-11-22 11:24 ` Jeff King
2013-11-22 14:23 ` Christian Couder
2013-11-22 16:15 ` Jeff King
2013-11-22 17:23 ` Junio C Hamano
2013-11-22 2:09 ` Jeff King
2013-11-22 17:28 ` Joey Hess
2013-11-24 8:44 ` Jeff King
2013-11-24 9:07 ` Jeff King
2013-11-25 18:35 ` Junio C Hamano
2013-11-27 9:30 ` Jeff King
2013-11-27 18:57 ` Junio C Hamano
2013-11-27 19:03 ` Jeff King
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='CAP8UFD1fMTrJGo9Z4+jdWqc-=UmPG1jQjwTij4962WDoh_a1DA@mail.gmail.com' \
--to=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=joey@kitenet.net \
--cc=peff@peff.net \
/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
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;
as well as URLs for NNTP newsgroup(s).