index_fd(): use enum object_type instead of type name string.

Signed-off-by: Junio C Hamano <junkio@cox.net>
diff --git a/cache.h b/cache.h
index ec72c0c..9f30ad6 100644
--- a/cache.h
+++ b/cache.h
@@ -127,6 +127,19 @@
 extern struct cache_tree *active_cache_tree;
 extern int cache_errno;
 
+enum object_type {
+	OBJ_BAD = -1,
+	OBJ_NONE = 0,
+	OBJ_COMMIT = 1,
+	OBJ_TREE = 2,
+	OBJ_BLOB = 3,
+	OBJ_TAG = 4,
+	/* 5 for future expansion */
+	OBJ_OFS_DELTA = 6,
+	OBJ_REF_DELTA = 7,
+	OBJ_MAX,
+};
+
 #define GIT_DIR_ENVIRONMENT "GIT_DIR"
 #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
@@ -177,7 +190,7 @@
 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, const char *type);
+extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type);
 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);
@@ -262,19 +275,6 @@
 int safe_create_leading_directories(char *path);
 char *enter_repo(char *path, int strict);
 
-enum object_type {
-	OBJ_BAD = -1,
-	OBJ_NONE = 0,
-	OBJ_COMMIT = 1,
-	OBJ_TREE = 2,
-	OBJ_BLOB = 3,
-	OBJ_TAG = 4,
-	/* 5 for future expansion */
-	OBJ_OFS_DELTA = 6,
-	OBJ_REF_DELTA = 7,
-	OBJ_MAX,
-};
-
 /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
 extern int sha1_object_info(const unsigned char *, unsigned long *);
 extern void * unpack_sha1_file(void *map, unsigned long mapsize, enum object_type *type, unsigned long *size);
diff --git a/hash-object.c b/hash-object.c
index 5f89e64..1e6f6bf 100644
--- a/hash-object.c
+++ b/hash-object.c
@@ -7,7 +7,7 @@
 #include "cache.h"
 #include "blob.h"
 
-static void hash_object(const char *path, const char *type, int write_object)
+static void hash_object(const char *path, enum object_type type, int write_object)
 {
 	int fd;
 	struct stat st;
@@ -73,7 +73,7 @@
 			if (0 <= prefix_length)
 				arg = prefix_filename(prefix, prefix_length,
 						      arg);
-			hash_object(arg, type, write_object);
+			hash_object(arg, type_from_string(type), write_object);
 			no_more_flags = 1;
 		}
 	}
diff --git a/read-cache.c b/read-cache.c
index d637464..6bfd411 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -59,7 +59,7 @@
 
 	if (fd >= 0) {
 		unsigned char sha1[20];
-		if (!index_fd(sha1, fd, st, 0, NULL))
+		if (!index_fd(sha1, fd, st, 0, OBJ_BLOB))
 			match = hashcmp(sha1, ce->sha1);
 		/* index_fd() closed the file descriptor already */
 	}
diff --git a/sha1_file.c b/sha1_file.c
index 3831614..38ccf1b 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2053,7 +2053,8 @@
 	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 @@
 	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 @@
 	}
 
 	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 @@
 		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;