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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Nov 12, 2018 at 09:48 UTC 263db403face43927c2eb545a2e6ebb39aae4239
10 files changed +69 -69
builtin/count-objects.c
+2 -2
@@ -78,10 +78,10 @@ static int count_cruft(const char *basename, const char *path, void *data)
78 return 0;
79 }
80
81 -static int print_alternate(struct alternate_object_database *alt, void *data)
81 +static int print_alternate(struct object_directory *odb, void *data)
82 {
83 printf("alternate: ");
84 - quote_c_style(alt->path, NULL, stdout, 0);
84 + quote_c_style(odb->path, NULL, stdout, 0);
85 putchar('\n');
86 return 0;
87 }
builtin/fsck.c
+8 -8
@@ -688,7 +688,7 @@ static struct option fsck_opts[] = {
688 int cmd_fsck(int argc, const char **argv, const char *prefix)
689 {
690 int i;
691 - struct alternate_object_database *alt;
691 + struct object_directory *odb;
692
693 /* fsck knows how to handle missing promisor objects */
694 fetch_if_missing = 0;
@@ -725,14 +725,14 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
725 for_each_loose_object(mark_loose_for_connectivity, NULL, 0);
726 for_each_packed_object(mark_packed_for_connectivity, NULL, 0);
727 } else {
728 - struct alternate_object_database *alt_odb_list;
728 + struct object_directory *alt_odb_list;
729
730 fsck_object_dir(get_object_directory());
731
732 prepare_alt_odb(the_repository);
733 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);
736
737 if (check_full) {
738 struct packed_git *p;
@@ -840,12 +840,12 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
840 errors_found |= ERROR_COMMIT_GRAPH;
841
842 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) {
844 child_process_init(&commit_graph_verify);
845 commit_graph_verify.argv = verify_argv;
846 commit_graph_verify.git_cmd = 1;
847 verify_argv[2] = "--object-dir";
848 - verify_argv[3] = alt->path;
848 + verify_argv[3] = odb->path;
849 if (run_command(&commit_graph_verify))
850 errors_found |= ERROR_COMMIT_GRAPH;
851 }
@@ -861,12 +861,12 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
861 errors_found |= ERROR_COMMIT_GRAPH;
862
863 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) {
865 child_process_init(&midx_verify);
866 midx_verify.argv = midx_argv;
867 midx_verify.git_cmd = 1;
868 midx_argv[2] = "--object-dir";
869 - midx_argv[3] = alt->path;
869 + midx_argv[3] = odb->path;
870 if (run_command(&midx_verify))
871 errors_found |= ERROR_COMMIT_GRAPH;
872 }
builtin/submodule--helper.c
+3 -3
@@ -1265,7 +1265,7 @@ struct submodule_alternate_setup {
1265 SUBMODULE_ALTERNATE_ERROR_IGNORE, NULL }
1266
1267 static int add_possible_reference_from_superproject(
1268 - struct alternate_object_database *alt, void *sas_cb)
1268 + struct object_directory *odb, void *sas_cb)
1269 {
1270 struct submodule_alternate_setup *sas = sas_cb;
1271 size_t len;
@@ -1274,11 +1274,11 @@ static int add_possible_reference_from_superproject(
1274 * If the alternate object store is another repository, try the
1275 * standard layout with .git/(modules/<name>)+/objects
1276 */
1277 - if (strip_suffix(alt->path, "/objects", &len)) {
1277 + if (strip_suffix(odb->path, "/objects", &len)) {
1278 char *sm_alternate;
1279 struct strbuf sb = STRBUF_INIT;
1280 struct strbuf err = STRBUF_INIT;
1281 - strbuf_add(&sb, alt->path, len);
1281 + strbuf_add(&sb, odb->path, len);
1282
1283 /*
1284 * We need to end the new path with '/' to mark it as a dir,
commit-graph.c
+5 -5
@@ -230,7 +230,7 @@ static void prepare_commit_graph_one(struct repository *r, const char *obj_dir)
230 */
231 static int prepare_commit_graph(struct repository *r)
232 {
233 - struct alternate_object_database *alt;
233 + struct object_directory *odb;
234 char *obj_dir;
235 int config_value;
236
@@ -255,10 +255,10 @@ static int prepare_commit_graph(struct repository *r)
255 obj_dir = r->objects->objectdir;
256 prepare_commit_graph_one(r, obj_dir);
257 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);
262 return !!r->objects->commit_graph;
263 }
264
object-store.h
+7 -7
@@ -7,8 +7,8 @@
7 #include "sha1-array.h"
8 #include "strbuf.h"
9
10 -struct alternate_object_database {
11 - struct alternate_object_database *next;
10 +struct object_directory {
11 + struct object_directory *next;
12
13 /* see alt_scratch_buf() */
14 struct strbuf scratch;
@@ -32,14 +32,14 @@ struct alternate_object_database {
32 };
33 void prepare_alt_odb(struct repository *r);
34 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 *);
36 int foreach_alt_odb(alt_odb_fn, void*);
37
38 /*
39 * Allocate a "struct alternate_object_database" but do _not_ actually
40 * add it to the list of alternates.
41 */
42 -struct alternate_object_database *alloc_alt_odb(const char *dir);
42 +struct object_directory *alloc_alt_odb(const char *dir);
43
44 /*
45 * 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);
60 * alternate. Always use this over direct access to alt->scratch, as it
61 * cleans up any previous use of the scratch buffer.
62 */
63 -struct strbuf *alt_scratch_buf(struct alternate_object_database *alt);
63 +struct strbuf *alt_scratch_buf(struct object_directory *odb);
64
65 struct packed_git {
66 struct packed_git *next;
@@ -100,8 +100,8 @@ struct raw_object_store {
100 /* Path to extra alternate object database if not NULL */
101 char *alternate_db;
102
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;
105
106 /*
107 * Objects that should be substituted by other objects
object.c
+5 -5
@@ -482,17 +482,17 @@ struct raw_object_store *raw_object_store_new(void)
482 return o;
483 }
484
485 -static void free_alt_odb(struct alternate_object_database *alt)
485 +static void free_alt_odb(struct object_directory *odb)
486 {
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);
490 }
491
492 static void free_alt_odbs(struct raw_object_store *o)
493 {
494 while (o->alt_odb_list) {
495 - struct alternate_object_database *next;
495 + struct object_directory *next;
496
497 next = o->alt_odb_list->next;
498 free_alt_odb(o->alt_odb_list);
packfile.c
+4 -4
@@ -966,16 +966,16 @@ static void prepare_packed_git_mru(struct repository *r)
966
967 static void prepare_packed_git(struct repository *r)
968 {
969 - struct alternate_object_database *alt;
969 + struct object_directory *odb;
970
971 if (r->objects->packed_git_initialized)
972 return;
973 prepare_multi_pack_index_one(r, r->objects->objectdir, 1);
974 prepare_packed_git_one(r, r->objects->objectdir, 1);
975 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);
979 }
980 rearrange_packed_git(r);
981
sha1-file.c
+24 -24
@@ -353,16 +353,16 @@ void sha1_file_name(struct repository *r, struct strbuf *buf, const unsigned cha
353 fill_sha1_path(buf, sha1);
354 }
355
356 -struct strbuf *alt_scratch_buf(struct alternate_object_database *alt)
356 +struct strbuf *alt_scratch_buf(struct object_directory *odb)
357 {
358 - strbuf_setlen(&alt->scratch, alt->base_len);
359 - return &alt->scratch;
358 + strbuf_setlen(&odb->scratch, odb->base_len);
359 + return &odb->scratch;
360 }
361
362 -static const char *alt_sha1_path(struct alternate_object_database *alt,
362 +static const char *alt_sha1_path(struct object_directory *odb,
363 const unsigned char *sha1)
364 {
365 - struct strbuf *buf = alt_scratch_buf(alt);
365 + struct strbuf *buf = alt_scratch_buf(odb);
366 fill_sha1_path(buf, sha1);
367 return buf->buf;
368 }
@@ -374,7 +374,7 @@ static int alt_odb_usable(struct raw_object_store *o,
374 struct strbuf *path,
375 const char *normalized_objdir)
376 {
377 - struct alternate_object_database *alt;
377 + struct object_directory *odb;
378
379 /* Detect cases where alternate disappeared */
380 if (!is_directory(path->buf)) {
@@ -388,8 +388,8 @@ static int alt_odb_usable(struct raw_object_store *o,
388 * Prevent the common mistake of listing the same
389 * thing twice, or object directory itself.
390 */
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))
393 return 0;
394 }
395 if (!fspathcmp(path->buf, normalized_objdir))
@@ -402,7 +402,7 @@ static int alt_odb_usable(struct raw_object_store *o,
402 * Prepare alternate object database registry.
403 *
404 * 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
406 * non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT
407 * environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates,
408 * whose contents is similar to that environment variable but can be
@@ -419,7 +419,7 @@ static void read_info_alternates(struct repository *r,
419 static int link_alt_odb_entry(struct repository *r, const char *entry,
420 const char *relative_base, int depth, const char *normalized_objdir)
421 {
422 - struct alternate_object_database *ent;
422 + struct object_directory *ent;
423 struct strbuf pathbuf = STRBUF_INIT;
424
425 if (!is_absolute_path(entry) && relative_base) {
@@ -540,9 +540,9 @@ static void read_info_alternates(struct repository *r,
540 free(path);
541 }
542
543 -struct alternate_object_database *alloc_alt_odb(const char *dir)
543 +struct object_directory *alloc_alt_odb(const char *dir)
544 {
545 - struct alternate_object_database *ent;
545 + struct object_directory *ent;
546
547 FLEX_ALLOC_STR(ent, path, dir);
548 strbuf_init(&ent->scratch, 0);
@@ -684,7 +684,7 @@ out:
684
685 int foreach_alt_odb(alt_odb_fn fn, void *cb)
686 {
687 - struct alternate_object_database *ent;
687 + struct object_directory *ent;
688 int r = 0;
689
690 prepare_alt_odb(the_repository);
@@ -743,10 +743,10 @@ static int check_and_freshen_local(const struct object_id *oid, int freshen)
743
744 static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen)
745 {
746 - struct alternate_object_database *alt;
746 + struct object_directory *odb;
747 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);
750 if (check_and_freshen_file(path, freshen))
751 return 1;
752 }
@@ -893,7 +893,7 @@ int git_open_cloexec(const char *name, int flags)
893 static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
894 struct stat *st, const char **path)
895 {
896 - struct alternate_object_database *alt;
896 + struct object_directory *odb;
897 static struct strbuf buf = STRBUF_INIT;
898
899 strbuf_reset(&buf);
@@ -905,8 +905,8 @@ static int stat_sha1_file(struct repository *r, const unsigned char *sha1,
905
906 prepare_alt_odb(r);
907 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);
910 if (!lstat(*path, st))
911 return 0;
912 }
@@ -922,7 +922,7 @@ static int open_sha1_file(struct repository *r,
922 const unsigned char *sha1, const char **path)
923 {
924 int fd;
925 - struct alternate_object_database *alt;
925 + struct object_directory *odb;
926 int most_interesting_errno;
927 static struct strbuf buf = STRBUF_INIT;
928
@@ -936,8 +936,8 @@ static int open_sha1_file(struct repository *r,
936 most_interesting_errno = errno;
937
938 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);
941 fd = git_open(*path);
942 if (fd >= 0)
943 return fd;
@@ -2139,14 +2139,14 @@ struct loose_alt_odb_data {
2139 void *data;
2140 };
2141
2142 -static int loose_from_alt_odb(struct alternate_object_database *alt,
2142 +static int loose_from_alt_odb(struct object_directory *odb,
2143 void *vdata)
2144 {
2145 struct loose_alt_odb_data *data = vdata;
2146 struct strbuf buf = STRBUF_INIT;
2147 int r;
2148
2149 - strbuf_addstr(&buf, alt->path);
2149 + strbuf_addstr(&buf, odb->path);
2150 r = for_each_loose_file_in_objdir_buf(&buf,
2151 data->cb, NULL, NULL,
2152 data->data);
sha1-name.c
+10 -10
@@ -95,8 +95,8 @@ static int match_sha(unsigned, const unsigned char *, const unsigned char *);
95 static void find_short_object_filename(struct disambiguate_state *ds)
96 {
97 int subdir_nr = ds->bin_pfx.hash[0];
98 - struct alternate_object_database *alt;
99 - static struct alternate_object_database *fakeent;
98 + struct object_directory *odb;
99 + static struct object_directory *fakeent;
100
101 if (!fakeent) {
102 /*
@@ -110,24 +110,24 @@ static void find_short_object_filename(struct disambiguate_state *ds)
110 }
111 fakeent->next = the_repository->objects->alt_odb_list;
112
113 - for (alt = fakeent; alt && !ds->ambiguous; alt = alt->next) {
113 + for (odb = fakeent; odb && !ds->ambiguous; odb = odb->next) {
114 int pos;
115
116 - if (!alt->loose_objects_subdir_seen[subdir_nr]) {
117 - struct strbuf *buf = alt_scratch_buf(alt);
116 + if (!odb->loose_objects_subdir_seen[subdir_nr]) {
117 + struct strbuf *buf = alt_scratch_buf(odb);
118 for_each_file_in_obj_subdir(subdir_nr, buf,
119 append_loose_object,
120 NULL, NULL,
121 - &alt->loose_objects_cache);
122 - alt->loose_objects_subdir_seen[subdir_nr] = 1;
121 + &odb->loose_objects_cache);
122 + odb->loose_objects_subdir_seen[subdir_nr] = 1;
123 }
124
125 - pos = oid_array_lookup(&alt->loose_objects_cache, &ds->bin_pfx);
125 + pos = oid_array_lookup(&odb->loose_objects_cache, &ds->bin_pfx);
126 if (pos < 0)
127 pos = -1 - pos;
128 - while (!ds->ambiguous && pos < alt->loose_objects_cache.nr) {
128 + while (!ds->ambiguous && pos < odb->loose_objects_cache.nr) {
129 const struct object_id *oid;
130 - oid = alt->loose_objects_cache.oid + pos;
130 + oid = odb->loose_objects_cache.oid + pos;
131 if (!match_sha(ds->len, ds->bin_pfx.hash, oid->hash))
132 break;
133 update_candidates(ds, oid);
transport.c
+1 -1
@@ -1433,7 +1433,7 @@ struct alternate_refs_data {
1433 void *data;
1434 };
1435
1436 -static int refs_from_alternate_cb(struct alternate_object_database *e,
1436 +static int refs_from_alternate_cb(struct object_directory *e,
1437 void *data)
1438 {
1439 struct strbuf path = STRBUF_INIT;