Skip to content

Commit 56ef85e

Browse files
pks-tgitster
authored andcommitted
object-store: drop loose_object_path()
The function `loose_object_path()` is a trivial wrapper around `odb_loose_path()`, with the only exception that it always uses the primary object database of the given repository. This doesn't really add a ton of value though, so let's drop the function and inline it at every callsite. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ddb28da commit 56ef85e

File tree

6 files changed

+10
-18
lines changed

6 files changed

+10
-18
lines changed

http-walker.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "list.h"
1010
#include "transport.h"
1111
#include "packfile.h"
12+
#include "object-file.h"
1213
#include "object-store.h"
1314

1415
struct alt_base {
@@ -540,7 +541,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid)
540541
ret = error("File %s has bad hash", hex);
541542
} else if (req->rename < 0) {
542543
struct strbuf buf = STRBUF_INIT;
543-
loose_object_path(the_repository, &buf, &req->oid);
544+
odb_loose_path(the_repository->objects->odb, &buf, &req->oid);
544545
ret = error("unable to write sha1 filename %s", buf.buf);
545546
strbuf_release(&buf);
546547
}

http.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url,
26622662
oidcpy(&freq->oid, oid);
26632663
freq->localfile = -1;
26642664

2665-
loose_object_path(the_repository, &filename, oid);
2665+
odb_loose_path(the_repository->objects->odb, &filename, oid);
26662666
strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf);
26672667

26682668
strbuf_addf(&prevfile, "%s.prev", filename.buf);
@@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq)
28142814
unlink_or_warn(freq->tmpfile.buf);
28152815
return -1;
28162816
}
2817-
loose_object_path(the_repository, &filename, &freq->oid);
2817+
odb_loose_path(the_repository->objects->odb, &filename, &freq->oid);
28182818
freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf);
28192819
strbuf_release(&filename);
28202820

object-file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr,
932932
if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT))
933933
prepare_loose_object_bulk_checkin();
934934

935-
loose_object_path(the_repository, &filename, oid);
935+
odb_loose_path(the_repository->objects->odb, &filename, oid);
936936

937937
fd = start_loose_object_common(&tmp_file, filename.buf, flags,
938938
&stream, compressed, sizeof(compressed),
@@ -1079,7 +1079,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len,
10791079
goto cleanup;
10801080
}
10811081

1082-
loose_object_path(the_repository, &filename, oid);
1082+
odb_loose_path(the_repository->objects->odb, &filename, oid);
10831083

10841084
/* We finally know the object path, and create the missing dir. */
10851085
dirlen = directory_size(filename.buf);

object-file.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa
2525

2626
struct object_directory;
2727

28+
/*
29+
* Put in `buf` the name of the file in the local object database that
30+
* would be used to store a loose object with the specified oid.
31+
*/
2832
const char *odb_loose_path(struct object_directory *odb,
2933
struct strbuf *buf,
3034
const struct object_id *oid);

object-store.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ int odb_pack_keep(const char *name)
9696
return open(name, O_RDWR|O_CREAT|O_EXCL, 0600);
9797
}
9898

99-
const char *loose_object_path(struct repository *r, struct strbuf *buf,
100-
const struct object_id *oid)
101-
{
102-
return odb_loose_path(r->objects->odb, buf, oid);
103-
}
104-
10599
/*
106100
* Return non-zero iff the path is usable as an alternate object database.
107101
*/

object-store.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,6 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);
196196
*/
197197
int odb_pack_keep(const char *name);
198198

199-
/*
200-
* Put in `buf` the name of the file in the local object database that
201-
* would be used to store a loose object with the specified oid.
202-
*/
203-
const char *loose_object_path(struct repository *r, struct strbuf *buf,
204-
const struct object_id *oid);
205-
206199
void *map_loose_object(struct repository *r, const struct object_id *oid,
207200
unsigned long *size);
208201

0 commit comments

Comments
 (0)