Skip to content

Commit e350655

Browse files
dreamergitster
authored andcommitted
sha1_file: convert index_fd to struct object_id
Convert all remaining callers as well. Signed-off-by: Patryk Obara <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98e019b commit e350655

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

builtin/difftool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int use_wt_file(const char *workdir, const char *name,
111111
int fd = open(buf.buf, O_RDONLY);
112112

113113
if (fd >= 0 &&
114-
!index_fd(wt_oid.hash, fd, &st, OBJ_BLOB, name, 0)) {
114+
!index_fd(&wt_oid, fd, &st, OBJ_BLOB, name, 0)) {
115115
if (is_null_oid(oid)) {
116116
oidcpy(oid, &wt_oid);
117117
use = 1;

builtin/hash-object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
3838
if (fstat(fd, &st) < 0 ||
3939
(literally
4040
? hash_literally(&oid, fd, type, flags)
41-
: index_fd(oid.hash, fd, &st, type_from_string(type), path, flags)))
41+
: index_fd(&oid, fd, &st, type_from_string(type), path, flags)))
4242
die((flags & HASH_WRITE_OBJECT)
4343
? "Unable to add %s to database"
4444
: "Unable to hash %s", path);

builtin/replace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ static void import_object(struct object_id *oid, enum object_type type,
269269

270270
if (fstat(fd, &st) < 0)
271271
die_errno("unable to fstat %s", filename);
272-
if (index_fd(oid->hash, fd, &st, type, NULL, flags) < 0)
272+
if (index_fd(oid, fd, &st, type, NULL, flags) < 0)
273273
die("unable to write object to database");
274274
/* index_fd close()s fd for us */
275275
}

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ extern int ie_modified(const struct index_state *, const struct cache_entry *, s
684684

685685
#define HASH_WRITE_OBJECT 1
686686
#define HASH_FORMAT_CHECK 2
687-
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
687+
extern int index_fd(struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
688688
extern int index_path(struct object_id *oid, const char *path, struct stat *st, unsigned flags);
689689

690690
/*

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int ce_compare_data(const struct cache_entry *ce, struct stat *st)
161161

162162
if (fd >= 0) {
163163
struct object_id oid;
164-
if (!index_fd(oid.hash, fd, st, OBJ_BLOB, ce->name, 0))
164+
if (!index_fd(&oid, fd, st, OBJ_BLOB, ce->name, 0))
165165
match = oidcmp(&oid, &ce->oid);
166166
/* index_fd() closed the file descriptor already */
167167
}

sha1_file.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3662,7 +3662,7 @@ static int index_stream(unsigned char *sha1, int fd, size_t size,
36623662
return index_bulk_checkin(sha1, fd, size, type, path, flags);
36633663
}
36643664

3665-
int index_fd(unsigned char *sha1, int fd, struct stat *st,
3665+
int index_fd(struct object_id *oid, int fd, struct stat *st,
36663666
enum object_type type, const char *path, unsigned flags)
36673667
{
36683668
int ret;
@@ -3672,15 +3672,15 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st,
36723672
* die() for large files.
36733673
*/
36743674
if (type == OBJ_BLOB && path && would_convert_to_git_filter_fd(path))
3675-
ret = index_stream_convert_blob(sha1, fd, path, flags);
3675+
ret = index_stream_convert_blob(oid->hash, fd, path, flags);
36763676
else if (!S_ISREG(st->st_mode))
3677-
ret = index_pipe(sha1, fd, type, path, flags);
3677+
ret = index_pipe(oid->hash, fd, type, path, flags);
36783678
else if (st->st_size <= big_file_threshold || type != OBJ_BLOB ||
36793679
(path && would_convert_to_git(&the_index, path)))
3680-
ret = index_core(sha1, fd, xsize_t(st->st_size), type, path,
3680+
ret = index_core(oid->hash, fd, xsize_t(st->st_size), type, path,
36813681
flags);
36823682
else
3683-
ret = index_stream(sha1, fd, xsize_t(st->st_size), type, path,
3683+
ret = index_stream(oid->hash, fd, xsize_t(st->st_size), type, path,
36843684
flags);
36853685
close(fd);
36863686
return ret;
@@ -3696,7 +3696,7 @@ int index_path(struct object_id *oid, const char *path, struct stat *st, unsigne
36963696
fd = open(path, O_RDONLY);
36973697
if (fd < 0)
36983698
return error_errno("open(\"%s\")", path);
3699-
if (index_fd(oid->hash, fd, st, OBJ_BLOB, path, flags) < 0)
3699+
if (index_fd(oid, fd, st, OBJ_BLOB, path, flags) < 0)
37003700
return error("%s: failed to insert into database",
37013701
path);
37023702
break;

0 commit comments

Comments
 (0)