diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-05-25 11:26:38 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-05-25 11:26:38 -0700 |
commit | 69e82602b9a5a01bc225d9b4e7a65a9daba506cb (patch) | |
tree | a1fbafe5fb22f2d96e782a0833b9c2b70c4aea31 | |
parent | 98eb3fc6cbdede41809e29166ddad4edf6acd1f4 (diff) | |
parent | 5e73633dbf8a62190611f6eb438a1a2eaaffa919 (diff) | |
download | git-69e82602b9a5a01bc225d9b4e7a65a9daba506cb.tar.gz |
Merge branch 'hv/submodule-alt-odb' into maint
When a submodule repository uses alternate object store mechanism, some
commands that were started from the superproject did not notice it and
failed with "No such object" errors. The subcommands of "git submodule"
command that recursed into the submodule in a separate process were OK;
only the ones that cheated and peeked directly into the submodule's
repository from the primary process were affected.
By Heiko Voigt
* hv/submodule-alt-odb:
teach add_submodule_odb() to look for alternates
-rw-r--r-- | cache.h | 1 | ||||
-rw-r--r-- | sha1_file.c | 3 | ||||
-rw-r--r-- | submodule.c | 3 | ||||
-rwxr-xr-x | t/t4041-diff-submodule-option.sh | 34 |
4 files changed, 39 insertions, 2 deletions
@@ -992,6 +992,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 4f06a0e450..f615fc7206 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -228,7 +228,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); /* @@ -353,7 +352,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 9a28060679..b63978a161 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); diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh index bf9a7526bd..6c01d0c056 100755 --- a/t/t4041-diff-submodule-option.sh +++ b/t/t4041-diff-submodule-option.sh @@ -458,4 +458,38 @@ EOF test_cmp expected actual ' +test_expect_success 'diff --submodule with objects referenced by alternates' ' + 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 && + sha1_before=$(git rev-parse --short HEAD) + echo b >b && + git add b && + git commit -m b + sha1_after=$(git rev-parse --short HEAD) + echo "Submodule sub $sha1_before..$sha1_after: + > b" >../expected + ) && + (cd super && + (cd sub && + git fetch && + git checkout origin/master + ) && + git diff --submodule > ../actual + ) + test_cmp expected actual +' + test_done |