Skip to contentSkip to conversation

Make git_check_attr() a void function

PATCH New [email protected] 1 participant 1 message Sep 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make git_check_attr() a void function

From: Torsten Bögershausen <[email protected]>

git_check_attr() returns always 0.
Remove all the error handling code of the callers, which is never executed. Change git_check_attr() to be a void function.

---
 archive.c              |  3 ++-
 attr.c                 |  8 +++-----
 attr.h                 |  4 ++--
 builtin/check-attr.c   |  3 +--
 builtin/pack-objects.c |  3 +--
 convert.c              | 42 ++++++++++++++++++----------------------
 ll-merge.c             | 16 +++++++--------
 userdiff.c             |  3 +--
 ws.c                   | 44 +++++++++++++++++++-----------------------
 9 files changed, 57 insertions(+), 69 deletions(-)
archive.c +2 -1
index 0a07b140fe..c1870105eb 100644
@@ -110,7 +110,8 @@ static const struct attr_check *get_archive_attrs(struct index_state *istate,
 	static struct attr_check *check;
 	if (!check)
 		check = attr_check_initl("export-ignore", "export-subst", NULL);
-	return git_check_attr(istate, path, check) ? NULL : check;
+	git_check_attr(istate, path, check);
+	return check;
 }
 
 static int check_attr_export_ignore(const struct attr_check *check)
attr.c +3 -5
index 98e4953f6e..60d284796d 100644
@@ -1143,9 +1143,9 @@ static void collect_some_attrs(const struct index_state *istate,
 	fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem);
 }
 
-int git_check_attr(const struct index_state *istate,
-		   const char *path,
-		   struct attr_check *check)
+void git_check_attr(const struct index_state *istate,
+		    const char *path,
+		    struct attr_check *check)
 {
 	int i;
 
@@ -1158,8 +1158,6 @@ int git_check_attr(const struct index_state *istate,
 			value = ATTR__UNSET;
 		check->items[i].value = value;
 	}
-
-	return 0;
 }
 
 void git_all_attrs(const struct index_state *istate,
attr.h +2 -2
index 2be86db36e..b0378bfe5f 100644
@@ -63,8 +63,8 @@ void attr_check_free(struct attr_check *check);
  */
 const char *git_attr_name(const struct git_attr *);
 
-int git_check_attr(const struct index_state *istate,
-		   const char *path, struct attr_check *check);
+void git_check_attr(const struct index_state *istate,
+		    const char *path, struct attr_check *check);
 
 /*
  * Retrieve all attributes that apply to the specified path.
builtin/check-attr.c +1 -2
index c05573ff9c..30a2f84274 100644
@@ -65,8 +65,7 @@ static void check_attr(const char *prefix,
 	if (collect_all) {
 		git_all_attrs(&the_index, full_path, check);
 	} else {
-		if (git_check_attr(&the_index, full_path, check))
-			die("git_check_attr died");
+		git_check_attr(&the_index, full_path, check);
 	}
 	output_attr(check, file);
 
builtin/pack-objects.c +1 -2
index d1144a8f7e..eb71dab5be 100644
@@ -951,8 +951,7 @@ static int no_try_delta(const char *path)
 
 	if (!check)
 		check = attr_check_initl("delta", NULL);
-	if (git_check_attr(&the_index, path, check))
-		return 0;
+	git_check_attr(&the_index, path, check);
 	if (ATTR_FALSE(check->items[0].value))
 		return 1;
 	return 0;
convert.c +19 -23

55 lines not on this page · raw message

ll-merge.c +8 -8
index 0e2800f7bb..1936fee9e1 100644
@@ -371,13 +371,12 @@ int ll_merge(mmbuffer_t *result_buf,
 	if (!check)
 		check = attr_check_initl("merge", "conflict-marker-size", NULL);
 
-	if (!git_check_attr(&the_index, path, check)) {
-		ll_driver_name = check->items[0].value;
-		if (check->items[1].value) {
-			marker_size = atoi(check->items[1].value);
-			if (marker_size <= 0)
-				marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
-		}
+	git_check_attr(&the_index, path, check);
+	ll_driver_name = check->items[0].value;
+	if (check->items[1].value) {
+		marker_size = atoi(check->items[1].value);
+		if (marker_size <= 0)
+			marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
 	}
 	driver = find_ll_merge_driver(ll_driver_name);
 
@@ -398,7 +397,8 @@ int ll_merge_marker_size(const char *path)
 
 	if (!check)
 		check = attr_check_initl("conflict-marker-size", NULL);
-	if (!git_check_attr(&the_index, path, check) && check->items[0].value) {
+	git_check_attr(&the_index, path, check);
+	if (check->items[0].value) {
 		marker_size = atoi(check->items[0].value);
 		if (marker_size <= 0)
 			marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
userdiff.c +1 -2
index f3f4be579c..f565f6731d 100644
@@ -278,8 +278,7 @@ struct userdiff_driver *userdiff_find_by_path(const char *path)
 		check = attr_check_initl("diff", NULL);
 	if (!path)
 		return NULL;
-	if (git_check_attr(&the_index, path, check))
-		return NULL;
+	git_check_attr(&the_index, path, check);
 
 	if (ATTR_TRUE(check->items[0].value))
 		return &driver_true;
ws.c +20 -24

55 lines not on this page · raw message

Signature · 1 line
2.18.0