Thread (24 messages) flat view 24 messages, 1 author, 2016-06-15
DORMANTno replies

Revision v3 of 3 in this series.

Revisions (3)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 current

[PATCH v3 09/23] Teach prepare_attr_stack() to figure out dirlen itself

From: Michael Haggerty <hidden>
Date: 2016-06-15 22:51:44
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Michael Haggerty <redacted>
---
 attr.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/attr.c b/attr.c
index bfa1f43..7f0f390 100644
--- a/attr.c
+++ b/attr.c
@@ -535,11 +535,18 @@ static void bootstrap_attr_stack(void)
 	}
 }
 
-static void prepare_attr_stack(const char *path, int dirlen)
+static void prepare_attr_stack(const char *path)
 {
 	struct attr_stack *elem, *info;
-	int len;
+	int dirlen, len;
 	struct strbuf pathbuf;
+	const char *cp;
+
+	cp = strrchr(path, '/');
+	if (!cp)
+		dirlen = 0;
+	else
+		dirlen = cp - path;
 
 	strbuf_init(&pathbuf, dirlen+2+strlen(GITATTRIBUTES_FILE));
 
@@ -709,20 +716,14 @@ static int macroexpand_one(int attr_nr, int rem)
 int git_checkattr(const char *path, int num, struct git_attr_check *check)
 {
 	struct attr_stack *stk;
-	const char *cp;
-	int dirlen, pathlen, i, rem;
+	int pathlen, i, rem;
 
 	bootstrap_attr_stack();
 	for (i = 0; i < attr_nr; i++)
 		check_all_attr[i].value = ATTR__UNKNOWN;
 
 	pathlen = strlen(path);
-	cp = strrchr(path, '/');
-	if (!cp)
-		dirlen = 0;
-	else
-		dirlen = cp - path;
-	prepare_attr_stack(path, dirlen);
+	prepare_attr_stack(path);
 	rem = attr_nr;
 	for (stk = attr_stack; 0 < rem && stk; stk = stk->prev)
 		rem = fill(path, pathlen, stk, rem);
-- 
1.7.6.8.gd2879
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help