Merge branch 'jk/alt-odb-cleanup'

Codepaths involved in interacting alternate object store have
been cleaned up.

* jk/alt-odb-cleanup:
  alternates: use fspathcmp to detect duplicates
  sha1_file: always allow relative paths to alternates
  count-objects: report alternates via verbose mode
  fill_sha1_file: write into a strbuf
  alternates: store scratch buffer as strbuf
  fill_sha1_file: write "boring" characters
  alternates: use a separate scratch space
  alternates: encapsulate alt->base munging
  alternates: provide helper for allocating alternate
  alternates: provide helper for adding to alternates list
  link_alt_odb_entry: refactor string handling
  link_alt_odb_entry: handle normalize_path errors
  t5613: clarify "too deep" recursion tests
  t5613: do not chdir in main process
  t5613: whitespace/style cleanups
  t5613: use test_must_fail
  t5613: drop test_valid_repo function
  t5613: drop reachable_via function
This commit is contained in:
Junio C Hamano
2016-10-17 13:25:19 -07:00
12 changed files with 319 additions and 233 deletions

View File

@ -492,20 +492,16 @@ static int add_possible_reference_from_superproject(
{
struct submodule_alternate_setup *sas = sas_cb;
/* directory name, minus trailing slash */
size_t namelen = alt->name - alt->base - 1;
struct strbuf name = STRBUF_INIT;
strbuf_add(&name, alt->base, namelen);
/*
* If the alternate object store is another repository, try the
* standard layout with .git/modules/<name>/objects
*/
if (ends_with(name.buf, ".git/objects")) {
if (ends_with(alt->path, ".git/objects")) {
char *sm_alternate;
struct strbuf sb = STRBUF_INIT;
struct strbuf err = STRBUF_INIT;
strbuf_add(&sb, name.buf, name.len - strlen("objects"));
strbuf_add(&sb, alt->path, strlen(alt->path) - strlen("objects"));
/*
* We need to end the new path with '/' to mark it as a dir,
* otherwise a submodule name containing '/' will be broken
@ -533,7 +529,6 @@ static int add_possible_reference_from_superproject(
strbuf_release(&sb);
}
strbuf_release(&name);
return 0;
}