return ret;
}
-int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, const char *type)
+int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object,
+ enum object_type type, const char *path)
{
unsigned long size = st->st_size;
void *buf;
close(fd);
if (!type)
- type = blob_type;
+ type = OBJ_BLOB;
/*
* Convert blobs to git internal format
*/
- if (!strcmp(type, blob_type)) {
+ if ((type == OBJ_BLOB) && S_ISREG(st->st_mode)) {
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;
}
if (write_object)
- ret = write_sha1_file(buf, size, type, sha1);
+ ret = write_sha1_file(buf, size, typename(type), sha1);
else
- ret = hash_sha1_file(buf, size, type, sha1);
+ ret = hash_sha1_file(buf, size, typename(type), sha1);
if (re_allocated) {
free(buf);
return ret;
if (fd < 0)
return error("open(\"%s\"): %s", path,
strerror(errno));
- if (index_fd(sha1, fd, st, write_object, NULL) < 0)
+ if (index_fd(sha1, fd, st, write_object, OBJ_BLOB, path) < 0)
return error("%s: failed to insert into database",
path);
break;