git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Hui <Hui.Wang@windriver.com>
To: <gitster@pobox.com>, <git@vger.kernel.org>, <tali@admingilde.org>
Subject: [PATCH v2 4/5] sha1_file: remove relative entries limitation
Date: Tue, 6 Sep 2011 18:24:04 +0800	[thread overview]
Message-ID: <1315304645-12009-5-git-send-email-Hui.Wang@windriver.com> (raw)
In-Reply-To: <1315304645-12009-4-git-send-email-Hui.Wang@windriver.com>

From: Hui Wang <Hui.Wang@windriver.com>

link_alt_odb_entries() will be called recursively if alternates has
valid object store paths, to avoid nesting too deep, the recursive
depth is limited to 5, this limitation is reasonable and safe for
dead-loop reference situation.

There is another limitation in this function to only permit the 1st
level alternates has relative paths, the purpose of this limitation
is to avoid inaccurate result when using memcmp() directly to compare
two directory path names, e.g. "./a/b/" and "./a/c/e/../../b" should
be the same dir, but memcmp() will report they are different dirs,
this will introduce the same dir be added twice or dead-loop
reference.

Now we have new method to compare two directories and can handle both
absolute path and relative path comparison, in addition to we already
have max depth 5 limitation, we can safely remove this limitation.

Moreover removing this limitation will make below two usage workable.

usage1: base-repos has relative path in the alternates
        %>git clone --reference base-repos src dest
usage2: src2 has relative path to point src1, src1 has relative path
	to point src
        %>git clone src2 dest

Signed-off-by: Hui Wang <Hui.Wang@windriver.com>
---
 sha1_file.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index 18f7fb3..98fdb0a 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -329,15 +329,10 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
 		}
 		while (cp < ep && *cp != sep)
 			cp++;
-		if (last != cp) {
-			if (!is_absolute_path(last) && depth) {
-				error("%s: ignoring relative alternate object store %s",
-						relative_base, last);
-			} else {
-				link_alt_odb_entry(last, cp - last,
-						relative_base, depth);
-			}
-		}
+		if (last != cp)
+			link_alt_odb_entry(last, cp - last,
+					relative_base, depth);
+
 		while (cp < ep && *cp == sep)
 			cp++;
 		last = cp;
-- 
1.6.3.1

  reply	other threads:[~2011-09-06 10:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-06 10:24 [PATCH v2 0/5] sha1_file: remove only current repository can have relative path limitation Wang Hui
2011-09-06 10:24 ` [PATCH v2 1/5] sha1_file cleanup: remove redundant variable check Wang Hui
2011-09-06 10:24   ` [PATCH v2 2/5] sha1_file: remove a buggy value setting Wang Hui
2011-09-06 10:24     ` [PATCH v2 3/5] sha1_file: improve directories comparison method Wang Hui
2011-09-06 10:24       ` Wang Hui [this message]
2011-09-06 10:24         ` [PATCH v2 5/5] t5710: add testcase for multi-level relative alternates Wang Hui
2011-09-06 16:32       ` [PATCH v2 3/5] sha1_file: improve directories comparison method Junio C Hamano
2011-09-06 16:26     ` [PATCH v2 2/5] sha1_file: remove a buggy value setting Junio C Hamano
2011-09-07  9:55       ` wanghui
2011-09-06 16:59   ` [PATCH v2 1/5] sha1_file cleanup: remove redundant variable check Junio C Hamano
2011-09-07 10:24     ` wanghui

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=1315304645-12009-5-git-send-email-Hui.Wang@windriver.com \
    --to=hui.wang@windriver.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tali@admingilde.org \
    /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).