git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] attr.c: split path processing code out of collect_all_attrs()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 9, 2014, 13:53 UTC
Message-ID
<1418133205-18213-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1418133205-18213-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 attr.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/attr.c b/attr.c
index 583d36a..def09c7 100644
--- a/attr.c
+++ b/attr.c
@@ -705,14 +705,9 @@ static int macroexpand_one(int attr_nr, int rem)
 	return rem;
 }
 
-/*
- * Collect all attributes for path into the array pointed to by
- * check_all_attr.
- */
-static void collect_all_attrs(const char *path)
+static int split_path(const char *path, int *dirlen_p, int *basename_offset_p)
 {
-	struct attr_stack *stk;
-	int i, pathlen, rem, dirlen;
+	int pathlen, dirlen;
 	const char *cp, *last_slash = NULL;
 	int basename_offset;
 
@@ -728,7 +723,22 @@ static void collect_all_attrs(const char *path)
 		basename_offset = 0;
 		dirlen = 0;
 	}
+	*dirlen_p = dirlen;
+	*basename_offset_p = basename_offset;
+	return pathlen;
+}
+
+/*
+ * Collect all attributes for path into the array pointed to by
+ * check_all_attr.
+ */
+static void collect_all_attrs(const char *path)
+{
+	struct attr_stack *stk;
+	int i, pathlen, rem, dirlen;
+	int basename_offset;
 
+	pathlen = split_path(path, &dirlen, &basename_offset);
 	prepare_attr_stack(path, dirlen);
 	for (i = 0; i < git_attr_nr; i++)
 		check_all_attr[i].value = ATTR__UNKNOWN;
-- 
2.2.0.84.ge9c7a8a
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 4 of 16 in “some attr optimizations”
  1. 0/4 some attr optimizationsNguyễn Thái Ngọc Duy, Dec 9, 2014
  2. 1/4 attr.c: rename global var attr_nr to git_attr_nrNguyễn Thái Ngọc Duy, Dec 9, 2014
  3. Junio C HamanoDec 9, 2014
  4. 2/4 attr.c: split path processing code out of collect_all_attrs()Nguyễn Thái Ngọc Duy, Dec 9, 2014
  5. 3/4 attr: do not attempt to expand when we know it's not a macroNguyễn Thái Ngọc Duy, Dec 9, 2014
  6. Eric SunshineDec 9, 2014
  7. Junio C HamanoDec 9, 2014
  8. 4/4 attr: avoid heavy work when we know the specified attr is not definedNguyễn Thái Ngọc Duy, Dec 9, 2014
  9. Junio C HamanoDec 10, 2014
  10. Duy NguyenDec 15, 2014
  11. Junio C HamanoDec 15, 2014
  12. 0/3 some attr optimizationsNguyễn Thái Ngọc Duy, Dec 27, 2014
  13. 1/3 attr.c: rename arg name attr_nr to avoid shadowing the global oneNguyễn Thái Ngọc Duy, Dec 27, 2014
  14. 2/3 attr: do not attempt to expand when we know it's not a macroNguyễn Thái Ngọc Duy, Dec 27, 2014
  15. Eric SunshineDec 27, 2014
  16. 3/3 attr: avoid heavy work when we know the specified attr is not definedNguyễn Thái Ngọc Duy, Dec 27, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.