Skip to content

Commit 98e019b

Browse files
dreamergitster
authored andcommitted
sha1_file: convert index_path 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 bebfecb commit 98e019b

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

builtin/update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
280280
fill_stat_cache_info(ce, st);
281281
ce->ce_mode = ce_mode_from_stat(old, st->st_mode);
282282

283-
if (index_path(ce->oid.hash, path, st,
283+
if (index_path(&ce->oid, path, st,
284284
info_only ? 0 : HASH_WRITE_OBJECT)) {
285285
free(ce);
286286
return -1;

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ extern int ie_modified(const struct index_state *, const struct cache_entry *, s
685685
#define HASH_WRITE_OBJECT 1
686686
#define HASH_FORMAT_CHECK 2
687687
extern int index_fd(unsigned char *sha1, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
688-
extern int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned flags);
688+
extern int index_path(struct object_id *oid, const char *path, struct stat *st, unsigned flags);
689689

690690
/*
691691
* Record to sd the data from st that we use to check whether a file

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3246,7 +3246,7 @@ static void diff_fill_oid_info(struct diff_filespec *one)
32463246
}
32473247
if (lstat(one->path, &st) < 0)
32483248
die_errno("stat '%s'", one->path);
3249-
if (index_path(one->oid.hash, one->path, &st, 0))
3249+
if (index_path(&one->oid, one->path, &st, 0))
32503250
die("cannot hash %s", one->path);
32513251
}
32523252
}

notes-merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ int notes_merge_commit(struct notes_merge_options *o,
709709
/* write file as blob, and add to partial_tree */
710710
if (stat(path.buf, &st))
711711
die_errno("Failed to stat '%s'", path.buf);
712-
if (index_path(blob_oid.hash, path.buf, &st, HASH_WRITE_OBJECT))
712+
if (index_path(&blob_oid, path.buf, &st, HASH_WRITE_OBJECT))
713713
die("Failed to write blob object from '%s'", path.buf);
714714
if (add_note(partial_tree, &obj_oid, &blob_oid, NULL))
715715
die("Failed to add resolved note '%s' to notes tree",

read-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
689689
return 0;
690690
}
691691
if (!intent_only) {
692-
if (index_path(ce->oid.hash, path, st, HASH_WRITE_OBJECT)) {
692+
if (index_path(&ce->oid, path, st, HASH_WRITE_OBJECT)) {
693693
free(ce);
694694
return error("unable to index file %s", path);
695695
}

sha1_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,7 +3686,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st,
36863686
return ret;
36873687
}
36883688

3689-
int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned flags)
3689+
int index_path(struct object_id *oid, const char *path, struct stat *st, unsigned flags)
36903690
{
36913691
int fd;
36923692
struct strbuf sb = STRBUF_INIT;
@@ -3696,22 +3696,22 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned
36963696
fd = open(path, O_RDONLY);
36973697
if (fd < 0)
36983698
return error_errno("open(\"%s\")", path);
3699-
if (index_fd(sha1, fd, st, OBJ_BLOB, path, flags) < 0)
3699+
if (index_fd(oid->hash, fd, st, OBJ_BLOB, path, flags) < 0)
37003700
return error("%s: failed to insert into database",
37013701
path);
37023702
break;
37033703
case S_IFLNK:
37043704
if (strbuf_readlink(&sb, path, st->st_size))
37053705
return error_errno("readlink(\"%s\")", path);
37063706
if (!(flags & HASH_WRITE_OBJECT))
3707-
hash_sha1_file(sb.buf, sb.len, blob_type, sha1);
3708-
else if (write_sha1_file(sb.buf, sb.len, blob_type, sha1))
3707+
hash_sha1_file(sb.buf, sb.len, blob_type, oid->hash);
3708+
else if (write_sha1_file(sb.buf, sb.len, blob_type, oid->hash))
37093709
return error("%s: failed to insert into database",
37103710
path);
37113711
strbuf_release(&sb);
37123712
break;
37133713
case S_IFDIR:
3714-
return resolve_gitlink_ref(path, "HEAD", sha1);
3714+
return resolve_gitlink_ref(path, "HEAD", oid->hash);
37153715
default:
37163716
return error("%s: unsupported file type", path);
37173717
}

0 commit comments

Comments
 (0)