git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: David Turner <dturner@twosigma.com>
Subject: [PATCH 2/6] sha1_file: always allow relative paths to alternates
Date: Fri, 30 Sep 2016 15:36:05 -0400	[thread overview]
Message-ID: <20160930193604.hqspizasfpqa6bez@sigill.intra.peff.net> (raw)
In-Reply-To: <20160930193533.ynbepaago6oycg5t@sigill.intra.peff.net>

We recursively expand alternates repositories, so that if A
borrows from B which borrows from C, A can see all objects.

For the root object database, we allow relative paths, so A
can point to B as "../B/objects". However, we currently do
not allow relative paths when recursing, so B must use an
absolute path to reach C.

That is an ancient protection from c2f493a (Transitively
read alternatives, 2006-05-07) that tries to avoid adding
the same alternate through two different paths. But since
5bdf0a8 (sha1_file: normalize alt_odb path before comparing
and storing, 2011-09-07), we use a normalized absolute path
for each alt_odb entry.

So this protection is no longer necessary; we will detect
the duplicate no matter how we got there.  And it's a good
idea to get rid of it, as it creates an unnecessary
complication when setting up recursive alternates (B has to
know that A is going to borrow from it and make sure to use
an absolute path).

We adjust the test script here to demonstrate that this now
works. Unfortunately, we can't demonstrate that the
duplicate is suppressed, since it has no user-visible
behavior (it's just one less place for our object lookups to
go). But you can verify it manually via gdb, with something
like:

    for i in a b c; do
            git init --bare $i
            blob=$(echo $i | git -C $i hash-object -w --stdin)
    done
    echo "../../b/objects" >a/objects/info/alternates
    echo "../../c/objects" >>a/objects/info/alternates
    echo "../../c/objects" >b/objects/info/alternates
    gdb --args git cat-file -e $blob

After prepare_alt_odb() runs, we have only a single copy of
"/path/to/c/objects/" in the alt_odb list.

Signed-off-by: Jeff King <peff@peff.net>
---
 sha1_file.c               | 7 +------
 t/t5613-info-alternate.sh | 4 ++--
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/sha1_file.c b/sha1_file.c
index b9c1fa3..9a79c19 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -343,12 +343,7 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
 		const char *entry = entries.items[i].string;
 		if (entry[0] == '\0' || entry[0] == '#')
 			continue;
-		if (!is_absolute_path(entry) && depth) {
-			error("%s: ignoring relative alternate object store %s",
-					relative_base, entry);
-		} else {
-			link_alt_odb_entry(entry, relative_base, depth, objdirbuf.buf);
-		}
+		link_alt_odb_entry(entry, relative_base, depth, objdirbuf.buf);
 	}
 	string_list_clear(&entries, 0);
 	free(alt_copy);
diff --git a/t/t5613-info-alternate.sh b/t/t5613-info-alternate.sh
index 9cd2626..b429707 100755
--- a/t/t5613-info-alternate.sh
+++ b/t/t5613-info-alternate.sh
@@ -102,9 +102,9 @@ test_valid_repo'
 cd "$base_dir"
 
 test_expect_success \
-    'that relative alternate is only possible for current dir' '
+    'that relative alternate is recursive' '
     cd D &&
-    ! (test_valid_repo)
+    test_valid_repo
 '
 
 cd "$base_dir"
-- 
2.10.0.618.g82cc264


  parent reply	other threads:[~2016-09-30 19:36 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30 19:35 [PATCH 0/6] receive-pack: quarantine pushed objects Jeff King
2016-09-30 19:35 ` [PATCH 1/6] check_connected: accept an env argument Jeff King
2016-09-30 19:36 ` Jeff King [this message]
2016-10-02  9:07   ` [PATCH 2/6] sha1_file: always allow relative paths to alternates René Scharfe
2016-10-02 13:03     ` Jeff King
2016-10-02 15:38     ` Jeff King
2016-10-02 16:59       ` Jeff King
2016-09-30 19:36 ` [PATCH 3/6] tmp-objdir: introduce API for temporary object directories Jeff King
2016-09-30 21:25   ` Junio C Hamano
2016-09-30 22:13     ` Jeff King
2016-09-30 21:32   ` David Turner
2016-09-30 22:44     ` Jeff King
2016-09-30 23:07       ` David Turner
2016-09-30 19:36 ` [PATCH 4/6] receive-pack: quarantine objects until pre-receive accepts Jeff King
2016-10-01  9:12   ` Jeff King
2017-04-08 14:53     ` Ævar Arnfjörð Bjarmason
2017-04-10 21:14       ` Jeff King
2016-09-30 19:36 ` [PATCH 5/6] tmp-objdir: put quarantine information in the environment Jeff King
2016-09-30 19:36 ` [PATCH 6/6] tmp-objdir: do not migrate files starting with '.' Jeff King
2016-10-02  9:20 ` [PATCH 0/6] receive-pack: quarantine pushed objects Christian Couder
2016-10-02 13:02   ` Jeff King
2016-10-03  6:45     ` Christian Couder
2016-10-03 20:48 ` [PATCH v2 0/5] " Jeff King
2016-10-03 20:49   ` [PATCH v2 1/5] check_connected: accept an env argument Jeff King
2016-10-05 19:01     ` Jakub Narębski
2016-10-05 19:06       ` Jeff King
2016-10-03 20:49   ` [PATCH v2 2/5] tmp-objdir: introduce API for temporary object directories Jeff King
2016-10-03 20:49   ` [PATCH v2 3/5] receive-pack: quarantine objects until pre-receive accepts Jeff King
2016-10-03 20:49   ` [PATCH v2 4/5] tmp-objdir: put quarantine information in the environment Jeff King
2016-10-03 20:49   ` [PATCH v2 5/5] tmp-objdir: do not migrate files starting with '.' Jeff King
2016-10-03 21:25   ` [PATCH v2 0/5] receive-pack: quarantine pushed objects Junio C Hamano
2016-10-03 21:28     ` 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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160930193604.hqspizasfpqa6bez@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=dturner@twosigma.com \
    --cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).