Rename sha1_array to oid_array

Since this structure handles an array of object IDs, rename it to struct oid_array. Also rename the accessor functions and the initialization constant. This commit was produced mechanically by providing non-Documentation files to the following Perl one-liners: perl -pi -E 's/struct sha1_array/struct oid_array/g' perl -pi -E 's/\bsha1_array_/oid_array_/g' perl -pi -E 's/SHA1_ARRAY_INIT/OID_ARRAY_INIT/g' Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Mar 31, 2017 at 01:40 UTC 910650d2f8755359ab7b1f0e2a2d576c06a68091
31 files changed +155 -155
bisect.c
+8 -8
@@ -12,8 +12,8 @@
12 #include "sha1-array.h"
13 #include "argv-array.h"
14
15 -static struct sha1_array good_revs;
16 -static struct sha1_array skipped_revs;
15 +static struct oid_array good_revs;
16 +static struct oid_array skipped_revs;
17
18 static struct object_id *current_bad_oid;
19
@@ -413,9 +413,9 @@ static int register_ref(const char *refname, const struct object_id *oid,
413 current_bad_oid = xmalloc(sizeof(*current_bad_oid));
414 oidcpy(current_bad_oid, oid);
415 } else if (starts_with(refname, good_prefix.buf)) {
416 - sha1_array_append(&good_revs, oid);
416 + oid_array_append(&good_revs, oid);
417 } else if (starts_with(refname, "skip-")) {
418 - sha1_array_append(&skipped_revs, oid);
418 + oid_array_append(&skipped_revs, oid);
419 }
420
421 strbuf_release(&good_prefix);
@@ -451,7 +451,7 @@ static void read_bisect_paths(struct argv_array *array)
451 fclose(fp);
452 }
453
454 -static char *join_sha1_array_hex(struct sha1_array *array, char delim)
454 +static char *join_sha1_array_hex(struct oid_array *array, char delim)
455 {
456 struct strbuf joined_hexs = STRBUF_INIT;
457 int i;
@@ -499,7 +499,7 @@ struct commit_list *filter_skipped(struct commit_list *list,
499 while (list) {
500 struct commit_list *next = list->next;
501 list->next = NULL;
502 - if (0 <= sha1_array_lookup(&skipped_revs, &list->item->object.oid)) {
502 + if (0 <= oid_array_lookup(&skipped_revs, &list->item->object.oid)) {
503 if (skipped_first && !*skipped_first)
504 *skipped_first = 1;
505 /* Move current to tried list */
@@ -789,9 +789,9 @@ static void check_merge_bases(int no_checkout)
789 const struct object_id *mb = &result->item->object.oid;
790 if (!oidcmp(mb, current_bad_oid)) {
791 handle_bad_merge_base();
792 - } else if (0 <= sha1_array_lookup(&good_revs, mb)) {
792 + } else if (0 <= oid_array_lookup(&good_revs, mb)) {
793 continue;
794 - } else if (0 <= sha1_array_lookup(&skipped_revs, mb)) {
794 + } else if (0 <= oid_array_lookup(&skipped_revs, mb)) {
795 handle_skipped_merge_base(mb);
796 } else {
797 printf(_("Bisecting: a merge base must be tested\n"));
builtin/cat-file.c
+5 -5
@@ -413,7 +413,7 @@ static int batch_loose_object(const struct object_id *oid,
413 const char *path,
414 void *data)
415 {
416 - sha1_array_append(data, oid);
416 + oid_array_append(data, oid);
417 return 0;
418 }
419
@@ -422,7 +422,7 @@ static int batch_packed_object(const struct object_id *oid,
422 uint32_t pos,
423 void *data)
424 {
425 - sha1_array_append(data, oid);
425 + oid_array_append(data, oid);
426 return 0;
427 }
428
@@ -462,7 +462,7 @@ static int batch_objects(struct batch_options *opt)
462 data.info.typep = &data.type;
463
464 if (opt->all_objects) {
465 - struct sha1_array sa = SHA1_ARRAY_INIT;
465 + struct oid_array sa = OID_ARRAY_INIT;
466 struct object_cb_data cb;
467
468 for_each_loose_object(batch_loose_object, &sa, 0);
@@ -470,9 +470,9 @@ static int batch_objects(struct batch_options *opt)
470
471 cb.opt = opt;
472 cb.expand = &data;
473 - sha1_array_for_each_unique(&sa, batch_object_cb, &cb);
473 + oid_array_for_each_unique(&sa, batch_object_cb, &cb);
474
475 - sha1_array_clear(&sa);
475 + oid_array_clear(&sa);
476 return 0;
477 }
478
builtin/diff.c
+3 -3
@@ -184,7 +184,7 @@ static int builtin_diff_combined(struct rev_info *revs,
184 struct object_array_entry *ent,
185 int ents)
186 {
187 - struct sha1_array parents = SHA1_ARRAY_INIT;
187 + struct oid_array parents = OID_ARRAY_INIT;
188 int i;
189
190 if (argc > 1)
@@ -193,10 +193,10 @@ static int builtin_diff_combined(struct rev_info *revs,
193 if (!revs->dense_combined_merges && !revs->combine_merges)
194 revs->dense_combined_merges = revs->combine_merges = 1;
195 for (i = 1; i < ents; i++)
196 - sha1_array_append(&parents, &ent[i].item->oid);
196 + oid_array_append(&parents, &ent[i].item->oid);
197 diff_tree_combined(ent[0].item->oid.hash, &parents,
198 revs->dense_combined_merges, revs);
199 - sha1_array_clear(&parents);
199 + oid_array_clear(&parents);
200 return 0;
201 }
202
builtin/fetch-pack.c
+1 -1
@@ -50,7 +50,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
50 char **pack_lockfile_ptr = NULL;
51 struct child_process *conn;
52 struct fetch_pack_args args;
53 - struct sha1_array shallow = SHA1_ARRAY_INIT;
53 + struct oid_array shallow = OID_ARRAY_INIT;
54 struct string_list deepen_not = STRING_LIST_INIT_DUP;
55
56 packet_trace_identity("fetch-pack");
builtin/pack-objects.c
+5 -5
@@ -2668,7 +2668,7 @@ static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
2668 *
2669 * This is filled by get_object_list.
2670 */
2671 -static struct sha1_array recent_objects;
2671 +static struct oid_array recent_objects;
2672
2673 static int loosened_object_can_be_discarded(const struct object_id *oid,
2674 unsigned long mtime)
@@ -2677,7 +2677,7 @@ static int loosened_object_can_be_discarded(const struct object_id *oid,
2677 return 0;
2678 if (mtime > unpack_unreachable_expiration)
2679 return 0;
2680 - if (sha1_array_lookup(&recent_objects, oid) >= 0)
2680 + if (oid_array_lookup(&recent_objects, oid) >= 0)
2681 return 0;
2682 return 1;
2683 }
@@ -2739,12 +2739,12 @@ static void record_recent_object(struct object *obj,
2739 const char *name,
2740 void *data)
2741 {
2742 - sha1_array_append(&recent_objects, &obj->oid);
2742 + oid_array_append(&recent_objects, &obj->oid);
2743 }
2744
2745 static void record_recent_commit(struct commit *commit, void *data)
2746 {
2747 - sha1_array_append(&recent_objects, &commit->object.oid);
2747 + oid_array_append(&recent_objects, &commit->object.oid);
2748 }
2749
2750 static void get_object_list(int ac, const char **av)
@@ -2812,7 +2812,7 @@ static void get_object_list(int ac, const char **av)
2812 if (unpack_unreachable)
2813 loosen_unused_packed_objects(&revs);
2814
2815 - sha1_array_clear(&recent_objects);
2815 + oid_array_clear(&recent_objects);
2816 }
2817
2818 static int option_parse_index_version(const struct option *opt,
builtin/pull.c
+3 -3
@@ -330,7 +330,7 @@ static int git_pull_config(const char *var, const char *value, void *cb)
330 * Appends merge candidates from FETCH_HEAD that are not marked not-for-merge
331 * into merge_heads.
332 */
333 -static void get_merge_heads(struct sha1_array *merge_heads)
333 +static void get_merge_heads(struct oid_array *merge_heads)
334 {
335 const char *filename = git_path("FETCH_HEAD");
336 FILE *fp;
@@ -344,7 +344,7 @@ static void get_merge_heads(struct sha1_array *merge_heads)
344 continue; /* invalid line: does not start with SHA1 */
345 if (starts_with(sb.buf + GIT_SHA1_HEXSZ, "\tnot-for-merge\t"))
346 continue; /* ref is not-for-merge */
347 - sha1_array_append(merge_heads, &oid);
347 + oid_array_append(merge_heads, &oid);
348 }
349 fclose(fp);
350 strbuf_release(&sb);
@@ -769,7 +769,7 @@ static int run_rebase(const struct object_id *curr_head,
769 int cmd_pull(int argc, const char **argv, const char *prefix)
770 {
771 const char *repo, **refspecs;
772 - struct sha1_array merge_heads = SHA1_ARRAY_INIT;
772 + struct oid_array merge_heads = OID_ARRAY_INIT;
773 struct object_id orig_head, curr_head;
774 struct object_id rebase_fork_point;
775
builtin/receive-pack.c
+12 -12
@@ -831,7 +831,7 @@ static int command_singleton_iterator(void *cb_data, unsigned char sha1[20]);
831 static int update_shallow_ref(struct command *cmd, struct shallow_info *si)
832 {
833 static struct lock_file shallow_lock;
834 - struct sha1_array extra = SHA1_ARRAY_INIT;
834 + struct oid_array extra = OID_ARRAY_INIT;
835 struct check_connected_options opt = CHECK_CONNECTED_INIT;
836 uint32_t mask = 1 << (cmd->index % 32);
837 int i;
@@ -842,13 +842,13 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)
842 if (si->used_shallow[i] &&
843 (si->used_shallow[i][cmd->index / 32] & mask) &&
844 !delayed_reachability_test(si, i))
845 - sha1_array_append(&extra, &si->shallow->oid[i]);
845 + oid_array_append(&extra, &si->shallow->oid[i]);
846
847 opt.env = tmp_objdir_env(tmp_objdir);
848 setup_alternate_shallow(&shallow_lock, &opt.shallow_file, &extra);
849 if (check_connected(command_singleton_iterator, cmd, &opt)) {
850 rollback_lock_file(&shallow_lock);
851 - sha1_array_clear(&extra);
851 + oid_array_clear(&extra);
852 return -1;
853 }
854
@@ -862,7 +862,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)
862 register_shallow(extra.oid[i].hash);
863
864 si->shallow_ref[cmd->index] = 0;
865 - sha1_array_clear(&extra);
865 + oid_array_clear(&extra);
866 return 0;
867 }
868
@@ -1529,7 +1529,7 @@ static void queue_commands_from_cert(struct command **tail,
1529 }
1530 }
1531
1532 -static struct command *read_head_info(struct sha1_array *shallow)
1532 +static struct command *read_head_info(struct oid_array *shallow)
1533 {
1534 struct command *commands = NULL;
1535 struct command **p = &commands;
@@ -1546,7 +1546,7 @@ static struct command *read_head_info(struct sha1_array *shallow)
1546 if (get_oid_hex(line + 8, &oid))
1547 die("protocol error: expected shallow sha, got '%s'",
1548 line + 8);
1549 - sha1_array_append(shallow, &oid);
1549 + oid_array_append(shallow, &oid);
1550 continue;
1551 }
1552
@@ -1804,7 +1804,7 @@ static void prepare_shallow_update(struct command *commands,
1804
1805 static void update_shallow_info(struct command *commands,
1806 struct shallow_info *si,
1807 - struct sha1_array *ref)
1807 + struct oid_array *ref)
1808 {
1809 struct command *cmd;
1810 int *ref_status;
@@ -1817,7 +1817,7 @@ static void update_shallow_info(struct command *commands,
1817 for (cmd = commands; cmd; cmd = cmd->next) {
1818 if (is_null_oid(&cmd->new_oid))
1819 continue;
1820 - sha1_array_append(ref, &cmd->new_oid);
1820 + oid_array_append(ref, &cmd->new_oid);
1821 cmd->index = ref->nr - 1;
1822 }
1823 si->ref = ref;
@@ -1878,8 +1878,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
1878 {
1879 int advertise_refs = 0;
1880 struct command *commands;
1881 - struct sha1_array shallow = SHA1_ARRAY_INIT;
1882 - struct sha1_array ref = SHA1_ARRAY_INIT;
1881 + struct oid_array shallow = OID_ARRAY_INIT;
1882 + struct oid_array ref = OID_ARRAY_INIT;
1883 struct shallow_info si;
1884
1885 struct option options[] = {
@@ -1971,8 +1971,8 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
1971 }
1972 if (use_sideband)
1973 packet_flush(1);
1974 - sha1_array_clear(&shallow);
1975 - sha1_array_clear(&ref);
1974 + oid_array_clear(&shallow);
1975 + oid_array_clear(&ref);
1976 free((void *)push_cert_nonce);
1977 return 0;
1978 }
builtin/send-pack.c
+2 -2
@@ -131,8 +131,8 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
131 const char *dest = NULL;
132 int fd[2];
133 struct child_process *conn;
134 - struct sha1_array extra_have = SHA1_ARRAY_INIT;
135 - struct sha1_array shallow = SHA1_ARRAY_INIT;
134 + struct oid_array extra_have = OID_ARRAY_INIT;
135 + struct oid_array shallow = OID_ARRAY_INIT;
136 struct ref *remote_refs, *local_refs;
137 int ret;
138 int helper_status = 0;
combine-diff.c
+6 -6
@@ -1311,7 +1311,7 @@ static const char *path_path(void *obj)
1311
1312 /* find set of paths that every parent touches */
1313 static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,
1314 - const struct sha1_array *parents, struct diff_options *opt)
1314 + const struct oid_array *parents, struct diff_options *opt)
1315 {
1316 struct combine_diff_path *paths = NULL;
1317 int i, num_parent = parents->nr;
@@ -1359,7 +1359,7 @@ static struct combine_diff_path *find_paths_generic(const unsigned char *sha1,
1359 * rename/copy detection, etc, comparing all trees simultaneously (= faster).
1360 */
1361 static struct combine_diff_path *find_paths_multitree(
1362 - const unsigned char *sha1, const struct sha1_array *parents,
1362 + const unsigned char *sha1, const struct oid_array *parents,
1363 struct diff_options *opt)
1364 {
1365 int i, nparent = parents->nr;
@@ -1384,7 +1384,7 @@ static struct combine_diff_path *find_paths_multitree(
1384
1385
1386 void diff_tree_combined(const unsigned char *sha1,
1387 - const struct sha1_array *parents,
1387 + const struct oid_array *parents,
1388 int dense,
1389 struct rev_info *rev)
1390 {
@@ -1532,12 +1532,12 @@ void diff_tree_combined_merge(const struct commit *commit, int dense,
1532 struct rev_info *rev)
1533 {
1534 struct commit_list *parent = get_saved_parents(rev, commit);
1535 - struct sha1_array parents = SHA1_ARRAY_INIT;
1535 + struct oid_array parents = OID_ARRAY_INIT;
1536
1537 while (parent) {
1538 - sha1_array_append(&parents, &parent->item->object.oid);
1538 + oid_array_append(&parents, &parent->item->object.oid);
1539 parent = parent->next;
1540 }
1541 diff_tree_combined(commit->object.oid.hash, &parents, dense, rev);
1542 - sha1_array_clear(&parents);
1542 + oid_array_clear(&parents);
1543 }
commit.h
+7 -7
@@ -261,7 +261,7 @@ extern struct commit_list *get_merge_bases_many_dirty(struct commit *one, int n,
261 /* largest positive number a signed 32-bit integer can contain */
262 #define INFINITE_DEPTH 0x7fffffff
263
264 -struct sha1_array;
264 +struct oid_array;
265 struct ref;
266 extern int register_shallow(const unsigned char *sha1);
267 extern int unregister_shallow(const unsigned char *sha1);
@@ -273,18 +273,18 @@ extern struct commit_list *get_shallow_commits_by_rev_list(
273 int ac, const char **av, int shallow_flag, int not_shallow_flag);
274 extern void set_alternate_shallow_file(const char *path, int override);
275 extern int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
276 - const struct sha1_array *extra);
276 + const struct oid_array *extra);
277 extern void setup_alternate_shallow(struct lock_file *shallow_lock,
278 const char **alternate_shallow_file,
279 - const struct sha1_array *extra);
280 -extern const char *setup_temporary_shallow(const struct sha1_array *extra);
279 + const struct oid_array *extra);
280 +extern const char *setup_temporary_shallow(const struct oid_array *extra);
281 extern void advertise_shallow_grafts(int);
282
283 struct shallow_info {
284 - struct sha1_array *shallow;
284 + struct oid_array *shallow;
285 int *ours, nr_ours;
286 int *theirs, nr_theirs;
287 - struct sha1_array *ref;
287 + struct oid_array *ref;
288
289 /* for receive-pack */
290 uint32_t **used_shallow;
@@ -295,7 +295,7 @@ struct shallow_info {
295 int nr_commits;
296 };
297
298 -extern void prepare_shallow_info(struct shallow_info *, struct sha1_array *);
298 +extern void prepare_shallow_info(struct shallow_info *, struct oid_array *);
299 extern void clear_shallow_info(struct shallow_info *);
300 extern void remove_nonexistent_theirs_shallow(struct shallow_info *);
301 extern void assign_shallow_commits_to_refs(struct shallow_info *info,
connect.c
+4 -4
@@ -111,8 +111,8 @@ static void annotate_refs_with_symref_info(struct ref *ref)
111 */
112 struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
113 struct ref **list, unsigned int flags,
114 - struct sha1_array *extra_have,
115 - struct sha1_array *shallow_points)
114 + struct oid_array *extra_have,
115 + struct oid_array *shallow_points)
116 {
117 struct ref **orig_list = list;
118
@@ -153,7 +153,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
153 die("protocol error: expected shallow sha-1, got '%s'", arg);
154 if (!shallow_points)
155 die("repository on the other end cannot be shallow");
156 - sha1_array_append(shallow_points, &old_oid);
156 + oid_array_append(shallow_points, &old_oid);
157 continue;
158 }
159
@@ -169,7 +169,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
169 }
170
171 if (extra_have && !strcmp(name, ".have")) {
172 - sha1_array_append(extra_have, &old_oid);
172 + oid_array_append(extra_have, &old_oid);
173 continue;
174 }
175
diff.h
+2 -2
@@ -14,7 +14,7 @@ struct diff_queue_struct;
14 struct strbuf;
15 struct diff_filespec;
16 struct userdiff_driver;
17 -struct sha1_array;
17 +struct oid_array;
18 struct commit;
19 struct combine_diff_path;
20
@@ -236,7 +236,7 @@ struct combine_diff_path {
236 extern void show_combined_diff(struct combine_diff_path *elem, int num_parent,
237 int dense, struct rev_info *);
238
239 -extern void diff_tree_combined(const unsigned char *sha1, const struct sha1_array *parents, int dense, struct rev_info *rev);
239 +extern void diff_tree_combined(const unsigned char *sha1, const struct oid_array *parents, int dense, struct rev_info *rev);
240
241 extern void diff_tree_combined_merge(const struct commit *commit, int dense, struct rev_info *rev);
242
fetch-pack.c
+13 -13
@@ -1015,7 +1015,7 @@ static void update_shallow(struct fetch_pack_args *args,
1015 struct ref **sought, int nr_sought,
1016 struct shallow_info *si)
1017 {
1018 - struct sha1_array ref = SHA1_ARRAY_INIT;
1018 + struct oid_array ref = OID_ARRAY_INIT;
1019 int *status;
1020 int i;
1021
@@ -1038,18 +1038,18 @@ static void update_shallow(struct fetch_pack_args *args,
1038 * shallow points that exist in the pack (iow in repo
1039 * after get_pack() and reprepare_packed_git())
1040 */
1041 - struct sha1_array extra = SHA1_ARRAY_INIT;
1041 + struct oid_array extra = OID_ARRAY_INIT;
1042 struct object_id *oid = si->shallow->oid;
1043 for (i = 0; i < si->shallow->nr; i++)
1044 if (has_object_file(&oid[i]))
1045 - sha1_array_append(&extra, &oid[i]);
1045 + oid_array_append(&extra, &oid[i]);
1046 if (extra.nr) {
1047 setup_alternate_shallow(&shallow_lock,
1048 &alternate_shallow_file,
1049 &extra);
1050 commit_lock_file(&shallow_lock);
1051 }
1052 - sha1_array_clear(&extra);
1052 + oid_array_clear(&extra);
1053 return;
1054 }
1055
@@ -1060,7 +1060,7 @@ static void update_shallow(struct fetch_pack_args *args,
1060 if (!si->nr_ours && !si->nr_theirs)
1061 return;
1062 for (i = 0; i < nr_sought; i++)
1063 - sha1_array_append(&ref, &sought[i]->old_oid);
1063 + oid_array_append(&ref, &sought[i]->old_oid);
1064 si->ref = &ref;
1065
1066 if (args->update_shallow) {
@@ -1070,23 +1070,23 @@ static void update_shallow(struct fetch_pack_args *args,
1070 * shallow roots that are actually reachable from new
1071 * refs.
1072 */
1073 - struct sha1_array extra = SHA1_ARRAY_INIT;
1073 + struct oid_array extra = OID_ARRAY_INIT;
1074 struct object_id *oid = si->shallow->oid;
1075 assign_shallow_commits_to_refs(si, NULL, NULL);
1076 if (!si->nr_ours && !si->nr_theirs) {
1077 - sha1_array_clear(&ref);
1077 + oid_array_clear(&ref);
1078 return;
1079 }
1080 for (i = 0; i < si->nr_ours; i++)
1081 - sha1_array_append(&extra, &oid[si->ours[i]]);
1081 + oid_array_append(&extra, &oid[si->ours[i]]);
1082 for (i = 0; i < si->nr_theirs; i++)
1083 - sha1_array_append(&extra, &oid[si->theirs[i]]);
1083 + oid_array_append(&extra, &oid[si->theirs[i]]);
1084 setup_alternate_shallow(&shallow_lock,
1085 &alternate_shallow_file,
1086 &extra);
1087 commit_lock_file(&shallow_lock);
1088 - sha1_array_clear(&extra);
1089 - sha1_array_clear(&ref);
1088 + oid_array_clear(&extra);
1089 + oid_array_clear(&ref);
1090 return;
1091 }
1092
@@ -1102,7 +1102,7 @@ static void update_shallow(struct fetch_pack_args *args,
1102 sought[i]->status = REF_STATUS_REJECT_SHALLOW;
1103 }
1104 free(status);
1105 - sha1_array_clear(&ref);
1105 + oid_array_clear(&ref);
1106 }
1107
1108 struct ref *fetch_pack(struct fetch_pack_args *args,
@@ -1110,7 +1110,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
1110 const struct ref *ref,
1111 const char *dest,
1112 struct ref **sought, int nr_sought,
1113 - struct sha1_array *shallow,
1113 + struct oid_array *shallow,
1114 char **pack_lockfile)
1115 {
1116 struct ref *ref_cpy;
fetch-pack.h
+2 -2
@@ -4,7 +4,7 @@
4 #include "string-list.h"
5 #include "run-command.h"
6
7 -struct sha1_array;
7 +struct oid_array;
8
9 struct fetch_pack_args {
10 const char *uploadpack;
@@ -42,7 +42,7 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
42 const char *dest,
43 struct ref **sought,
44 int nr_sought,
45 - struct sha1_array *shallow,
45 + struct oid_array *shallow,
46 char **pack_lockfile);
47
48 /*
fsck.c
+3 -3
@@ -132,7 +132,7 @@ static int fsck_msg_type(enum fsck_msg_id msg_id,
132
133 static void init_skiplist(struct fsck_options *options, const char *path)
134 {
135 - static struct sha1_array skiplist = SHA1_ARRAY_INIT;
135 + static struct oid_array skiplist = OID_ARRAY_INIT;
136 int sorted, fd;
137 char buffer[GIT_MAX_HEXSZ + 1];
138 struct object_id oid;
@@ -156,7 +156,7 @@ static void init_skiplist(struct fsck_options *options, const char *path)
156 break;
157 if (parse_oid_hex(buffer, &oid, &p) || *p != '\n')
158 die("Invalid SHA-1: %s", buffer);
159 - sha1_array_append(&skiplist, &oid);
159 + oid_array_append(&skiplist, &oid);
160 if (sorted && skiplist.nr > 1 &&
161 oidcmp(&skiplist.oid[skiplist.nr - 2],
162 &oid) > 0)
@@ -280,7 +280,7 @@ static int report(struct fsck_options *options, struct object *object,
280 return 0;
281
282 if (options->skiplist && object &&
283 - sha1_array_lookup(options->skiplist, &object->oid) >= 0)
283 + oid_array_lookup(options->skiplist, &object->oid) >= 0)
284 return 0;
285
286 if (msg_type == FSCK_FATAL)
fsck.h
+1 -1
@@ -34,7 +34,7 @@ struct fsck_options {
34 fsck_error error_func;
35 unsigned strict:1;
36 int *msg_type;
37 - struct sha1_array *skiplist;
37 + struct oid_array *skiplist;
38 struct decoration *object_names;
39 };
40
parse-options-cb.c
+2 -2
@@ -99,14 +99,14 @@ int parse_opt_object_name(const struct option *opt, const char *arg, int unset)
99 struct object_id oid;
100
101 if (unset) {
102 - sha1_array_clear(opt->value);
102 + oid_array_clear(opt->value);
103 return 0;
104 }
105 if (!arg)
106 return -1;
107 if (get_oid(arg, &oid))
108 return error(_("malformed object name '%s'"), arg);
109 - sha1_array_append(opt->value, &oid);
109 + oid_array_append(opt->value, &oid);
110 return 0;
111 }
112
ref-filter.c
+3 -3
@@ -1677,21 +1677,21 @@ static int filter_pattern_match(struct ref_filter *filter, const char *refname)
1677 * the need to parse the object via parse_object(). peel_ref() might be a
1678 * more efficient alternative to obtain the pointee.
1679 */
1680 -static const struct object_id *match_points_at(struct sha1_array *points_at,
1680 +static const struct object_id *match_points_at(struct oid_array *points_at,
1681 const struct object_id *oid,
1682 const char *refname)
1683 {
1684 const struct object_id *tagged_oid = NULL;
1685 struct object *obj;
1686
1687 - if (sha1_array_lookup(points_at, oid) >= 0)
1687 + if (oid_array_lookup(points_at, oid) >= 0)
1688 return oid;
1689 obj = parse_object(oid->hash);
1690 if (!obj)
1691 die(_("malformed object at '%s'"), refname);
1692 if (obj->type == OBJ_TAG)
1693 tagged_oid = &((struct tag *)obj)->tagged->oid;
1694 - if (tagged_oid && sha1_array_lookup(points_at, tagged_oid) >= 0)
1694 + if (tagged_oid && oid_array_lookup(points_at, tagged_oid) >= 0)
1695 return tagged_oid;
1696 return NULL;
1697 }
ref-filter.h
+1 -1
@@ -51,7 +51,7 @@ struct ref_array {
51
52 struct ref_filter {
53 const char **name_patterns;
54 - struct sha1_array points_at;
54 + struct oid_array points_at;
55 struct commit_list *with_commit;
56
57 enum {
remote-curl.c
+1 -1
@@ -163,7 +163,7 @@ struct discovery {
163 char *buf;
164 size_t len;
165 struct ref *refs;
166 - struct sha1_array shallow;
166 + struct oid_array shallow;
167 unsigned proto_git : 1;
168 };
169 static struct discovery *last_discovery;
remote.h
+3 -3
@@ -149,11 +149,11 @@ int check_ref_type(const struct ref *ref, int flags);
149 */
150 void free_refs(struct ref *ref);
151
152 -struct sha1_array;
152 +struct oid_array;
153 extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
154 struct ref **list, unsigned int flags,
155 - struct sha1_array *extra_have,
156 - struct sha1_array *shallow);
155 + struct oid_array *extra_have,
156 + struct oid_array *shallow);
157
158 int resolve_remote_symref(struct ref *ref, struct ref *list);
159 int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
send-pack.c
+2 -2
@@ -50,7 +50,7 @@ static void feed_object(const unsigned char *sha1, FILE *fh, int negative)
50 /*
51 * Make a pack stream and spit it out into file descriptor fd
52 */
53 -static int pack_objects(int fd, struct ref *refs, struct sha1_array *extra, struct send_pack_args *args)
53 +static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struct send_pack_args *args)
54 {
55 /*
56 * The child becomes pack-objects --revs; we feed
@@ -376,7 +376,7 @@ static void reject_invalid_nonce(const char *nonce, int len)
376 int send_pack(struct send_pack_args *args,
377 int fd[], struct child_process *conn,
378 struct ref *remote_refs,
379 - struct sha1_array *extra_have)
379 + struct oid_array *extra_have)
380 {
381 int in = fd[0];
382 int out = fd[1];
send-pack.h
+1 -1
@@ -32,6 +32,6 @@ int option_parse_push_signed(const struct option *opt,
32
33 int send_pack(struct send_pack_args *args,
34 int fd[], struct child_process *conn,
35 - struct ref *remote_refs, struct sha1_array *extra_have);
35 + struct ref *remote_refs, struct oid_array *extra_have);
36
37 #endif
sha1-array.c
+7 -7
@@ -2,7 +2,7 @@
2 #include "sha1-array.h"
3 #include "sha1-lookup.h"
4
5 -void sha1_array_append(struct sha1_array *array, const struct object_id *oid)
5 +void oid_array_append(struct oid_array *array, const struct object_id *oid)
6 {
7 ALLOC_GROW(array->oid, array->nr + 1, array->alloc);
8 oidcpy(&array->oid[array->nr++], oid);
@@ -14,7 +14,7 @@ static int void_hashcmp(const void *a, const void *b)
14 return oidcmp(a, b);
15 }
16
17 -static void sha1_array_sort(struct sha1_array *array)
17 +static void oid_array_sort(struct oid_array *array)
18 {
19 QSORT(array->oid, array->nr, void_hashcmp);
20 array->sorted = 1;
@@ -26,14 +26,14 @@ static const unsigned char *sha1_access(size_t index, void *table)
26 return array[index].hash;
27 }
28
29 -int sha1_array_lookup(struct sha1_array *array, const struct object_id *oid)
29 +int oid_array_lookup(struct oid_array *array, const struct object_id *oid)
30 {
31 if (!array->sorted)
32 - sha1_array_sort(array);
32 + oid_array_sort(array);
33 return sha1_pos(oid->hash, array->oid, array->nr, sha1_access);
34 }
35
36 -void sha1_array_clear(struct sha1_array *array)
36 +void oid_array_clear(struct oid_array *array)
37 {
38 free(array->oid);
39 array->oid = NULL;
@@ -42,14 +42,14 @@ void sha1_array_clear(struct sha1_array *array)
42 array->sorted = 0;
43 }
44
45 -int sha1_array_for_each_unique(struct sha1_array *array,
45 +int oid_array_for_each_unique(struct oid_array *array,
46 for_each_oid_fn fn,
47 void *data)
48 {
49 int i;
50
51 if (!array->sorted)
52 - sha1_array_sort(array);
52 + oid_array_sort(array);
53
54 for (i = 0; i < array->nr; i++) {
55 int ret;
sha1-array.h
+6 -6
@@ -1,22 +1,22 @@
1 #ifndef SHA1_ARRAY_H
2 #define SHA1_ARRAY_H
3
4 -struct sha1_array {
4 +struct oid_array {
5 struct object_id *oid;
6 int nr;
7 int alloc;
8 int sorted;
9 };
10
11 -#define SHA1_ARRAY_INIT { NULL, 0, 0, 0 }
11 +#define OID_ARRAY_INIT { NULL, 0, 0, 0 }
12
13 -void sha1_array_append(struct sha1_array *array, const struct object_id *oid);
14 -int sha1_array_lookup(struct sha1_array *array, const struct object_id *oid);
15 -void sha1_array_clear(struct sha1_array *array);
13 +void oid_array_append(struct oid_array *array, const struct object_id *oid);
14 +int oid_array_lookup(struct oid_array *array, const struct object_id *oid);
15 +void oid_array_clear(struct oid_array *array);
16
17 typedef int (*for_each_oid_fn)(const struct object_id *oid,
18 void *data);
19 -int sha1_array_for_each_unique(struct sha1_array *array,
19 +int oid_array_for_each_unique(struct oid_array *array,
20 for_each_oid_fn fn,
21 void *data);
22
sha1_name.c
+4 -4
@@ -426,13 +426,13 @@ static int get_short_sha1(const char *name, int len, unsigned char *sha1,
426
427 static int collect_ambiguous(const struct object_id *oid, void *data)
428 {
429 - sha1_array_append(data, oid);
429 + oid_array_append(data, oid);
430 return 0;
431 }
432
433 int for_each_abbrev(const char *prefix, each_abbrev_fn fn, void *cb_data)
434 {
435 - struct sha1_array collect = SHA1_ARRAY_INIT;
435 + struct oid_array collect = OID_ARRAY_INIT;
436 struct disambiguate_state ds;
437 int ret;
438
@@ -445,8 +445,8 @@ int for_each_abbrev(const char *prefix, each_abbrev_fn fn, void *cb_data)
445 find_short_object_filename(&ds);
446 find_short_packed_object(&ds);
447
448 - ret = sha1_array_for_each_unique(&collect, fn, cb_data);
449 - sha1_array_clear(&collect);
448 + ret = oid_array_for_each_unique(&collect, fn, cb_data);
449 + oid_array_clear(&collect);
450 return ret;
451 }
452
shallow.c
+6 -6
@@ -260,7 +260,7 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data)
260 }
261
262 static int write_shallow_commits_1(struct strbuf *out, int use_pack_protocol,
263 - const struct sha1_array *extra,
263 + const struct oid_array *extra,
264 unsigned flags)
265 {
266 struct write_shallow_data data;
@@ -281,14 +281,14 @@ static int write_shallow_commits_1(struct strbuf *out, int use_pack_protocol,
281 }
282
283 int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
284 - const struct sha1_array *extra)
284 + const struct oid_array *extra)
285 {
286 return write_shallow_commits_1(out, use_pack_protocol, extra, 0);
287 }
288
289 static struct tempfile temporary_shallow;
290
291 -const char *setup_temporary_shallow(const struct sha1_array *extra)
291 +const char *setup_temporary_shallow(const struct oid_array *extra)
292 {
293 struct strbuf sb = STRBUF_INIT;
294 int fd;
@@ -312,7 +312,7 @@ const char *setup_temporary_shallow(const struct sha1_array *extra)
312
313 void setup_alternate_shallow(struct lock_file *shallow_lock,
314 const char **alternate_shallow_file,
315 - const struct sha1_array *extra)
315 + const struct oid_array *extra)
316 {
317 struct strbuf sb = STRBUF_INIT;
318 int fd;
@@ -385,7 +385,7 @@ struct trace_key trace_shallow = TRACE_KEY_INIT(SHALLOW);
385 * Step 1, split sender shallow commits into "ours" and "theirs"
386 * Step 2, clean "ours" based on .git/shallow
387 */
388 -void prepare_shallow_info(struct shallow_info *info, struct sha1_array *sa)
388 +void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
389 {
390 int i;
391 trace_printf_key(&trace_shallow, "shallow: prepare_shallow_info\n");
@@ -560,7 +560,7 @@ void assign_shallow_commits_to_refs(struct shallow_info *info,
560 uint32_t **used, int *ref_status)
561 {
562 struct object_id *oid = info->shallow->oid;
563 - struct sha1_array *ref = info->ref;
563 + struct oid_array *ref = info->ref;
564 unsigned int i, nr;
565 int *shallow, nr_shallow = 0;
566 struct paint_info pi;
submodule.c
+24 -24
@@ -20,8 +20,8 @@ static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
20 static int parallel_jobs = 1;
21 static struct string_list changed_submodule_paths = STRING_LIST_INIT_NODUP;
22 static int initialized_fetch_ref_tips;
23 -static struct sha1_array ref_tips_before_fetch;
24 -static struct sha1_array ref_tips_after_fetch;
23 +static struct oid_array ref_tips_before_fetch;
24 +static struct oid_array ref_tips_after_fetch;
25
26 /*
27 * The following flag is set if the .gitmodules file is unmerged. We then
@@ -568,18 +568,18 @@ static int check_has_commit(const struct object_id *oid, void *data)
568 return 0;
569 }
570
571 -static int submodule_has_commits(const char *path, struct sha1_array *commits)
571 +static int submodule_has_commits(const char *path, struct oid_array *commits)
572 {
573 int has_commit = 1;
574
575 if (add_submodule_odb(path))
576 return 0;
577
578 - sha1_array_for_each_unique(commits, check_has_commit, &has_commit);
578 + oid_array_for_each_unique(commits, check_has_commit, &has_commit);
579 return has_commit;
580 }
581
582 -static int submodule_needs_pushing(const char *path, struct sha1_array *commits)
582 +static int submodule_needs_pushing(const char *path, struct oid_array *commits)
583 {
584 if (!submodule_has_commits(path, commits))
585 /*
@@ -601,7 +601,7 @@ static int submodule_needs_pushing(const char *path, struct sha1_array *commits)
601 int needs_pushing = 0;
602
603 argv_array_push(&cp.args, "rev-list");
604 - sha1_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
604 + oid_array_for_each_unique(commits, append_oid_to_argv, &cp.args);
605 argv_array_pushl(&cp.args, "--not", "--remotes", "-n", "1" , NULL);
606
607 prepare_submodule_repo_env(&cp.env_array);
@@ -623,18 +623,18 @@ static int submodule_needs_pushing(const char *path, struct sha1_array *commits)
623 return 0;
624 }
625
626 -static struct sha1_array *submodule_commits(struct string_list *submodules,
626 +static struct oid_array *submodule_commits(struct string_list *submodules,
627 const char *path)
628 {
629 struct string_list_item *item;
630
631 item = string_list_insert(submodules, path);
632 if (item->util)
633 - return (struct sha1_array *) item->util;
633 + return (struct oid_array *) item->util;
634
635 - /* NEEDSWORK: should we have sha1_array_init()? */
636 - item->util = xcalloc(1, sizeof(struct sha1_array));
637 - return (struct sha1_array *) item->util;
635 + /* NEEDSWORK: should we have oid_array_init()? */
636 + item->util = xcalloc(1, sizeof(struct oid_array));
637 + return (struct oid_array *) item->util;
638 }
639
640 static void collect_submodules_from_diff(struct diff_queue_struct *q,
@@ -646,11 +646,11 @@ static void collect_submodules_from_diff(struct diff_queue_struct *q,
646
647 for (i = 0; i < q->nr; i++) {
648 struct diff_filepair *p = q->queue[i];
649 - struct sha1_array *commits;
649 + struct oid_array *commits;
650 if (!S_ISGITLINK(p->two->mode))
651 continue;
652 commits = submodule_commits(submodules, p->two->path);
653 - sha1_array_append(commits, &p->two->oid);
653 + oid_array_append(commits, &p->two->oid);
654 }
655 }
656
@@ -670,11 +670,11 @@ static void free_submodules_sha1s(struct string_list *submodules)
670 {
671 struct string_list_item *item;
672 for_each_string_list_item(item, submodules)
673 - sha1_array_clear((struct sha1_array *) item->util);
673 + oid_array_clear((struct oid_array *) item->util);
674 string_list_clear(submodules, 1);
675 }
676
677 -int find_unpushed_submodules(struct sha1_array *commits,
677 +int find_unpushed_submodules(struct oid_array *commits,
678 const char *remotes_name, struct string_list *needs_pushing)
679 {
680 struct rev_info rev;
@@ -687,7 +687,7 @@ int find_unpushed_submodules(struct sha1_array *commits,
687
688 /* argv.argv[0] will be ignored by setup_revisions */
689 argv_array_push(&argv, "find_unpushed_submodules");
690 - sha1_array_for_each_unique(commits, append_oid_to_argv, &argv);
690 + oid_array_for_each_unique(commits, append_oid_to_argv, &argv);
691 argv_array_push(&argv, "--not");
692 argv_array_pushf(&argv, "--remotes=%s", remotes_name);
693
@@ -702,7 +702,7 @@ int find_unpushed_submodules(struct sha1_array *commits,
702 argv_array_clear(&argv);
703
704 for_each_string_list_item(submodule, &submodules) {
705 - struct sha1_array *commits = (struct sha1_array *) submodule->util;
705 + struct oid_array *commits = (struct oid_array *) submodule->util;
706
707 if (submodule_needs_pushing(submodule->string, commits))
708 string_list_insert(needs_pushing, submodule->string);
@@ -735,7 +735,7 @@ static int push_submodule(const char *path, int dry_run)
735 return 1;
736 }
737
738 -int push_unpushed_submodules(struct sha1_array *commits,
738 +int push_unpushed_submodules(struct oid_array *commits,
739 const char *remotes_name,
740 int dry_run)
741 {
@@ -817,7 +817,7 @@ static void submodule_collect_changed_cb(struct diff_queue_struct *q,
817 static int add_sha1_to_array(const char *ref, const struct object_id *oid,
818 int flags, void *data)
819 {
820 - sha1_array_append(data, oid);
820 + oid_array_append(data, oid);
821 return 0;
822 }
823
@@ -828,7 +828,7 @@ void check_for_new_submodule_commits(struct object_id *oid)
828 initialized_fetch_ref_tips = 1;
829 }
830
831 - sha1_array_append(&ref_tips_after_fetch, oid);
831 + oid_array_append(&ref_tips_after_fetch, oid);
832 }
833
834 static int add_oid_to_argv(const struct object_id *oid, void *data)
@@ -849,10 +849,10 @@ static void calculate_changed_submodule_paths(void)
849
850 init_revisions(&rev, NULL);
851 argv_array_push(&argv, "--"); /* argv[0] program name */
852 - sha1_array_for_each_unique(&ref_tips_after_fetch,
852 + oid_array_for_each_unique(&ref_tips_after_fetch,
853 add_oid_to_argv, &argv);
854 argv_array_push(&argv, "--not");
855 - sha1_array_for_each_unique(&ref_tips_before_fetch,
855 + oid_array_for_each_unique(&ref_tips_before_fetch,
856 add_oid_to_argv, &argv);
857 setup_revisions(argv.argc, argv.argv, &rev, NULL);
858 if (prepare_revision_walk(&rev))
@@ -879,8 +879,8 @@ static void calculate_changed_submodule_paths(void)
879 }
880
881 argv_array_clear(&argv);
882 - sha1_array_clear(&ref_tips_before_fetch);
883 - sha1_array_clear(&ref_tips_after_fetch);
882 + oid_array_clear(&ref_tips_before_fetch);
883 + oid_array_clear(&ref_tips_after_fetch);
884 initialized_fetch_ref_tips = 0;
885 }
886
submodule.h
+3 -3
@@ -3,7 +3,7 @@
3
4 struct diff_options;
5 struct argv_array;
6 -struct sha1_array;
6 +struct oid_array;
7
8 enum {
9 RECURSE_SUBMODULES_ONLY = -5,
@@ -73,10 +73,10 @@ extern int merge_submodule(unsigned char result[20], const char *path,
73 const unsigned char base[20],
74 const unsigned char a[20],
75 const unsigned char b[20], int search);
76 -extern int find_unpushed_submodules(struct sha1_array *commits,
76 +extern int find_unpushed_submodules(struct oid_array *commits,
77 const char *remotes_name,
78 struct string_list *needs_pushing);
79 -extern int push_unpushed_submodules(struct sha1_array *commits,
79 +extern int push_unpushed_submodules(struct oid_array *commits,
80 const char *remotes_name,
81 int dry_run);
82 extern void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir);
t/helper/test-sha1-array.c
+5 -5
@@ -9,7 +9,7 @@ static int print_oid(const struct object_id *oid, void *data)
9
10 int cmd_main(int argc, const char **argv)
11 {
12 - struct sha1_array array = SHA1_ARRAY_INIT;
12 + struct oid_array array = OID_ARRAY_INIT;
13 struct strbuf line = STRBUF_INIT;
14
15 while (strbuf_getline(&line, stdin) != EOF) {
@@ -19,15 +19,15 @@ int cmd_main(int argc, const char **argv)
19 if (skip_prefix(line.buf, "append ", &arg)) {
20 if (get_oid_hex(arg, &oid))
21 die("not a hexadecimal SHA1: %s", arg);
22 - sha1_array_append(&array, &oid);
22 + oid_array_append(&array, &oid);
23 } else if (skip_prefix(line.buf, "lookup ", &arg)) {
24 if (get_oid_hex(arg, &oid))
25 die("not a hexadecimal SHA1: %s", arg);
26 - printf("%d\n", sha1_array_lookup(&array, &oid));
26 + printf("%d\n", oid_array_lookup(&array, &oid));
27 } else if (!strcmp(line.buf, "clear"))
28 - sha1_array_clear(&array);
28 + oid_array_clear(&array);
29 else if (!strcmp(line.buf, "for_each_unique"))
30 - sha1_array_for_each_unique(&array, print_oid, NULL);
30 + oid_array_for_each_unique(&array, print_oid, NULL);
31 else
32 die("unknown command: %s", line.buf);
33 }
transport.c
+10 -10
@@ -116,8 +116,8 @@ struct git_transport_data {
116 struct child_process *conn;
117 int fd[2];
118 unsigned got_remote_heads : 1;
119 - struct sha1_array extra_have;
120 - struct sha1_array shallow;
119 + struct oid_array extra_have;
120 + struct oid_array shallow;
121 };
122
123 static int set_git_option(struct git_transport_options *opts,
@@ -1023,20 +1023,20 @@ int transport_push(struct transport *transport,
1023 TRANSPORT_RECURSE_SUBMODULES_ONLY)) &&
1024 !is_bare_repository()) {
1025 struct ref *ref = remote_refs;
1026 - struct sha1_array commits = SHA1_ARRAY_INIT;
1026 + struct oid_array commits = OID_ARRAY_INIT;
1027
1028 for (; ref; ref = ref->next)
1029 if (!is_null_oid(&ref->new_oid))
1030 - sha1_array_append(&commits,
1030 + oid_array_append(&commits,
1031 &ref->new_oid);
1032
1033 if (!push_unpushed_submodules(&commits,
1034 transport->remote->name,
1035 pretend)) {
1036 - sha1_array_clear(&commits);
1036 + oid_array_clear(&commits);
1037 die("Failed to push all needed submodules!");
1038 }
1039 - sha1_array_clear(&commits);
1039 + oid_array_clear(&commits);
1040 }
1041
1042 if (((flags & TRANSPORT_RECURSE_SUBMODULES_CHECK) ||
@@ -1045,20 +1045,20 @@ int transport_push(struct transport *transport,
1045 !pretend)) && !is_bare_repository()) {
1046 struct ref *ref = remote_refs;
1047 struct string_list needs_pushing = STRING_LIST_INIT_DUP;
1048 - struct sha1_array commits = SHA1_ARRAY_INIT;
1048 + struct oid_array commits = OID_ARRAY_INIT;
1049
1050 for (; ref; ref = ref->next)
1051 if (!is_null_oid(&ref->new_oid))
1052 - sha1_array_append(&commits,
1052 + oid_array_append(&commits,
1053 &ref->new_oid);
1054
1055 if (find_unpushed_submodules(&commits, transport->remote->name,
1056 &needs_pushing)) {
1057 - sha1_array_clear(&commits);
1057 + oid_array_clear(&commits);
1058 die_with_unpushed_submodules(&needs_pushing);
1059 }
1060 string_list_clear(&needs_pushing, 0);
1061 - sha1_array_clear(&commits);
1061 + oid_array_clear(&commits);
1062 }
1063
1064 if (!(flags & TRANSPORT_RECURSE_SUBMODULES_ONLY))