summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-07-21 11:18:46 -0700
committerJunio C Hamano <gitster@pobox.com>2014-07-21 11:18:46 -0700
commita8c565b227b408cb2ff2064482d2259df16e9e52 (patch)
treeb9617bbb33abcafa5177518b673a6d7b56e497d2 /sha1_file.c
parent9b1c2a3a8e625ea7f56e9ba3d3c0e31938faa738 (diff)
parent539e75069f5c8f0ecf9e99f1163647aa9f92c5bd (diff)
downloadgit-a8c565b227b408cb2ff2064482d2259df16e9e52.tar.gz
Merge branch 'ek/alt-odb-entry-fix'
* ek/alt-odb-entry-fix: sha1_file: do not add own object directory as alternate
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 4127ae138d..ea6150892a 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -268,9 +268,9 @@ static struct alternate_object_database **alt_odb_tail;
* SHA1, an extra slash for the first level indirection, and the
* terminating NUL.
*/
-static int link_alt_odb_entry(const char *entry, const char *relative_base, int depth)
+static int link_alt_odb_entry(const char *entry, const char *relative_base,
+ int depth, const char *normalized_objdir)
{
- const char *objdir = get_object_directory();
struct alternate_object_database *ent;
struct alternate_object_database *alt;
int pfxlen, entlen;
@@ -321,7 +321,7 @@ static int link_alt_odb_entry(const char *entry, const char *relative_base, int
return -1;
}
}
- if (!strcmp(ent->base, objdir)) {
+ if (!strcmp_icase(ent->base, normalized_objdir)) {
free(ent);
return -1;
}
@@ -345,6 +345,7 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
struct string_list entries = STRING_LIST_INIT_NODUP;
char *alt_copy;
int i;
+ struct strbuf objdirbuf = STRBUF_INIT;
if (depth > 5) {
error("%s: ignoring alternate object stores, nesting too deep.",
@@ -352,6 +353,9 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
return;
}
+ strbuf_addstr(&objdirbuf, absolute_path(get_object_directory()));
+ normalize_path_copy(objdirbuf.buf, objdirbuf.buf);
+
alt_copy = xmemdupz(alt, len);
string_list_split_in_place(&entries, alt_copy, sep, -1);
for (i = 0; i < entries.nr; i++) {
@@ -362,11 +366,12 @@ static void link_alt_odb_entries(const char *alt, int len, int sep,
error("%s: ignoring relative alternate object store %s",
relative_base, entry);
} else {
- link_alt_odb_entry(entry, relative_base, depth);
+ link_alt_odb_entry(entry, relative_base, depth, objdirbuf.buf);
}
}
string_list_clear(&entries, 0);
free(alt_copy);
+ strbuf_release(&objdirbuf);
}
void read_info_alternates(const char * relative_base, int depth)