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

[RFC PATCH 4/5] test-oidmap: add 'get_all' subcommand

From
Christian Couder <christian.couder@gmail.com>
Date
Jul 7, 2019, 08:30 UTC
Message-ID
<20190707083002.7037-5-chriscool@tuxfamily.org>
In-Reply-To
<20190707083002.7037-1-chriscool@tuxfamily.org>

Let's make it possible to test oidmap_get_next() by adding a 'get_all' subcommand that calls oidmap_get() once first and then oidmap_get_next() several times until there is no more entry with the same oid key.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 t/helper/test-oidmap.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index c19b41aa4f..5c4897ce59 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -95,6 +95,23 @@ int cmd__oidmap(int argc, const char **argv)
 			/* print result */
 			puts(entry ? entry->name : "NULL");
 
+		} else if (!strcmp("get_all", cmd) && p1) {
+
+			if (get_oid(p1, &oid)) {
+				printf("Unknown oid: %s\n", p1);
+				continue;
+			}
+
+			/* lookup entry in oidmap */
+			entry = oidmap_get(&map, &oid);
+
+			/* print result */
+			puts(entry ? entry->name : "NULL");
+
+			if (entry)
+				while ((entry = oidmap_get_next(&map, entry)))
+					puts(entry ? entry->name : "NULL");
+
 		} else if (!strcmp("remove", cmd) && p1) {
 
 			if (get_oid(p1, &oid)) {
-- 
2.22.0.514.g3228928bce.dirty
Previous: Christian CouderNext: Christian Couder
Message 5 of 9 in “oidmap: handle entries with the same key”
  1. 0/5 oidmap: handle entries with the same keyChristian Couder, Jul 7, 2019
  2. 1/5 oidmap: add oidmap_add()Christian Couder, Jul 7, 2019
  3. 2/5 oidmap: add oidmap_get_next()Christian Couder, Jul 7, 2019
  4. 3/5 test-oidmap: add back proper 'add' subcommandChristian Couder, Jul 7, 2019
  5. 4/5 test-oidmap: add 'get_all' subcommandChristian Couder, Jul 7, 2019
  6. 5/5 t0016: add 'add' and 'get_all' subcommand testChristian Couder, Jul 7, 2019
  7. Junio C HamanoJul 8, 2019
  8. Junio C HamanoJul 12, 2019
  9. Jeff KingJul 12, 2019

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.