From: Junio C Hamano <gitster@pobox.com>
To: Ephrim Khong <dr.khong@gmail.com>
Cc: Johannes Sixt <j6t@kdbg.org>, Duy Nguyen <pclouds@gmail.com>,
GIT Mailing-list <git@vger.kernel.org>
Subject: Re: [PATCH v3] sha1_file: do not add own object directory as alternate
Date: Tue, 15 Jul 2014 12:26:00 -0700 [thread overview]
Message-ID: <xmqqd2d6v2yf.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <53C510A9.4010208@gmail.com> (Ephrim Khong's message of "Tue, 15 Jul 2014 13:29:45 +0200")
Ephrim Khong <dr.khong@gmail.com> writes:
> @@ -320,7 +320,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base, int
> return -1;
> }
> }
> - if (!strcmp(ent->base, objdir)) {
> + if (!strcmp_icase(ent->base, normalized_objdir)) {
Not a problem with your patch, but we should rethink the name of
this function when the code base is more quiet. It always makes me
wonder if it is something similar to strcasecmp(), but in fact it is
not. It is meant to be used *only* for pathnames; pathname_cmp() or
something that has "path" in its name would be appropriate, but it
is wrong to call it "str"-anything.
> @@ -344,6 +344,7 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
> struct string_list entries = STRING_LIST_INIT_NODUP;
> char *alt_copy;
> int i;
> + struct strbuf objdirbuf = STRBUF_INIT;
>
> if (depth > 5) {
> error("%s: ignoring alternate object stores, nesting too deep.",
> @@ -351,6 +352,9 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
> return;
> }
>
> + strbuf_addstr(&objdirbuf, absolute_path(get_object_directory()));
> + normalize_path_copy(objdirbuf.buf, objdirbuf.buf);
This is somewhat a strange usage of a strbuf.
- it relies on that normalize_path_copy() only shrinks, never
lengthens, which is not too bad;
- if the operation ever shrinks, objdirbuf.len becomes
meaningless. The allocated length is objdirbuf.alloc, length
of the string is strlen(objdirbuf.buf).
- abspath.c::absolute_path() is still restricted to PATH_MAX, so
you are not gaining much by using strbuf here.
But at least this patch is not making things any worse, so....
> @@ -361,11 +365,12 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
> error("%s: ignoring relative alternate object store %s",
> relative_base, entry);
> } else {
> - link_alt_odb_entry(entry, relative_base, depth);
> + link_alt_odb_entry(entry, relative_base, depth, objdirbuf.buf);
> }
> }
> string_list_clear(&entries, 0);
> free(alt_copy);
> + strbuf_release(&objdirbuf);
> }
>
> void read_info_alternates(const char * relative_base, int depth)
> diff --git a/t/t7702-repack-cyclic-alternate.sh b/t/t7702-repack-cyclic-alternate.sh
> new file mode 100755
> index 0000000..8341d46
> --- /dev/null
> +++ b/t/t7702-repack-cyclic-alternate.sh
Do we really have to waste a new test file only for this test?
Don't we have any test that already uses alternate that these two
new test pieces can be added to?
$ git grep info/alternates t/
seems to show a few existing ones, including 1450 (fsck) and 7700
(repack) that look very relevant (I didn't check what the tests in
them are about, though).
next prev parent reply other threads:[~2014-07-15 19:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-11 9:37 [Bug] data loss with cyclic alternates Ephrim Khong
2014-07-11 16:01 ` Junio C Hamano
2014-07-11 18:01 ` Keller, Jacob E
2014-07-12 5:57 ` Jeff King
2014-07-14 22:05 ` Keller, Jacob E
2014-07-13 10:44 ` Ephrim Khong
2014-07-14 9:02 ` [PATCH] sha1_file: do not add own object directory as alternate Ephrim Khong
2014-07-14 10:47 ` Duy Nguyen
2014-07-14 12:53 ` [PATCH v2] " Ephrim Khong
2014-07-15 5:44 ` Johannes Sixt
2014-07-15 11:29 ` [PATCH v3] " Ephrim Khong
2014-07-15 19:26 ` Junio C Hamano [this message]
2014-07-16 6:42 ` Ephrim Khong
2014-07-15 19:33 ` Eric Sunshine
2014-07-15 19:48 ` Junio C Hamano
2014-07-16 6:47 ` Ephrim Khong
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=xmqqd2d6v2yf.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=dr.khong@gmail.com \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=pclouds@gmail.com \
/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 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.