diff options
author | Patryk Obara <patryk.obara@gmail.com> | 2018-01-28 01:13:20 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-01-30 10:42:36 -0800 |
commit | 4bdb70a4f73369af39989a3ab5732825600dc914 (patch) | |
tree | c1732a9cf1b5cb25f3463fbc81887fbbc05854be | |
parent | sha1_file: convert write_sha1_file to object_id (diff) | |
download | tgif-4bdb70a4f73369af39989a3ab5732825600dc914.tar.xz |
sha1_file: convert force_object_loose to object_id
Convert the definition and declaration of force_object_loose to
struct object_id and adjust usage of this function.
Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/pack-objects.c | 2 | ||||
-rw-r--r-- | cache.h | 3 | ||||
-rw-r--r-- | sha1_file.c | 10 |
3 files changed, 8 insertions, 7 deletions
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 6b9cfc289d..f38197543d 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -2768,7 +2768,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs) if (!packlist_find(&to_pack, oid.hash, NULL) && !has_sha1_pack_kept_or_nonlocal(&oid) && !loosened_object_can_be_discarded(&oid, p->mtime)) - if (force_object_loose(oid.hash, p->mtime)) + if (force_object_loose(&oid, p->mtime)) die("unable to force loose object"); } } @@ -1248,7 +1248,8 @@ extern int hash_sha1_file_literally(const void *buf, unsigned long len, const ch extern int pretend_object_file(void *, unsigned long, enum object_type, struct object_id *oid); -extern int force_object_loose(const unsigned char *sha1, time_t mtime); +extern int force_object_loose(const struct object_id *oid, time_t mtime); + extern int git_open_cloexec(const char *name, int flags); #define git_open(name) git_open_cloexec(name, O_RDONLY) extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size); diff --git a/sha1_file.c b/sha1_file.c index d1569b1b96..d9ee966d74 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1670,7 +1670,7 @@ cleanup: return status; } -int force_object_loose(const unsigned char *sha1, time_t mtime) +int force_object_loose(const struct object_id *oid, time_t mtime) { void *buf; unsigned long len; @@ -1679,13 +1679,13 @@ int force_object_loose(const unsigned char *sha1, time_t mtime) int hdrlen; int ret; - if (has_loose_object(sha1)) + if (has_loose_object(oid->hash)) return 0; - buf = read_object(sha1, &type, &len); + buf = read_object(oid->hash, &type, &len); if (!buf) - return error("cannot read sha1_file for %s", sha1_to_hex(sha1)); + return error("cannot read sha1_file for %s", oid_to_hex(oid)); hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), len) + 1; - ret = write_loose_object(sha1, hdr, hdrlen, buf, len, mtime); + ret = write_loose_object(oid->hash, hdr, hdrlen, buf, len, mtime); free(buf); return ret; |