From: Heiko Voigt <hvoigt@hvoigt.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Orgad and Raizel Shaneh <orgads@gmail.com>,
git@vger.kernel.org, Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: git-diff-tree does not use alternate objects for submodules
Date: Sun, 13 May 2012 19:23:25 +0200 [thread overview]
Message-ID: <20120513172301.GA58961@book.hvoigt.net> (raw)
In-Reply-To: <7vwr4lotjl.fsf@alter.siamese.dyndns.org>
Hi,
On Wed, May 09, 2012 at 03:53:34PM -0700, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > Heiko Voigt <hvoigt@hvoigt.net> writes:
> > ...
> >> I will have a look if I can come up with something that reads the
> >> submodules alternate config and uses it. Do you have other config
> >> related things in mind that might be missing?
> >
> > No, I do not, and that is exactly the point.
> >
> > Making the process that works in the top-level superproject to imitate
> > what would happen if the processing happened inside the submodule is what
> > invited a bug like this. Who knows what other discrepancies remain there.
> >
> > If we forked a separate process,...
>
> Having said all that, we seem to have come too far and it is probably too
> painful to revert the approach to contaminate the obj_hash (in object.c),
> the set of refs (in refs.c) and the like in the top-level superproject
> process with data borrowed from submodules repository [*1*]. So not only
> I do not mind seeing you try solving it inside the superproject process, I
> would appreciate and encourage the attempt. One thing to be careful about
> is relative paths stored in the objects/info/alternates; they are relative
> to the object database of the repository the "alternates" is specified,
> not relative to the superproject that happens to contain the submodule.
>
> Thanks.
Here is the simplest approach I could think of (not sure if its maybe
too simple). On first sight it seems to work (even if I exchange the
absolute path in alternates with a relative one.
Please see below.
Cheers Heiko
I used the following setup to test:
mkdir sub_alt &&
(cd sub_alt &&
git init &&
echo a >a &&
git add a &&
git commit -m a) &&
mkdir super &&
(cd super &&
git clone -s ../sub_alt sub &&
git init &&
git add sub &&
git commit -m "sub a") &&
(cd sub_alt &&
echo b >b &&
git add b &&
git commit -m b) &&
(cd super &&
(cd sub &&
git fetch &&
git checkout origin/master) &&
git diff --submodule
)
-8<--
From: Heiko Voigt <hvoigt@hvoigt.net>
Subject: [PATCH] teach add_submodule_odb() to look for alternates
Since we allow to link other object databases when loading a submodules
database we should also load possible alternates.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
cache.h | 1 +
sha1_file.c | 3 +--
submodule.c | 3 +++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/cache.h b/cache.h
index e14ffcd..cc5048c 100644
--- a/cache.h
+++ b/cache.h
@@ -947,6 +947,7 @@ extern struct alternate_object_database {
char base[FLEX_ARRAY]; /* more */
} *alt_odb_list;
extern void prepare_alt_odb(void);
+extern void read_info_alternates(const char * relative_base, int depth);
extern void add_to_alternates_file(const char *reference);
typedef int alt_odb_fn(struct alternate_object_database *, void *);
extern void foreach_alt_odb(alt_odb_fn, void*);
diff --git a/sha1_file.c b/sha1_file.c
index 3c4f165..4ccaf7a 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -229,7 +229,6 @@ char *sha1_pack_index_name(const unsigned char *sha1)
struct alternate_object_database *alt_odb_list;
static struct alternate_object_database **alt_odb_tail;
-static void read_info_alternates(const char * alternates, int depth);
static int git_open_noatime(const char *name);
/*
@@ -354,7 +353,7 @@ static void link_alt_odb_entries(const char *alt, const char *ep, int sep,
}
}
-static void read_info_alternates(const char * relative_base, int depth)
+void read_info_alternates(const char * relative_base, int depth)
{
char *map;
size_t mapsz;
diff --git a/submodule.c b/submodule.c
index 784b580..959d349 100644
--- a/submodule.c
+++ b/submodule.c
@@ -63,6 +63,9 @@ static int add_submodule_odb(const char *path)
alt_odb->name[40] = '\0';
alt_odb->name[41] = '\0';
alt_odb_list = alt_odb;
+
+ /* add possible alternates from the submodule */
+ read_info_alternates(objects_directory.buf, 0);
prepare_alt_odb();
done:
strbuf_release(&objects_directory);
--
1.7.10.1.491.gc66153e
next prev parent reply other threads:[~2012-05-13 17:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-08 13:42 git-diff-tree does not use alternate objects for submodules Orgad and Raizel Shaneh
2012-05-08 15:36 ` Junio C Hamano
2012-05-08 15:37 ` Junio C Hamano
2012-05-09 21:58 ` Heiko Voigt
2012-05-09 22:19 ` Junio C Hamano
2012-05-09 22:53 ` Junio C Hamano
2012-05-13 17:23 ` Heiko Voigt [this message]
2012-05-13 22:13 ` Heiko Voigt
2012-05-14 16:24 ` [PATCH v2] teach add_submodule_odb() to look for alternates Heiko Voigt
2012-05-14 16:49 ` git-diff-tree does not use alternate objects for submodules Junio C Hamano
2012-05-14 17:51 ` Heiko Voigt
2012-05-14 18:03 ` Junio C Hamano
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=20120513172301.GA58961@book.hvoigt.net \
--to=hvoigt@hvoigt.net \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=orgads@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 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).