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

Re: [PATCH v2 10/12] attr: convert git_all_attrs() to use "struct git_attr_check"

From
Junio C Hamano <gitster@pobox.com>
Date
May 17, 2016, 21:08 UTC
Message-ID
<xmqq7fesv1d6.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqeg90y5yz.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 5 quoted lines
> Given that one of the two expected callers, namely, "check-attr" and
> Stefan's pathspec label magic, of this "alloc and then append" side
> of the API wants to have an access to git_attr(name), I think
> the function signature for this one should be updated to take not
> "const char *name" but instead take "struct git_attr *attr", i.e.

Perhaps this can be squashed into 12/12 to update the tutorial part to cover this less often used form.

 Documentation/technical/api-gitattributes.txt | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/Documentation/technical/api-gitattributes.txt b/Documentation/technical/api-gitattributes.txt
index 6f13f94..92fc32a 100644
--- a/Documentation/technical/api-gitattributes.txt
+++ b/Documentation/technical/api-gitattributes.txt
@@ -55,7 +55,11 @@ Querying Specific Attributes
 
 * Prepare `struct git_attr_check` using git_attr_check_initl()
   function, enumerating the names of attributes whose values you are
-  interested in, terminated with a NULL pointer.
+  interested in, terminated with a NULL pointer.  Alternatively, an
+  empty `struct git_attr_check` can be prepared by calling
+  `git_attr_check_alloc()` function and then attributes you want to
+  ask about can be added to it with `git_attr_check_append()`
+  function.
 
 * Call `git_check_attr()` to check the attributes for the path.
 
@@ -112,6 +116,22 @@ static void setup_check(void)
 	}
 ------------
 
+To see how attributes in argv[] are set for different paths, only
+the first step in the above would be different.
+
+------------
+static struct git_attr_check *check;
+static void setup_check(const char **argv)
+{
+	check = git_attr_check_alloc();
+	while (*argv) {
+		struct git_attr *attr = git_attr(*argv);
+		git_attr_check_append(check, attr);
+		argv++;
+	}
+}
+------------
+
 
 Querying All Attributes
 -----------------------
Previous: Junio C HamanoNext: Stefan Beller
Message 22 of 27 in “revamping git_check_attr() API”
  1. 00/12 revamping git_check_attr() APIJunio C Hamano, May 16, 2016
  2. 01/12 commit.c: use strchrnul() to scan for one lineJunio C Hamano, May 16, 2016
  3. Stefan BellerMay 16, 2016
  4. Junio C HamanoMay 16, 2016
  5. Stefan BellerMay 16, 2016
  6. 02/12 attr.c: use strchrnul() to scan for one lineJunio C Hamano, May 16, 2016
  7. Stefan BellerMay 16, 2016
  8. Junio C HamanoMay 16, 2016
  9. 03/12 attr.c: update a stale comment on "struct match_attr"Junio C Hamano, May 16, 2016
  10. Stefan BellerMay 16, 2016
  11. Junio C HamanoMay 16, 2016
  12. 04/12 attr.c: explain the lack of attr-name syntax check in parse_attr()Junio C Hamano, May 16, 2016
  13. 05/12 attr.c: complete a sentence in a commentJunio C Hamano, May 16, 2016
  14. 06/12 attr.c: mark where #if DEBUG ends more clearlyJunio C Hamano, May 16, 2016
  15. 07/12 attr.c: simplify macroexpand_one()Junio C Hamano, May 16, 2016
  16. 08/12 attr: rename function and struct related to checking attributesJunio C Hamano, May 16, 2016
  17. 09/12 attr: (re)introduce git_check_attr() and struct git_attr_checkJunio C Hamano, May 16, 2016
  18. Eric SunshineMay 17, 2016
  19. Junio C HamanoMay 17, 2016
  20. 10/12 attr: convert git_all_attrs() to use "struct git_attr_check"Junio C Hamano, May 16, 2016
  21. Junio C HamanoMay 17, 2016
  22. Junio C HamanoMay 17, 2016
  23. Stefan BellerMay 18, 2016
  24. 11/12 attr: convert git_check_attrs() callers to use the new APIJunio C Hamano, May 16, 2016
  25. 12/12 attr: retire git_check_attrs() APIJunio C Hamano, May 16, 2016
  26. Stefan BellerMay 18, 2016
  27. Junio C HamanoMay 18, 2016

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.