Commit b59c71d8a48c2d70e05f82c3a87b49e0b99db810

Edward Thomson 2020-01-18T14:11:01

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.

diff --git a/src/diff.h b/src/diff.h
index 1a4ee47..69233b3 100644
--- a/src/diff.h
+++ b/src/diff.h
@@ -39,8 +39,8 @@ struct git_diff {
 	git_diff_options opts;
 	git_vector       deltas;    /* vector of git_diff_delta */
 	git_pool pool;
-	git_iterator_type_t old_src;
-	git_iterator_type_t new_src;
+	git_iterator_t old_src;
+	git_iterator_t new_src;
 	git_diff_perfdata perf;
 
 	int (*strcomp)(const char *, const char *);
diff --git a/src/diff_file.c b/src/diff_file.c
index 6c9a8e0..621bff5 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -50,8 +50,8 @@ static int diff_file_content_init_common(
 		fc->opts_max_size = opts->max_size ?
 			opts->max_size : DIFF_MAX_FILESIZE;
 
-	if (fc->src == GIT_ITERATOR_TYPE_EMPTY)
-		fc->src = GIT_ITERATOR_TYPE_TREE;
+	if (fc->src == GIT_ITERATOR_EMPTY)
+		fc->src = GIT_ITERATOR_TREE;
 
 	if (!fc->driver &&
 		git_diff_driver_lookup(&fc->driver, fc->repo,
@@ -425,7 +425,7 @@ int git_diff_file_content__load(
 		(diff_opts->flags & GIT_DIFF_SHOW_BINARY) == 0)
 		return 0;
 
-	if (fc->src == GIT_ITERATOR_TYPE_WORKDIR)
+	if (fc->src == GIT_ITERATOR_WORKDIR)
 		error = diff_file_content_load_workdir(fc, diff_opts);
 	else
 		error = diff_file_content_load_blob(fc, diff_opts);
diff --git a/src/diff_file.h b/src/diff_file.h
index 9354912..8d743e8 100644
--- a/src/diff_file.h
+++ b/src/diff_file.h
@@ -21,7 +21,7 @@ typedef struct {
 	uint32_t flags;
 	uint32_t opts_flags;
 	git_object_size_t opts_max_size;
-	git_iterator_type_t src;
+	git_iterator_t src;
 	const git_blob *blob;
 	git_map map;
 } git_diff_file_content;
diff --git a/src/diff_generate.c b/src/diff_generate.c
index bd0b71c..b69ef30 100644
--- a/src/diff_generate.c
+++ b/src/diff_generate.c
@@ -341,16 +341,16 @@ bool git_diff_delta__should_skip(
 
 
 static const char *diff_mnemonic_prefix(
-	git_iterator_type_t type, bool left_side)
+	git_iterator_t type, bool left_side)
 {
 	const char *pfx = "";
 
 	switch (type) {
-	case GIT_ITERATOR_TYPE_EMPTY:   pfx = "c"; break;
-	case GIT_ITERATOR_TYPE_TREE:    pfx = "c"; break;
-	case GIT_ITERATOR_TYPE_INDEX:   pfx = "i"; break;
-	case GIT_ITERATOR_TYPE_WORKDIR: pfx = "w"; break;
-	case GIT_ITERATOR_TYPE_FS:      pfx = left_side ? "1" : "2"; break;
+	case GIT_ITERATOR_EMPTY:   pfx = "c"; break;
+	case GIT_ITERATOR_TREE:    pfx = "c"; break;
+	case GIT_ITERATOR_INDEX:   pfx = "i"; break;
+	case GIT_ITERATOR_WORKDIR: pfx = "w"; break;
+	case GIT_ITERATOR_FS:      pfx = left_side ? "1" : "2"; break;
 	default: break;
 	}
 
@@ -497,17 +497,17 @@ static int diff_generated_apply_options(
 
 	/* Reverse src info if diff is reversed */
 	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_REVERSE)) {
-		git_iterator_type_t tmp_src = diff->base.old_src;
+		git_iterator_t tmp_src = diff->base.old_src;
 		diff->base.old_src = diff->base.new_src;
 		diff->base.new_src = tmp_src;
 	}
 
 	/* Unset UPDATE_INDEX unless diffing workdir and index */
 	if (DIFF_FLAG_IS_SET(diff, GIT_DIFF_UPDATE_INDEX) &&
-		(!(diff->base.old_src == GIT_ITERATOR_TYPE_WORKDIR ||
-		   diff->base.new_src == GIT_ITERATOR_TYPE_WORKDIR) ||
-		 !(diff->base.old_src == GIT_ITERATOR_TYPE_INDEX ||
-		   diff->base.new_src == GIT_ITERATOR_TYPE_INDEX)))
+		(!(diff->base.old_src == GIT_ITERATOR_WORKDIR ||
+		   diff->base.new_src == GIT_ITERATOR_WORKDIR) ||
+		 !(diff->base.old_src == GIT_ITERATOR_INDEX ||
+		   diff->base.new_src == GIT_ITERATOR_INDEX)))
 		diff->base.opts.flags &= ~GIT_DIFF_UPDATE_INDEX;
 
 	/* if ignore_submodules not explicitly set, check diff config */
@@ -742,7 +742,7 @@ static int maybe_modified(
 	const git_index_entry *nitem = info->nitem;
 	unsigned int omode = oitem->mode;
 	unsigned int nmode = nitem->mode;
-	bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_TYPE_WORKDIR);
+	bool new_is_workdir = (info->new_iter->type == GIT_ITERATOR_WORKDIR);
 	bool modified_uncertain = false;
 	const char *matched_pathspec;
 	int error = 0;
@@ -1079,7 +1079,7 @@ static int handle_unmatched_new_item(
 		/* item contained in ignored directory, so skip over it */
 		return iterator_advance(&info->nitem, info->new_iter);
 
-	else if (info->new_iter->type != GIT_ITERATOR_TYPE_WORKDIR) {
+	else if (info->new_iter->type != GIT_ITERATOR_WORKDIR) {
 		if (delta_type != GIT_DELTA_CONFLICTED)
 			delta_type = GIT_DELTA_ADDED;
 	}
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 70bbb00..437144a 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -389,7 +389,7 @@ static int apply_splits_and_deletes(
 			if (insert_delete_side_of_split(diff, &onto, delta) < 0)
 				goto on_error;
 
-			if (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR)
+			if (diff->new_src == GIT_ITERATOR_WORKDIR)
 				delta->status = GIT_DELTA_UNTRACKED;
 			else
 				delta->status = GIT_DELTA_ADDED;
@@ -441,7 +441,7 @@ GIT_INLINE(git_diff_file *) similarity_get_file(git_diff *diff, size_t idx)
 
 typedef struct {
 	size_t idx;
-	git_iterator_type_t src;
+	git_iterator_t src;
 	git_repository *repo;
 	git_diff_file *file;
 	git_buf data;
@@ -460,7 +460,7 @@ static int similarity_init(
 	info->blob = NULL;
 	git_buf_init(&info->data, 0);
 
-	if (info->file->size > 0 || info->src == GIT_ITERATOR_TYPE_WORKDIR)
+	if (info->file->size > 0 || info->src == GIT_ITERATOR_WORKDIR)
 		return 0;
 
 	return git_diff_file__resolve_zero_size(
@@ -475,7 +475,7 @@ static int similarity_sig(
 	int error = 0;
 	git_diff_file *file = info->file;
 
-	if (info->src == GIT_ITERATOR_TYPE_WORKDIR) {
+	if (info->src == GIT_ITERATOR_WORKDIR) {
 		if ((error = git_buf_joinpath(
 			&info->data, git_repository_workdir(info->repo), file->path)) < 0)
 			return error;
@@ -561,13 +561,13 @@ static int similarity_measure(
 	/* if exact match is requested, force calculation of missing OIDs now */
 	if (exact_match) {
 		if (git_oid_is_zero(&a_file->id) &&
-			diff->old_src == GIT_ITERATOR_TYPE_WORKDIR &&
+			diff->old_src == GIT_ITERATOR_WORKDIR &&
 			!git_diff__oid_for_file(&a_file->id,
 				diff, a_file->path, a_file->mode, a_file->size))
 			a_file->flags |= GIT_DIFF_FLAG_VALID_ID;
 
 		if (git_oid_is_zero(&b_file->id) &&
-			diff->new_src == GIT_ITERATOR_TYPE_WORKDIR &&
+			diff->new_src == GIT_ITERATOR_WORKDIR &&
 			!git_diff__oid_for_file(&b_file->id,
 				diff, b_file->path, b_file->mode, b_file->size))
 			b_file->flags |= GIT_DIFF_FLAG_VALID_ID;
@@ -1013,7 +1013,7 @@ find_best_matches:
 
 				delta_make_rename(tgt, src, best_match->similarity);
 
-				src->status = (diff->new_src == GIT_ITERATOR_TYPE_WORKDIR) ?
+				src->status = (diff->new_src == GIT_ITERATOR_WORKDIR) ?
 					GIT_DELTA_UNTRACKED : GIT_DELTA_ADDED;
 				src->nfiles = 1;
 				memset(&src->old_file, 0, sizeof(src->old_file));
diff --git a/src/iterator.c b/src/iterator.c
index 28ffddf..e26e2c0 100644
--- a/src/iterator.c
+++ b/src/iterator.c
@@ -405,7 +405,7 @@ int git_iterator_for_nothing(
 	iter = git__calloc(1, sizeof(empty_iterator));
 	GIT_ERROR_CHECK_ALLOC(iter);
 
-	iter->base.type = GIT_ITERATOR_TYPE_EMPTY;
+	iter->base.type = GIT_ITERATOR_EMPTY;
 	iter->base.cb = &callbacks;
 	iter->base.flags = options->flags;
 
@@ -950,7 +950,7 @@ int git_iterator_for_tree(
 	iter = git__calloc(1, sizeof(tree_iterator));
 	GIT_ERROR_CHECK_ALLOC(iter);
 
-	iter->base.type = GIT_ITERATOR_TYPE_TREE;
+	iter->base.type = GIT_ITERATOR_TREE;
 	iter->base.cb = &callbacks;
 
 	if ((error = iterator_init_common(&iter->base,
@@ -974,7 +974,7 @@ int git_iterator_current_tree_entry(
 	tree_iterator_frame *frame;
 	tree_iterator_entry *entry;
 
-	assert(i->type == GIT_ITERATOR_TYPE_TREE);
+	assert(i->type == GIT_ITERATOR_TREE);
 
 	iter = (tree_iterator *)i;
 
@@ -991,7 +991,7 @@ int git_iterator_current_parent_tree(
 	tree_iterator *iter;
 	tree_iterator_frame *frame;
 
-	assert(i->type == GIT_ITERATOR_TYPE_TREE);
+	assert(i->type == GIT_ITERATOR_TREE);
 
 	iter = (tree_iterator *)i;
 
@@ -1271,7 +1271,7 @@ static int filesystem_iterator_entry_hash(
 		return 0;
 	}
 
-	if (iter->base.type == GIT_ITERATOR_TYPE_WORKDIR)
+	if (iter->base.type == GIT_ITERATOR_WORKDIR)
 		return git_repository_hashfile(&entry->id,
 			iter->base.repo, entry->path, GIT_OBJECT_BLOB, NULL);
 
@@ -1668,8 +1668,8 @@ int git_iterator_current_workdir_path(git_buf **out, git_iterator *i)
 	filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base);
 	const git_index_entry *entry;
 
-	if (i->type != GIT_ITERATOR_TYPE_FS &&
-		i->type != GIT_ITERATOR_TYPE_WORKDIR) {
+	if (i->type != GIT_ITERATOR_FS &&
+		i->type != GIT_ITERATOR_WORKDIR) {
 		*out = NULL;
 		return 0;
 	}
@@ -1727,7 +1727,7 @@ bool git_iterator_current_is_ignored(git_iterator *i)
 {
 	filesystem_iterator *iter = NULL;
 
-	if (i->type != GIT_ITERATOR_TYPE_WORKDIR)
+	if (i->type != GIT_ITERATOR_WORKDIR)
 		return false;
 
 	iter = GIT_CONTAINER_OF(i, filesystem_iterator, base);
@@ -1740,7 +1740,7 @@ bool git_iterator_current_tree_is_ignored(git_iterator *i)
 	filesystem_iterator *iter = GIT_CONTAINER_OF(i, filesystem_iterator, base);
 	filesystem_iterator_frame *frame;
 
-	if (i->type != GIT_ITERATOR_TYPE_WORKDIR)
+	if (i->type != GIT_ITERATOR_WORKDIR)
 		return false;
 
 	frame = filesystem_iterator_current_frame(iter);
@@ -1894,7 +1894,7 @@ static int iterator_for_filesystem(
 	const char *root,
 	git_index *index,
 	git_tree *tree,
-	git_iterator_type_t type,
+	git_iterator_t type,
 	git_iterator_options *options)
 {
 	filesystem_iterator *iter;
@@ -1971,7 +1971,7 @@ int git_iterator_for_filesystem(
 	git_iterator_options *options)
 {
 	return iterator_for_filesystem(out,
-		NULL, root, NULL, NULL, GIT_ITERATOR_TYPE_FS, options);
+		NULL, root, NULL, NULL, GIT_ITERATOR_FS, options);
 }
 
 int git_iterator_for_workdir_ext(
@@ -1999,7 +1999,7 @@ int git_iterator_for_workdir_ext(
 		GIT_ITERATOR_IGNORE_DOT_GIT;
 
 	return iterator_for_filesystem(out,
-		repo, repo_workdir, index, tree, GIT_ITERATOR_TYPE_WORKDIR, &options);
+		repo, repo_workdir, index, tree, GIT_ITERATOR_WORKDIR, &options);
 }
 
 
@@ -2248,7 +2248,7 @@ int git_iterator_for_index(
 	iter = git__calloc(1, sizeof(index_iterator));
 	GIT_ERROR_CHECK_ALLOC(iter);
 
-	iter->base.type = GIT_ITERATOR_TYPE_INDEX;
+	iter->base.type = GIT_ITERATOR_INDEX;
 	iter->base.cb = &callbacks;
 
 	if ((error = iterator_init_common(&iter->base, repo, index, options)) < 0 ||
diff --git a/src/iterator.h b/src/iterator.h
index bbe357f..ebd6936 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -17,12 +17,12 @@
 typedef struct git_iterator git_iterator;
 
 typedef enum {
-	GIT_ITERATOR_TYPE_EMPTY = 0,
-	GIT_ITERATOR_TYPE_TREE = 1,
-	GIT_ITERATOR_TYPE_INDEX = 2,
-	GIT_ITERATOR_TYPE_WORKDIR = 3,
-	GIT_ITERATOR_TYPE_FS = 4,
-} git_iterator_type_t;
+	GIT_ITERATOR_EMPTY = 0,
+	GIT_ITERATOR_TREE = 1,
+	GIT_ITERATOR_INDEX = 2,
+	GIT_ITERATOR_WORKDIR = 3,
+	GIT_ITERATOR_FS = 4,
+} git_iterator_t;
 
 typedef enum {
 	/** ignore case for entry sort order */
@@ -78,7 +78,7 @@ typedef struct {
 } git_iterator_callbacks;
 
 struct git_iterator {
-	git_iterator_type_t type;
+	git_iterator_t type;
 	git_iterator_callbacks *cb;
 
 	git_repository *repo;
@@ -238,7 +238,7 @@ GIT_INLINE(int) git_iterator_reset(git_iterator *iter)
 extern int git_iterator_reset_range(
 	git_iterator *iter, const char *start, const char *end);
 
-GIT_INLINE(git_iterator_type_t) git_iterator_type(git_iterator *iter)
+GIT_INLINE(git_iterator_t) git_iterator_type(git_iterator *iter)
 {
 	return iter->type;
 }
diff --git a/src/pathspec.c b/src/pathspec.c
index 9eb9523..19ea9eb 100644
--- a/src/pathspec.c
+++ b/src/pathspec.c
@@ -422,7 +422,7 @@ static int pathspec_match_from_iterator(
 	if ((error = git_iterator_reset_range(iter, ps->prefix, ps->prefix)) < 0)
 		goto done;
 
-	if (git_iterator_type(iter) == GIT_ITERATOR_TYPE_WORKDIR &&
+	if (git_iterator_type(iter) == GIT_ITERATOR_WORKDIR &&
 		(error = git_repository_index__weakptr(
 			&index, git_iterator_owner(iter))) < 0)
 		goto done;
diff --git a/src/status.c b/src/status.c
index 42c98f6..6a12844 100644
--- a/src/status.c
+++ b/src/status.c
@@ -87,14 +87,14 @@ static unsigned int workdir_delta2status(
 			 * discern between RENAMED vs RENAMED+MODIFED
 			 */
 			if (git_oid_is_zero(&idx2wd->old_file.id) &&
-				diff->old_src == GIT_ITERATOR_TYPE_WORKDIR &&
+				diff->old_src == GIT_ITERATOR_WORKDIR &&
 				!git_diff__oid_for_file(
 					&idx2wd->old_file.id, diff, idx2wd->old_file.path,
 					idx2wd->old_file.mode, idx2wd->old_file.size))
 			idx2wd->old_file.flags |= GIT_DIFF_FLAG_VALID_ID;
 
 			if (git_oid_is_zero(&idx2wd->new_file.id) &&
-				diff->new_src == GIT_ITERATOR_TYPE_WORKDIR &&
+				diff->new_src == GIT_ITERATOR_WORKDIR &&
 				!git_diff__oid_for_file(
 					&idx2wd->new_file.id, diff, idx2wd->new_file.path,
 					idx2wd->new_file.mode, idx2wd->new_file.size))