aboutsummaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-02-28 11:45:56 -0800
committerJunio C Hamano <junkio@cox.net>2007-02-28 12:00:00 -0800
commitedaec3fbe8821a5761e35e9b01937eea9b2544c1 (patch)
tree181b9bae79e0d63fdac6c92b471653adc8b5e2c9 /sha1_file.c
parent597388f6a1c18a117904c307c20542d8a79a1fcd (diff)
downloadgit-edaec3fbe8821a5761e35e9b01937eea9b2544c1.tar.gz
git-edaec3fbe8821a5761e35e9b01937eea9b2544c1.tar.xz
index_fd(): use enum object_type instead of type name string.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 383161473..38ccf1b80 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2053,7 +2053,8 @@ int index_pipe(unsigned char *sha1, int fd, const char *type, int write_object)
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)
{
unsigned long size = st->st_size;
void *buf;
@@ -2065,12 +2066,12 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, con
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) {
unsigned long nsize = size;
char *nbuf = buf;
if (convert_to_git(NULL, &nbuf, &nsize)) {
@@ -2083,9 +2084,9 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, con
}
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;
@@ -2106,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, NULL) < 0)
+ if (index_fd(sha1, fd, st, write_object, OBJ_BLOB) < 0)
return error("%s: failed to insert into database",
path);
break;