OSDN Git Service
(root)
/
git-core
/
git.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'js/win32-lazyload-dll'
[git-core/git.git]
/
sha1_file.c
diff --git
a/sha1_file.c
b/sha1_file.c
index
b4a67bb
..
5a20148
100644
(file)
--- a/
sha1_file.c
+++ b/
sha1_file.c
@@
-398,7
+398,7
@@
static const char *parse_alt_odb_entry(const char *string,
return end;
}
return end;
}
-static void link_alt_odb_entries(const char *alt, int
len, int
sep,
+static void link_alt_odb_entries(const char *alt, int sep,
const char *relative_base, int depth)
{
struct strbuf objdirbuf = STRBUF_INIT;
const char *relative_base, int depth)
{
struct strbuf objdirbuf = STRBUF_INIT;
@@
-427,28
+427,19
@@
static void link_alt_odb_entries(const char *alt, int len, int sep,
static void read_info_alternates(const char * relative_base, int depth)
{
static void read_info_alternates(const char * relative_base, int depth)
{
- char *map;
- size_t mapsz;
- struct stat st;
char *path;
char *path;
-
int fd
;
+
struct strbuf buf = STRBUF_INIT
;
path = xstrfmt("%s/info/alternates", relative_base);
path = xstrfmt("%s/info/alternates", relative_base);
- fd = git_open(path);
- free(path);
- if (fd < 0)
- return;
- if (fstat(fd, &st) || (st.st_size == 0)) {
- close(fd);
+ if (strbuf_read_file(&buf, path, 1024) < 0) {
+ warn_on_fopen_errors(path);
+ free(path);
return;
}
return;
}
- mapsz = xsize_t(st.st_size);
- map = xmmap(NULL, mapsz, PROT_READ, MAP_PRIVATE, fd, 0);
- close(fd);
-
- link_alt_odb_entries(map, mapsz, '\n', relative_base, depth);
- munmap(map, mapsz);
+ link_alt_odb_entries(buf.buf, '\n', relative_base, depth);
+ strbuf_release(&buf);
+ free(path);
}
struct alternate_object_database *alloc_alt_odb(const char *dir)
}
struct alternate_object_database *alloc_alt_odb(const char *dir)
@@
-503,7
+494,7
@@
void add_to_alternates_file(const char *reference)
if (commit_lock_file(lock))
die_errno("unable to move new alternates file into place");
if (alt_odb_tail)
if (commit_lock_file(lock))
die_errno("unable to move new alternates file into place");
if (alt_odb_tail)
- link_alt_odb_entries(reference,
strlen(reference),
'\n', NULL, 0);
+ link_alt_odb_entries(reference, '\n', NULL, 0);
}
free(alts);
}
}
free(alts);
}
@@
-516,7
+507,7
@@
void add_to_alternates_memory(const char *reference)
*/
prepare_alt_odb();
*/
prepare_alt_odb();
- link_alt_odb_entries(reference,
strlen(reference),
'\n', NULL, 0);
+ link_alt_odb_entries(reference, '\n', NULL, 0);
}
/*
}
/*
@@
-619,7
+610,7
@@
void prepare_alt_odb(void)
if (!alt) alt = "";
alt_odb_tail = &alt_odb_list;
if (!alt) alt = "";
alt_odb_tail = &alt_odb_list;
- link_alt_odb_entries(alt,
strlen(alt),
PATH_SEP, NULL, 0);
+ link_alt_odb_entries(alt, PATH_SEP, NULL, 0);
read_info_alternates(get_object_directory(), 0);
}
read_info_alternates(get_object_directory(), 0);
}
@@
-1850,7
+1841,7
@@
int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
int read_pack_header(int fd, struct pack_header *header)
{
int read_pack_header(int fd, struct pack_header *header)
{
- if (read_in_full(fd, header, sizeof(*header))
<
sizeof(*header))
+ if (read_in_full(fd, header, sizeof(*header))
!=
sizeof(*header))
/* "eof before pack header was fully read" */
return PH_ERROR_EOF;
/* "eof before pack header was fully read" */
return PH_ERROR_EOF;