Skip to content

Commit f6638bf

Browse files
pks-tgitster
authored andcommitted
object-file: inline check_and_freshen() functions
The `check_and_freshen()` functions are only used by a single caller now. Inline them into `freshen_loose_object()`. While at it, rename `check_and_freshen_odb()` to `_source()` to reflect that it works on a single object source instead of on the whole database. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 931e8c9 commit f6638bf

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

object-file.c

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,42 +89,19 @@ int check_and_freshen_file(const char *fn, int freshen)
8989
return 1;
9090
}
9191

92-
static int check_and_freshen_odb(struct odb_source *source,
93-
const struct object_id *oid,
94-
int freshen)
92+
static int check_and_freshen_source(struct odb_source *source,
93+
const struct object_id *oid,
94+
int freshen)
9595
{
9696
static struct strbuf path = STRBUF_INIT;
9797
odb_loose_path(source, &path, oid);
9898
return check_and_freshen_file(path.buf, freshen);
9999
}
100100

101-
static int check_and_freshen_local(const struct object_id *oid, int freshen)
102-
{
103-
return check_and_freshen_odb(the_repository->objects->sources, oid, freshen);
104-
}
105-
106-
static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)
107-
{
108-
struct odb_source *source;
109-
110-
odb_prepare_alternates(the_repository->objects);
111-
for (source = the_repository->objects->sources->next; source; source = source->next) {
112-
if (check_and_freshen_odb(source, oid, freshen))
113-
return 1;
114-
}
115-
return 0;
116-
}
117-
118-
static int check_and_freshen(const struct object_id *oid, int freshen)
119-
{
120-
return check_and_freshen_local(oid, freshen) ||
121-
check_and_freshen_nonlocal(oid, freshen);
122-
}
123-
124101
int has_loose_object(struct odb_source *source,
125102
const struct object_id *oid)
126103
{
127-
return check_and_freshen_odb(source, oid, 0);
104+
return check_and_freshen_source(source, oid, 0);
128105
}
129106

130107
int format_object_header(char *str, size_t size, enum object_type type,
@@ -918,7 +895,15 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
918895

919896
static int freshen_loose_object(const struct object_id *oid)
920897
{
921-
return check_and_freshen(oid, 1);
898+
struct odb_source *source;
899+
900+
odb_prepare_alternates(the_repository->objects);
901+
for (source = the_repository->objects->sources; source; source = source->next) {
902+
if (check_and_freshen_source(source, oid, 1))
903+
return 1;
904+
}
905+
906+
return 0;
922907
}
923908

924909
static int freshen_packed_object(const struct object_id *oid)

0 commit comments

Comments
 (0)