Skip to content

Commit b59c71d

Browse files
committed
iterator: update enum type name for consistency
libgit2 does not use `type_t` suffixes as it's redundant; thus, rename `git_iterator_type_t` to `git_iterator_t` for consistency.
1 parent df3063e commit b59c71d

File tree

9 files changed

+50
-50
lines changed

9 files changed

+50
-50
lines changed

src/diff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ struct git_diff {
3939
git_diff_options opts;
4040
git_vector deltas; /* vector of git_diff_delta */
4141
git_pool pool;
42-
git_iterator_type_t old_src;
43-
git_iterator_type_t new_src;
42+
git_iterator_t old_src;
43+
git_iterator_t new_src;
4444
git_diff_perfdata perf;
4545

4646
int (*strcomp)(const char *, const char *);

src/diff_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ static int diff_file_content_init_common(
5050
fc->opts_max_size = opts->max_size ?
5151
opts->max_size : DIFF_MAX_FILESIZE;
5252

53-
if (fc->src == GIT_ITERATOR_TYPE_EMPTY)
54-
fc->src = GIT_ITERATOR_TYPE_TREE;
53+
if (fc->src == GIT_ITERATOR_EMPTY)
54+
fc->src = GIT_ITERATOR_TREE;
5555

5656
if (!fc->driver &&
5757
git_diff_driver_lookup(&fc->driver, fc->repo,
@@ -425,7 +425,7 @@ int git_diff_file_content__load(
425425
(diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0)
426426
return 0;
427427

428-
if (fc->src == GIT_ITERATOR_TYPE_WORKDIR)
428+
if (fc->src == GIT_ITERATOR_WORKDIR)
429429
error = diff_file_content_load_workdir(fc, diff_opts);
430430
else
431431
error = diff_file_content_load_blob(fc, diff_opts);

src/diff_file.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef struct {
2121
uint32_t flags;
2222
uint32_t opts_flags;
2323
git_object_size_t opts_max_size;
24-
git_iterator_type_t src;
24+
git_iterator_t src;
2525
const git_blob *blob;
2626
git_map map;
2727
} git_diff_file_content;

src/diff_generate.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -341,16 +341,16 @@ bool git_diff_delta__should_skip(
341341

342342

343343
static const char *diff_mnemonic_prefix(
344-
git_iterator_type_t type, bool left_side)
344+
git_iterator_t type, bool left_side)
345345
{
346346
const char *pfx = "";
347347

348348
switch (type) {
349-
case GIT_ITERATOR_TYPE_EMPTY: pfx = "c"; break;
350-
case GIT_ITERATOR_TYPE_TREE: pfx = "c"; break;
351-
case GIT_ITERATOR_TYPE_INDEX: pfx = "i"; break;
352-
case GIT_ITERATOR_TYPE_WORKDIR: pfx = "w"; break;
353-
case GIT_ITERATOR_TYPE_FS: pfx = left_side ? "1" : "2"; break;
349+
case GIT_ITERATOR_EMPTY: pfx = "c"; break;
350+
case GIT_ITERATOR_TREE: pfx = "c"; break;
351+
case GIT_ITERATOR_INDEX: pfx = "i"; break;
352+
case GIT_ITERATOR_WORKDIR: pfx = "w"; break;
353+
case GIT_ITERATOR_FS: pfx = left_side ? "1" : "2"; break;
354354
default: break;
355355
}
356356

@@ -497,17 +497,17 @@ static int diff_generated_apply_options(
497497

498498
/* Reverse src info if diff is reversed */
499499
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) {
500-
git_iterator_type_t tmp_src = diff->base.old_src;
500+
git_iterator_t tmp_src = diff->base.old_src;
501501
diff->base.old_src = diff->base.new_src;
502502
diff->base.new_src = tmp_src;
503503
}
504504

505505
/* Unset UPDATE_INDEX unless diffing workdir and index */
506506
if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) &&
507-
(!(diff->base.old_src == GIT_ITERATOR_TYPE_WORKDIR ||
508-
diff->base.new_src == GIT_ITERATOR_TYPE_WORKDIR) ||
509-
!(diff->base.old_src == GIT_ITERATOR_TYPE_INDEX ||
510-
diff->base.new_src == GIT_ITERATOR_TYPE_INDEX)))
507+
(!(diff->base.old_src == GIT_ITERATOR_WORKDIR ||
508+
diff->base.new_src == GIT_ITERATOR_WORKDIR) ||
509+
!(diff->base.old_src == GIT_ITERATOR_INDEX ||
510+
diff->base.new_src == GIT_ITERATOR_INDEX)))
511511
diff->base.opts.flags &= ~GIT_DIFF_UPDATE_INDEX;
512512

513513
/* if ignore_submodules not explicitly set, check diff config */
@@ -742,7 +742,7 @@ static int maybe_modified(
742742
const git_index_entry *nitem = info->nitem;
743743
unsigned int omode = oitem->mode;
744744
unsigned int nmode = nitem->mode;
745-
bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_TYPE_WORKDIR);
745+
bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_WORKDIR);
746746
bool modified_uncertain = false;
747747
const char *matched_pathspec;
748748
int error = 0;
@@ -1079,7 +1079,7 @@ static int handle_unmatched_new_item(
10791079
/* item contained in ignored directory, so skip over it */
10801080
return iterator_advance(&info->nitem, info->new_iter);
10811081

1082-
else if (info->new_iter->type != GIT_ITERATOR_TYPE_WORKDIR) {
1082+
else if (info->new_iter->type != GIT_ITERATOR_WORKDIR) {
10831083
if (delta_type != GIT_DELTA_CONFLICTED)
10841084
delta_type = GIT_DELTA_ADDED;
10851085
}

src/diff_tform.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ static int apply_splits_and_deletes(
389389
if (insert_delete_side_of_split(diff, &onto, delta) < 0)
390390
goto on_error;
391391

392-
if (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR)
392+
if (diff->new_src == GIT_ITERATOR_WORKDIR)
393393
delta->status = GIT_DELTA_UNTRACKED;
394394
else
395395
delta->status = GIT_DELTA_ADDED;
@@ -441,7 +441,7 @@ GIT_INLINE(git_diff_file *) similarity_get_file(git_diff *diff, size_t idx)
441441

442442
typedef struct {
443443
size_t idx;
444-
git_iterator_type_t src;
444+
git_iterator_t src;
445445
git_repository *repo;
446446
git_diff_file *file;
447447
git_buf data;
@@ -460,7 +460,7 @@ static int similarity_init(
460460
info->blob = NULL;
461461
git_buf_init(&info->data, 0);
462462

463-
if (info->file->size > 0 || info->src == GIT_ITERATOR_TYPE_WORKDIR)
463+
if (info->file->size > 0 || info->src == GIT_ITERATOR_WORKDIR)
464464
return 0;
465465

466466
return git_diff_file__resolve_zero_size(
@@ -475,7 +475,7 @@ static int similarity_sig(
475475
int error = 0;
476476
git_diff_file *file = info->file;
477477

478-
if (info->src == GIT_ITERATOR_TYPE_WORKDIR) {
478+
if (info->src == GIT_ITERATOR_WORKDIR) {
479479
if ((error = git_buf_joinpath(
480480
&info->data, git_repository_workdir(info->repo), file->path)) < 0)
481481
return error;
@@ -561,13 +561,13 @@ static int similarity_measure(
561561
/* if exact match is requested, force calculation of missing OIDs now */
562562
if (exact_match) {
563563
if (git_oid_is_zero(&a_file->id) &&
564-
diff->old_src == GIT_ITERATOR_TYPE_WORKDIR &&
564+
diff->old_src == GIT_ITERATOR_WORKDIR &&
565565
!git_diff__oid_for_file(&a_file->id,
566566
diff, a_file->path, a_file->mode, a_file->size))
567567
a_file->flags |= GIT_DIFF_FLAG_VALID_ID;
568568

569569
if (git_oid_is_zero(&b_file->id) &&
570-
diff->new_src == GIT_ITERATOR_TYPE_WORKDIR &&
570+
diff->new_src == GIT_ITERATOR_WORKDIR &&
571571
!git_diff__oid_for_file(&b_file->id,
572572
diff, b_file->path, b_file->mode, b_file->size))
573573
b_file->flags |= GIT_DIFF_FLAG_VALID_ID;
@@ -1013,7 +1013,7 @@ int git_diff_find_similar(
10131013

10141014
delta_make_rename(tgt, src, best_match->similarity);
10151015

1016-
src->status = (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) ?
1016+
src->status = (diff->new_src == GIT_ITERATOR_WORKDIR) ?
10171017
GIT_DELTA_UNTRACKED : GIT_DELTA_ADDED;
10181018
src->nfiles = 1;
10191019
memset(&src->old_file, 0, sizeof(src->old_file));

src/iterator.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ int git_iterator_for_nothing(
405405
iter = git__calloc(1, sizeof(empty_iterator));
406406
GIT_ERROR_CHECK_ALLOC(iter);
407407

408-
iter->base.type = GIT_ITERATOR_TYPE_EMPTY;
408+
iter->base.type = GIT_ITERATOR_EMPTY;
409409
iter->base.cb = &callbacks;
410410
iter->base.flags = options->flags;
411411

@@ -950,7 +950,7 @@ int git_iterator_for_tree(
950950
iter = git__calloc(1, sizeof(tree_iterator));
951951
GIT_ERROR_CHECK_ALLOC(iter);
952952

953-
iter->base.type = GIT_ITERATOR_TYPE_TREE;
953+
iter->base.type = GIT_ITERATOR_TREE;
954954
iter->base.cb = &callbacks;
955955

956956
if ((error = iterator_init_common(&iter->base,
@@ -974,7 +974,7 @@ int git_iterator_current_tree_entry(
974974
tree_iterator_frame *frame;
975975
tree_iterator_entry *entry;
976976

977-
assert(i->type == GIT_ITERATOR_TYPE_TREE);
977+
assert(i->type == GIT_ITERATOR_TREE);
978978

979979
iter = (tree_iterator *)i;
980980

@@ -991,7 +991,7 @@ int git_iterator_current_parent_tree(
991991
tree_iterator *iter;
992992
tree_iterator_frame *frame;
993993

994-
assert(i->type == GIT_ITERATOR_TYPE_TREE);
994+
assert(i->type == GIT_ITERATOR_TREE);
995995

996996
iter = (tree_iterator *)i;
997997

@@ -1271,7 +1271,7 @@ static int filesystem_iterator_entry_hash(
12711271
return 0;
12721272
}
12731273

1274-
if (iter->base.type == GIT_ITERATOR_TYPE_WORKDIR)
1274+
if (iter->base.type == GIT_ITERATOR_WORKDIR)
12751275
return git_repository_hashfile(&entry->id,
12761276
iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL);
12771277

@@ -1668,8 +1668,8 @@ int git_iterator_current_workdir_path(git_buf **out, git_iterator *i)
16681668
filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base);
16691669
const git_index_entry *entry;
16701670

1671-
if (i->type != GIT_ITERATOR_TYPE_FS &&
1672-
i->type != GIT_ITERATOR_TYPE_WORKDIR) {
1671+
if (i->type != GIT_ITERATOR_FS &&
1672+
i->type != GIT_ITERATOR_WORKDIR) {
16731673
*out = NULL;
16741674
return 0;
16751675
}
@@ -1727,7 +1727,7 @@ bool git_iterator_current_is_ignored(git_iterator *i)
17271727
{
17281728
filesystem_iterator *iter = NULL;
17291729

1730-
if (i->type != GIT_ITERATOR_TYPE_WORKDIR)
1730+
if (i->type != GIT_ITERATOR_WORKDIR)
17311731
return false;
17321732

17331733
iter = GIT_CONTAINER_OF(i, filesystem_iterator, base);
@@ -1740,7 +1740,7 @@ bool git_iterator_current_tree_is_ignored(git_iterator *i)
17401740
filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base);
17411741
filesystem_iterator_frame *frame;
17421742

1743-
if (i->type != GIT_ITERATOR_TYPE_WORKDIR)
1743+
if (i->type != GIT_ITERATOR_WORKDIR)
17441744
return false;
17451745

17461746
frame = filesystem_iterator_current_frame(iter);
@@ -1894,7 +1894,7 @@ static int iterator_for_filesystem(
18941894
const char *root,
18951895
git_index *index,
18961896
git_tree *tree,
1897-
git_iterator_type_t type,
1897+
git_iterator_t type,
18981898
git_iterator_options *options)
18991899
{
19001900
filesystem_iterator *iter;
@@ -1971,7 +1971,7 @@ int git_iterator_for_filesystem(
19711971
git_iterator_options *options)
19721972
{
19731973
return iterator_for_filesystem(out,
1974-
NULL, root, NULL, NULL, GIT_ITERATOR_TYPE_FS, options);
1974+
NULL, root, NULL, NULL, GIT_ITERATOR_FS, options);
19751975
}
19761976

19771977
int git_iterator_for_workdir_ext(
@@ -1999,7 +1999,7 @@ int git_iterator_for_workdir_ext(
19991999
GIT_ITERATOR_IGNORE_DOT_GIT;
20002000

20012001
return iterator_for_filesystem(out,
2002-
repo, repo_workdir, index, tree, GIT_ITERATOR_TYPE_WORKDIR, &options);
2002+
repo, repo_workdir, index, tree, GIT_ITERATOR_WORKDIR, &options);
20032003
}
20042004

20052005

@@ -2248,7 +2248,7 @@ int git_iterator_for_index(
22482248
iter = git__calloc(1, sizeof(index_iterator));
22492249
GIT_ERROR_CHECK_ALLOC(iter);
22502250

2251-
iter->base.type = GIT_ITERATOR_TYPE_INDEX;
2251+
iter->base.type = GIT_ITERATOR_INDEX;
22522252
iter->base.cb = &callbacks;
22532253

22542254
if ((error = iterator_init_common(&iter->base, repo, index, options)) < 0 ||

src/iterator.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
typedef struct git_iterator git_iterator;
1818

1919
typedef enum {
20-
GIT_ITERATOR_TYPE_EMPTY = 0,
21-
GIT_ITERATOR_TYPE_TREE = 1,
22-
GIT_ITERATOR_TYPE_INDEX = 2,
23-
GIT_ITERATOR_TYPE_WORKDIR = 3,
24-
GIT_ITERATOR_TYPE_FS = 4,
25-
} git_iterator_type_t;
20+
GIT_ITERATOR_EMPTY = 0,
21+
GIT_ITERATOR_TREE = 1,
22+
GIT_ITERATOR_INDEX = 2,
23+
GIT_ITERATOR_WORKDIR = 3,
24+
GIT_ITERATOR_FS = 4,
25+
} git_iterator_t;
2626

2727
typedef enum {
2828
/** ignore case for entry sort order */
@@ -78,7 +78,7 @@ typedef struct {
7878
} git_iterator_callbacks;
7979

8080
struct git_iterator {
81-
git_iterator_type_t type;
81+
git_iterator_t type;
8282
git_iterator_callbacks *cb;
8383

8484
git_repository *repo;
@@ -238,7 +238,7 @@ GIT_INLINE(int) git_iterator_reset(git_iterator *iter)
238238
extern int git_iterator_reset_range(
239239
git_iterator *iter, const char *start, const char *end);
240240

241-
GIT_INLINE(git_iterator_type_t) git_iterator_type(git_iterator *iter)
241+
GIT_INLINE(git_iterator_t) git_iterator_type(git_iterator *iter)
242242
{
243243
return iter->type;
244244
}

src/pathspec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static int pathspec_match_from_iterator(
422422
if ((error = git_iterator_reset_range(iter, ps->prefix, ps->prefix)) < 0)
423423
goto done;
424424

425-
if (git_iterator_type(iter) == GIT_ITERATOR_TYPE_WORKDIR &&
425+
if (git_iterator_type(iter) == GIT_ITERATOR_WORKDIR &&
426426
(error = git_repository_index__weakptr(
427427
&index, git_iterator_owner(iter))) < 0)
428428
goto done;

src/status.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ static unsigned int workdir_delta2status(
8787
* discern between RENAMED vs RENAMED+MODIFED
8888
*/
8989
if (git_oid_is_zero(&idx2wd->old_file.id) &&
90-
diff->old_src == GIT_ITERATOR_TYPE_WORKDIR &&
90+
diff->old_src == GIT_ITERATOR_WORKDIR &&
9191
!git_diff__oid_for_file(
9292
&idx2wd->old_file.id, diff, idx2wd->old_file.path,
9393
idx2wd->old_file.mode, idx2wd->old_file.size))
9494
idx2wd->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
9595

9696
if (git_oid_is_zero(&idx2wd->new_file.id) &&
97-
diff->new_src == GIT_ITERATOR_TYPE_WORKDIR &&
97+
diff->new_src == GIT_ITERATOR_WORKDIR &&
9898
!git_diff__oid_for_file(
9999
&idx2wd->new_file.id, diff, idx2wd->new_file.path,
100100
idx2wd->new_file.mode, idx2wd->new_file.size))

0 commit comments

Comments
 (0)