Skip to content

Commit 4bdb70a

Browse files
dreamergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a09c985 commit 4bdb70a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2768,7 +2768,7 @@ static void loosen_unused_packed_objects(struct rev_info *revs)
27682768
if (!packlist_find(&to_pack, oid.hash, NULL) &&
27692769
!has_sha1_pack_kept_or_nonlocal(&oid) &&
27702770
!loosened_object_can_be_discarded(&oid, p->mtime))
2771-
if (force_object_loose(oid.hash, p->mtime))
2771+
if (force_object_loose(&oid, p->mtime))
27722772
die("unable to force loose object");
27732773
}
27742774
}

cache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,8 @@ extern int hash_sha1_file_literally(const void *buf, unsigned long len, const ch
12481248
extern int pretend_object_file(void *, unsigned long, enum object_type,
12491249
struct object_id *oid);
12501250

1251-
extern int force_object_loose(const unsigned char *sha1, time_t mtime);
1251+
extern int force_object_loose(const struct object_id *oid, time_t mtime);
1252+
12521253
extern int git_open_cloexec(const char *name, int flags);
12531254
#define git_open(name) git_open_cloexec(name, O_RDONLY)
12541255
extern void *map_sha1_file(const unsigned char *sha1, unsigned long *size);

sha1_file.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,7 @@ int hash_sha1_file_literally(const void *buf, unsigned long len, const char *typ
16701670
return status;
16711671
}
16721672

1673-
int force_object_loose(const unsigned char *sha1, time_t mtime)
1673+
int force_object_loose(const struct object_id *oid, time_t mtime)
16741674
{
16751675
void *buf;
16761676
unsigned long len;
@@ -1679,13 +1679,13 @@ int force_object_loose(const unsigned char *sha1, time_t mtime)
16791679
int hdrlen;
16801680
int ret;
16811681

1682-
if (has_loose_object(sha1))
1682+
if (has_loose_object(oid->hash))
16831683
return 0;
1684-
buf = read_object(sha1, &type, &len);
1684+
buf = read_object(oid->hash, &type, &len);
16851685
if (!buf)
1686-
return error("cannot read sha1_file for %s", sha1_to_hex(sha1));
1686+
return error("cannot read sha1_file for %s", oid_to_hex(oid));
16871687
hdrlen = xsnprintf(hdr, sizeof(hdr), "%s %lu", typename(type), len) + 1;
1688-
ret = write_loose_object(sha1, hdr, hdrlen, buf, len, mtime);
1688+
ret = write_loose_object(oid->hash, hdr, hdrlen, buf, len, mtime);
16891689
free(buf);
16901690

16911691
return ret;

0 commit comments

Comments
 (0)