Skip to content

Commit 263db40

Browse files
peffgitster
authored andcommitted
rename "alternate_object_database" to "object_directory"
In preparation for unifying the handling of alt odb's and the normal repo object directory, let's use a more neutral name. This patch is purely mechanical, swapping the type name, and converting any variables named "alt" to "odb". There should be no functional change, but it will reduce the noise in subsequent diffs. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b2ac148 commit 263db40

File tree

10 files changed

+69
-69
lines changed

10 files changed

+69
-69
lines changed

builtin/count-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ static int count_cruft(const char *basename, const char *path, void *data)
7878
return 0;
7979
}
8080

81-
static int print_alternate(struct alternate_object_database *alt, void *data)
81+
static int print_alternate(struct object_directory *odb, void *data)
8282
{
8383
printf("alternate: ");
84-
quote_c_style(alt->path, NULL, stdout, 0);
84+
quote_c_style(odb->path, NULL, stdout, 0);
8585
putchar('\n');
8686
return 0;
8787
}

builtin/fsck.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static struct option fsck_opts[] = {
688688
int cmd_fsck(int argc, const char **argv, const char *prefix)
689689
{
690690
int i;
691-
struct alternate_object_database *alt;
691+
struct object_directory *odb;
692692

693693
/* fsck knows how to handle missing promisor objects */
694694
fetch_if_missing = 0;
@@ -725,14 +725,14 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
725725
for_each_loose_object(mark_loose_for_connectivity, NULL, 0);
726726
for_each_packed_object(mark_packed_for_connectivity, NULL, 0);
727727
} else {
728-
struct alternate_object_database *alt_odb_list;
728+
struct object_directory *alt_odb_list;
729729

730730
fsck_object_dir(get_object_directory());
731731

732732
prepare_alt_odb(the_repository);
733733
alt_odb_list = the_repository->objects->alt_odb_list;
734-
for (alt = alt_odb_list; alt; alt = alt->next)
735-
fsck_object_dir(alt->path);
734+
for (odb = alt_odb_list; odb; odb = odb->next)
735+
fsck_object_dir(odb->path);
736736

737737
if (check_full) {
738738
struct packed_git *p;
@@ -840,12 +840,12 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
840840
errors_found |= ERROR_COMMIT_GRAPH;
841841

842842
prepare_alt_odb(the_repository);
843-
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
843+
for (odb = the_repository->objects->alt_odb_list; odb; odb = odb->next) {
844844
child_process_init(&commit_graph_verify);
845845
commit_graph_verify.argv = verify_argv;
846846
commit_graph_verify.git_cmd = 1;
847847
verify_argv[2] = "--object-dir";
848-
verify_argv[3] = alt->path;
848+
verify_argv[3] = odb->path;
849849
if (run_command(&commit_graph_verify))
850850
errors_found |= ERROR_COMMIT_GRAPH;
851851
}
@@ -861,12 +861,12 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
861861
errors_found |= ERROR_COMMIT_GRAPH;
862862

863863
prepare_alt_odb(the_repository);
864-
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
864+
for (odb = the_repository->objects->alt_odb_list; odb; odb = odb->next) {
865865
child_process_init(&midx_verify);
866866
midx_verify.argv = midx_argv;
867867
midx_verify.git_cmd = 1;
868868
midx_argv[2] = "--object-dir";
869-
midx_argv[3] = alt->path;
869+
midx_argv[3] = odb->path;
870870
if (run_command(&midx_verify))
871871
errors_found |= ERROR_COMMIT_GRAPH;
872872
}

builtin/submodule--helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ struct submodule_alternate_setup {
12651265
SUBMODULE_ALTERNATE_ERROR_IGNORE, NULL }
12661266

12671267
static int add_possible_reference_from_superproject(
1268-
struct alternate_object_database *alt, void *sas_cb)
1268+
struct object_directory *odb, void *sas_cb)
12691269
{
12701270
struct submodule_alternate_setup *sas = sas_cb;
12711271
size_t len;
@@ -1274,11 +1274,11 @@ static int add_possible_reference_from_superproject(
12741274
* If the alternate object store is another repository, try the
12751275
* standard layout with .git/(modules/<name>)+/objects
12761276
*/
1277-
if (strip_suffix(alt->path, "/objects", &len)) {
1277+
if (strip_suffix(odb->path, "/objects", &len)) {
12781278
char *sm_alternate;
12791279
struct strbuf sb = STRBUF_INIT;
12801280
struct strbuf err = STRBUF_INIT;
1281-
strbuf_add(&sb, alt->path, len);
1281+
strbuf_add(&sb, odb->path, len);
12821282

12831283
/*
12841284
* We need to end the new path with '/' to mark it as a dir,

commit-graph.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static void prepare_commit_graph_one(struct repository *r, const char *obj_dir)
230230
*/
231231
static int prepare_commit_graph(struct repository *r)
232232
{
233-
struct alternate_object_database *alt;
233+
struct object_directory *odb;
234234
char *obj_dir;
235235
int config_value;
236236

@@ -255,10 +255,10 @@ static int prepare_commit_graph(struct repository *r)
255255
obj_dir = r->objects->objectdir;
256256
prepare_commit_graph_one(r, obj_dir);
257257
prepare_alt_odb(r);
258-
for (alt = r->objects->alt_odb_list;
259-
!r->objects->commit_graph && alt;
260-
alt = alt->next)
261-
prepare_commit_graph_one(r, alt->path);
258+
for (odb = r->objects->alt_odb_list;
259+
!r->objects->commit_graph && odb;
260+
odb = odb->next)
261+
prepare_commit_graph_one(r, odb->path);
262262
return !!r->objects->commit_graph;
263263
}
264264

object-store.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include "sha1-array.h"
88
#include "strbuf.h"
99

10-
struct alternate_object_database {
11-
struct alternate_object_database *next;
10+
struct object_directory {
11+
struct object_directory *next;
1212

1313
/* see alt_scratch_buf() */
1414
struct strbuf scratch;
@@ -32,14 +32,14 @@ struct alternate_object_database {
3232
};
3333
void prepare_alt_odb(struct repository *r);
3434
char *compute_alternate_path(const char *path, struct strbuf *err);
35-
typedef int alt_odb_fn(struct alternate_object_database *, void *);
35+
typedef int alt_odb_fn(struct object_directory *, void *);
3636
int foreach_alt_odb(alt_odb_fn, void*);
3737

3838
/*
3939
* Allocate a "struct alternate_object_database" but do _not_ actually
4040
* add it to the list of alternates.
4141
*/
42-
struct alternate_object_database *alloc_alt_odb(const char *dir);
42+
struct object_directory *alloc_alt_odb(const char *dir);
4343

4444
/*
4545
* Add the directory to the on-disk alternates file; the new entry will also
@@ -60,7 +60,7 @@ void add_to_alternates_memory(const char *dir);
6060
* alternate. Always use this over direct access to alt->scratch, as it
6161
* cleans up any previous use of the scratch buffer.
6262
*/
63-
struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
63+
struct strbuf *alt_scratch_buf(struct object_directory *odb);
6464

6565
struct packed_git {
6666
struct packed_git *next;
@@ -100,8 +100,8 @@ struct raw_object_store {
100100
/* Path to extra alternate object database if not NULL */
101101
char *alternate_db;
102102

103-
struct alternate_object_database *alt_odb_list;
104-
struct alternate_object_database **alt_odb_tail;
103+
struct object_directory *alt_odb_list;
104+
struct object_directory **alt_odb_tail;
105105

106106
/*
107107
* Objects that should be substituted by other objects

object.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -482,17 +482,17 @@ struct raw_object_store *raw_object_store_new(void)
482482
return o;
483483
}
484484

485-
static void free_alt_odb(struct alternate_object_database *alt)
485+
static void free_alt_odb(struct object_directory *odb)
486486
{
487-
strbuf_release(&alt->scratch);
488-
oid_array_clear(&alt->loose_objects_cache);
489-
free(alt);
487+
strbuf_release(&odb->scratch);
488+
oid_array_clear(&odb->loose_objects_cache);
489+
free(odb);
490490
}
491491

492492
static void free_alt_odbs(struct raw_object_store *o)
493493
{
494494
while (o->alt_odb_list) {
495-
struct alternate_object_database *next;
495+
struct object_directory *next;
496496

497497
next = o->alt_odb_list->next;
498498
free_alt_odb(o->alt_odb_list);

packfile.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,16 +966,16 @@ static void prepare_packed_git_mru(struct repository *r)
966966

967967
static void prepare_packed_git(struct repository *r)
968968
{
969-
struct alternate_object_database *alt;
969+
struct object_directory *odb;
970970

971971
if (r->objects->packed_git_initialized)
972972
return;
973973
prepare_multi_pack_index_one(r, r->objects->objectdir, 1);
974974
prepare_packed_git_one(r, r->objects->objectdir, 1);
975975
prepare_alt_odb(r);
976-
for (alt = r->objects->alt_odb_list; alt; alt = alt->next) {
977-
prepare_multi_pack_index_one(r, alt->path, 0);
978-
prepare_packed_git_one(r, alt->path, 0);
976+
for (odb = r->objects->alt_odb_list; odb; odb = odb->next) {
977+
prepare_multi_pack_index_one(r, odb->path, 0);
978+
prepare_packed_git_one(r, odb->path, 0);
979979
}
980980
rearrange_packed_git(r);
981981

sha1-file.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,16 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha
353353
fill_sha1_path(buf, sha1);
354354
}
355355

356-
struct strbuf *alt_scratch_buf(struct alternate_object_database *alt)
356+
struct strbuf *alt_scratch_buf(struct object_directory *odb)
357357
{
358-
strbuf_setlen(&alt->scratch, alt->base_len);
359-
return &alt->scratch;
358+
strbuf_setlen(&odb->scratch, odb->base_len);
359+
return &odb->scratch;
360360
}
361361

362-
static const char *alt_sha1_path(struct alternate_object_database *alt,
362+
static const char *alt_sha1_path(struct object_directory *odb,
363363
const unsigned char *sha1)
364364
{
365-
struct strbuf *buf = alt_scratch_buf(alt);
365+
struct strbuf *buf = alt_scratch_buf(odb);
366366
fill_sha1_path(buf, sha1);
367367
return buf->buf;
368368
}
@@ -374,7 +374,7 @@ static int alt_odb_usable(struct raw_object_store *o,
374374
struct strbuf *path,
375375
const char *normalized_objdir)
376376
{
377-
struct alternate_object_database *alt;
377+
struct object_directory *odb;
378378

379379
/* Detect cases where alternate disappeared */
380380
if (!is_directory(path->buf)) {
@@ -388,8 +388,8 @@ static int alt_odb_usable(struct raw_object_store *o,
388388
* Prevent the common mistake of listing the same
389389
* thing twice, or object directory itself.
390390
*/
391-
for (alt = o->alt_odb_list; alt; alt = alt->next) {
392-
if (!fspathcmp(path->buf, alt->path))
391+
for (odb = o->alt_odb_list; odb; odb = odb->next) {
392+
if (!fspathcmp(path->buf, odb->path))
393393
return 0;
394394
}
395395
if (!fspathcmp(path->buf, normalized_objdir))
@@ -402,7 +402,7 @@ static int alt_odb_usable(struct raw_object_store *o,
402402
* Prepare alternate object database registry.
403403
*
404404
* The variable alt_odb_list points at the list of struct
405-
* alternate_object_database. The elements on this list come from
405+
* object_directory. The elements on this list come from
406406
* non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT
407407
* environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,
408408
* whose contents is similar to that environment variable but can be
@@ -419,7 +419,7 @@ static void read_info_alternates(struct repository *r,
419419
static int link_alt_odb_entry(struct repository *r, const char *entry,
420420
const char *relative_base, int depth, const char *normalized_objdir)
421421
{
422-
struct alternate_object_database *ent;
422+
struct object_directory *ent;
423423
struct strbuf pathbuf = STRBUF_INIT;
424424

425425
if (!is_absolute_path(entry) && relative_base) {
@@ -540,9 +540,9 @@ static void read_info_alternates(struct repository *r,
540540
free(path);
541541
}
542542

543-
struct alternate_object_database *alloc_alt_odb(const char *dir)
543+
struct object_directory *alloc_alt_odb(const char *dir)
544544
{
545-
struct alternate_object_database *ent;
545+
struct object_directory *ent;
546546

547547
FLEX_ALLOC_STR(ent, path, dir);
548548
strbuf_init(&ent->scratch, 0);
@@ -684,7 +684,7 @@ char *compute_alternate_path(const char *path, struct strbuf *err)
684684

685685
int foreach_alt_odb(alt_odb_fn fn, void *cb)
686686
{
687-
struct alternate_object_database *ent;
687+
struct object_directory *ent;
688688
int r = 0;
689689

690690
prepare_alt_odb(the_repository);
@@ -743,10 +743,10 @@ static int check_and_freshen_local(const struct object_id *oid, int freshen)
743743

744744
static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)
745745
{
746-
struct alternate_object_database *alt;
746+
struct object_directory *odb;
747747
prepare_alt_odb(the_repository);
748-
for (alt = the_repository->objects->alt_odb_list; alt; alt = alt->next) {
749-
const char *path = alt_sha1_path(alt, oid->hash);
748+
for (odb = the_repository->objects->alt_odb_list; odb; odb = odb->next) {
749+
const char *path = alt_sha1_path(odb, oid->hash);
750750
if (check_and_freshen_file(path, freshen))
751751
return 1;
752752
}
@@ -893,7 +893,7 @@ int git_open_cloexec(const char *name, int flags)
893893
static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
894894
struct stat *st, const char **path)
895895
{
896-
struct alternate_object_database *alt;
896+
struct object_directory *odb;
897897
static struct strbuf buf = STRBUF_INIT;
898898

899899
strbuf_reset(&buf);
@@ -905,8 +905,8 @@ static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
905905

906906
prepare_alt_odb(r);
907907
errno = ENOENT;
908-
for (alt = r->objects->alt_odb_list; alt; alt = alt->next) {
909-
*path = alt_sha1_path(alt, sha1);
908+
for (odb = r->objects->alt_odb_list; odb; odb = odb->next) {
909+
*path = alt_sha1_path(odb, sha1);
910910
if (!lstat(*path, st))
911911
return 0;
912912
}
@@ -922,7 +922,7 @@ static int open_sha1_file(struct repository *r,
922922
const unsigned char *sha1, const char **path)
923923
{
924924
int fd;
925-
struct alternate_object_database *alt;
925+
struct object_directory *odb;
926926
int most_interesting_errno;
927927
static struct strbuf buf = STRBUF_INIT;
928928

@@ -936,8 +936,8 @@ static int open_sha1_file(struct repository *r,
936936
most_interesting_errno = errno;
937937

938938
prepare_alt_odb(r);
939-
for (alt = r->objects->alt_odb_list; alt; alt = alt->next) {
940-
*path = alt_sha1_path(alt, sha1);
939+
for (odb = r->objects->alt_odb_list; odb; odb = odb->next) {
940+
*path = alt_sha1_path(odb, sha1);
941941
fd = git_open(*path);
942942
if (fd >= 0)
943943
return fd;
@@ -2139,14 +2139,14 @@ struct loose_alt_odb_data {
21392139
void *data;
21402140
};
21412141

2142-
static int loose_from_alt_odb(struct alternate_object_database *alt,
2142+
static int loose_from_alt_odb(struct object_directory *odb,
21432143
void *vdata)
21442144
{
21452145
struct loose_alt_odb_data *data = vdata;
21462146
struct strbuf buf = STRBUF_INIT;
21472147
int r;
21482148

2149-
strbuf_addstr(&buf, alt->path);
2149+
strbuf_addstr(&buf, odb->path);
21502150
r = for_each_loose_file_in_objdir_buf(&buf,
21512151
data->cb, NULL, NULL,
21522152
data->data);

0 commit comments

Comments
 (0)