зеркало из https://github.com/microsoft/git.git
index_fd(): pass optional path parameter as hint for blob conversion
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Родитель
edaec3fbe8
Коммит
53bca91a7d
2
cache.h
2
cache.h
|
@ -190,7 +190,7 @@ extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
|
|||
extern int ce_match_stat(struct cache_entry *ce, struct stat *st, int);
|
||||
extern int ce_modified(struct cache_entry *ce, struct stat *st, int);
|
||||
extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
|
||||
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type);
|
||||
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
|
||||
extern int read_pipe(int fd, char** return_buf, unsigned long* return_size);
|
||||
extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);
|
||||
extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
|
||||
|
|
|
@ -15,7 +15,7 @@ static void hash_object(const char *path, enum object_type type, int write_objec
|
|||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0 ||
|
||||
fstat(fd, &st) < 0 ||
|
||||
index_fd(sha1, fd, &st, write_object, type))
|
||||
index_fd(sha1, fd, &st, write_object, type, path))
|
||||
die(write_object
|
||||
? "Unable to add %s to database"
|
||||
: "Unable to hash %s", path);
|
||||
|
|
|
@ -59,7 +59,7 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st)
|
|||
|
||||
if (fd >= 0) {
|
||||
unsigned char sha1[20];
|
||||
if (!index_fd(sha1, fd, st, 0, OBJ_BLOB))
|
||||
if (!index_fd(sha1, fd, st, 0, OBJ_BLOB, ce->name))
|
||||
match = hashcmp(sha1, ce->sha1);
|
||||
/* index_fd() closed the file descriptor already */
|
||||
}
|
||||
|
|
|
@ -2054,7 +2054,7 @@ int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
|
|||
}
|
||||
|
||||
int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
|
||||
enum object_type type)
|
||||
enum object_type type, const char *path)
|
||||
{
|
||||
unsigned long size = st->st_size;
|
||||
void *buf;
|
||||
|
@ -2074,7 +2074,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
|
|||
if (type == OBJ_BLOB) {
|
||||
unsigned long nsize = size;
|
||||
char *nbuf = buf;
|
||||
if (convert_to_git(NULL, &nbuf, &nsize)) {
|
||||
if (convert_to_git(path, &nbuf, &nsize)) {
|
||||
if (size)
|
||||
munmap(buf, size);
|
||||
size = nsize;
|
||||
|
@ -2107,7 +2107,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
|
|||
if (fd < 0)
|
||||
return error("open(\"%s\"): %s", path,
|
||||
strerror(errno));
|
||||
if (index_fd(sha1, fd, st, write_object, OBJ_BLOB) < 0)
|
||||
if (index_fd(sha1, fd, st, write_object, OBJ_BLOB, path) < 0)
|
||||
return error("%s: failed to insert into database",
|
||||
path);
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче