sha1_file: convert index_path to struct object_id
Convert all remaining callers as well. Signed-off-by: Patryk Obara <patryk.obara@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patryk Obara committed
Aug 20, 2017 at 22:09 UTC
98e019b067ac8a34e06f9c412f14a080c7c4dc0d
6 files changed
+10
-10
builtin/update-index.c
+1
-1
@@ -280,7 +280,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
280
fill_stat_cache_info(ce, st);
281
ce->ce_mode = ce_mode_from_stat(old, st->st_mode);
282
283
- if (index_path(ce->oid.hash, path, st,
283
+ if (index_path(&ce->oid, path, st,
284
info_only ? 0 : HASH_WRITE_OBJECT)) {
285
free(ce);
286
return -1;
cache.h
+1
-1
@@ -685,7 +685,7 @@ extern int ie_modified(const struct index_state *, const struct cache_entry *, s
685
#define HASH_WRITE_OBJECT 1
686
#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);
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);
689
690
/*
691
* Record to sd the data from st that we use to check whether a file
diff.c
+1
-1
@@ -3246,7 +3246,7 @@ static void diff_fill_oid_info(struct diff_filespec *one)
3246
}
3247
if (lstat(one->path, &st) < 0)
3248
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))
3250
die("cannot hash %s", one->path);
3251
}
3252
}
notes-merge.c
+1
-1
@@ -709,7 +709,7 @@ int notes_merge_commit(struct notes_merge_options *o,
709
/* write file as blob, and add to partial_tree */
710
if (stat(path.buf, &st))
711
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))
713
die("Failed to write blob object from '%s'", path.buf);
714
if (add_note(partial_tree, &obj_oid, &blob_oid, NULL))
715
die("Failed to add resolved note '%s' to notes tree",
read-cache.c
+1
-1
@@ -689,7 +689,7 @@ int add_to_index(struct index_state *istate, const char *path, struct stat *st,
689
return 0;
690
}
691
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)) {
693
free(ce);
694
return error("unable to index file %s", path);
695
}
sha1_file.c
+5
-5
@@ -3686,7 +3686,7 @@ int index_fd(unsigned char *sha1, int fd, struct stat *st,
3686
return ret;
3687
}
3688
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)
3690
{
3691
int fd;
3692
struct strbuf sb = STRBUF_INIT;
@@ -3696,7 +3696,7 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned
3696
fd = open(path, O_RDONLY);
3697
if (fd < 0)
3698
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)
3700
return error("%s: failed to insert into database",
3701
path);
3702
break;
@@ -3704,14 +3704,14 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, unsigned
3704
if (strbuf_readlink(&sb, path, st->st_size))
3705
return error_errno("readlink(\"%s\")", path);
3706
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))
3709
return error("%s: failed to insert into database",
3710
path);
3711
strbuf_release(&sb);
3712
break;
3713
case S_IFDIR:
3714
- return resolve_gitlink_ref(path, "HEAD", sha1);
3714
+ return resolve_gitlink_ref(path, "HEAD", oid->hash);
3715
default:
3716
return error("%s: unsupported file type", path);
3717
}