index_fd(): pass optional path parameter as hint for blob conversion
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Feb 28, 2007 at 11:52 UTC
53bca91a7d337ea648197b9642b41a92704c17f7
4 files changed
+6
-6
cache.h
+1
-1
@@ -190,7 +190,7 @@ extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
190
extern int ce_match_stat(struct cache_entry *ce, struct stat *st, int);
191
extern int ce_modified(struct cache_entry *ce, struct stat *st, int);
192
extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
193
-extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type);
193
+extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
194
extern int read_pipe(int fd, char** return_buf, unsigned long* return_size);
195
extern int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object);
196
extern int index_path(unsigned char *sha1, const char *path, struct stat *st, int write_object);
hash-object.c
+1
-1
@@ -15,7 +15,7 @@ static void hash_object(const char *path, enum object_type type, int write_objec
15
fd = open(path, O_RDONLY);
16
if (fd < 0 ||
17
fstat(fd, &st) < 0 ||
18
- index_fd(sha1, fd, &st, write_object, type))
18
+ index_fd(sha1, fd, &st, write_object, type, path))
19
die(write_object
20
? "Unable to add %s to database"
21
: "Unable to hash %s", path);
read-cache.c
+1
-1
@@ -59,7 +59,7 @@ static int ce_compare_data(struct cache_entry *ce, struct stat *st)
59
60
if (fd >= 0) {
61
unsigned char sha1[20];
62
- if (!index_fd(sha1, fd, st, 0, OBJ_BLOB))
62
+ if (!index_fd(sha1, fd, st, 0, OBJ_BLOB, ce->name))
63
match = hashcmp(sha1, ce->sha1);
64
/* index_fd() closed the file descriptor already */
65
}
sha1_file.c
+3
-3
@@ -2054,7 +2054,7 @@ int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
2054
}
2055
2056
int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
2057
- enum object_type type)
2057
+ enum object_type type, const char *path)
2058
{
2059
unsigned long size = st->st_size;
2060
void *buf;
@@ -2074,7 +2074,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
2074
if (type == OBJ_BLOB) {
2075
unsigned long nsize = size;
2076
char *nbuf = buf;
2077
- if (convert_to_git(NULL, &nbuf, &nsize)) {
2077
+ if (convert_to_git(path, &nbuf, &nsize)) {
2078
if (size)
2079
munmap(buf, size);
2080
size = nsize;
@@ -2107,7 +2107,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
2107
if (fd < 0)
2108
return error("open(\"%s\"): %s", path,
2109
strerror(errno));
2110
- if (index_fd(sha1, fd, st, write_object, OBJ_BLOB) < 0)
2110
+ if (index_fd(sha1, fd, st, write_object, OBJ_BLOB, path) < 0)
2111
return error("%s: failed to insert into database",
2112
path);
2113
break;