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

Re: [ANNOUNCE] Git v2.23.0-rc0 - Initial test failures on NonStop

From
Jeff King <peff@peff.net>
Date
Jul 31, 2019, 03:53 UTC
Message-ID
<20190731035344.GA26019@sigill.intra.peff.net>
In-Reply-To
<20190731032735.GA14684@sigill.intra.peff.net>
On Tue, Jul 30, 2019 at 11:27:35PM -0400, Jeff King wrote:
Show 5 quoted lines
> That would perhaps be clearer if the "hashmap" tool actually did the
> sorting itself (so we'd sort _just_ the iteration, not the whole
> output). Something like this, though I'm on the fence about whether it
> is worth it:
> [...]

And here it is for reference with the matching change in test-oidmap, and the adjustments necessary for the test scripts (from master, not from my earlier patch). I think I prefer the simpler "just sort it all" version I posted with the commit message.

The post-image in t0016 may be a new low: a command substitution in a DQ string fed to echo, itself inside a command substitution in a here-doc. Yuck. :)

---
diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c
index aaf17b0ddf..9f6901666e 100644
--- a/t/helper/test-hashmap.c
+++ b/t/helper/test-hashmap.c
@@ -2,6 +2,7 @@
 #include "git-compat-util.h"
 #include "hashmap.h"
 #include "strbuf.h"
+#include "string-list.h"
 
 struct test_entry
 {
@@ -221,10 +222,18 @@ int cmd__hashmap(int argc, const char **argv)
 
 		} else if (!strcmp("iterate", cmd)) {
 
+			struct string_list sorted = STRING_LIST_INIT_NODUP;
+			struct string_list_item *item;
 			struct hashmap_iter iter;
 			hashmap_iter_init(&map, &iter);
-			while ((entry = hashmap_iter_next(&iter)))
-				printf("%s %s\n", entry->key, get_value(entry));
+			while ((entry = hashmap_iter_next(&iter))) {
+				item = string_list_append(&sorted, entry->key);
+				item->util = (void *)get_value(entry);
+			}
+			string_list_sort(&sorted);
+			for_each_string_list_item(item, &sorted)
+				printf("%s %s\n", item->string, (const char *)item->util);
+			string_list_clear(&sorted, 0);
 
 		} else if (!strcmp("size", cmd)) {
 
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index 0acf99931e..5fd059fe90 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -94,10 +94,19 @@ int cmd__oidmap(int argc, const char **argv)
 
 		} else if (!strcmp("iterate", cmd)) {
 
+			struct string_list sorted = STRING_LIST_INIT_DUP;
+			struct string_list_item *item;
 			struct oidmap_iter iter;
 			oidmap_iter_init(&map, &iter);
-			while ((entry = oidmap_iter_next(&iter)))
-				printf("%s %s\n", oid_to_hex(&entry->entry.oid), entry->name);
+			while ((entry = oidmap_iter_next(&iter))) {
+				item = string_list_append(&sorted,
+							  oid_to_hex(&entry->entry.oid));
+				item->util = entry->name;
+			}
+			string_list_sort(&sorted);
+			for_each_string_list_item(item, &sorted)
+				printf("%s %s\n", item->string, (const char *)item->util);
+			string_list_clear(&sorted, 0);
 
 		} else {
 
diff --git a/t/t0011-hashmap.sh b/t/t0011-hashmap.sh
index 9c96b3e3b1..1adcd7762d 100755
--- a/t/t0011-hashmap.sh
+++ b/t/t0011-hashmap.sh
@@ -177,9 +177,9 @@ put fooBarFrotz value3
 iterate" "NULL
 NULL
 NULL
-key2 value2
+fooBarFrotz value3
 key1 value1
-fooBarFrotz value3"
+key2 value2"
 
 '
 
@@ -192,8 +192,8 @@ iterate" "NULL
 NULL
 NULL
 fooBarFrotz value3
-key2 value2
-key1 value1" ignorecase
+key1 value1
+key2 value2" ignorecase
 
 '
 
diff --git a/t/t0016-oidmap.sh b/t/t0016-oidmap.sh
index bbe719e950..abeaa64159 100755
--- a/t/t0016-oidmap.sh
+++ b/t/t0016-oidmap.sh
@@ -93,9 +93,14 @@ put three 3
 iterate" "NULL
 NULL
 NULL
-$(git rev-parse two) 2
-$(git rev-parse one) 1
-$(git rev-parse three) 3"
+$(
+	# sort to avoid relying on exact oids
+	{
+		echo "$(git rev-parse one) 1"
+		echo "$(git rev-parse two) 2"
+		echo "$(git rev-parse three) 3"
+	} | sort
+)"
 
 '
 
Previous: Jeff KingNext: Junio C Hamano
Message 17 of 24 in “RE: [ANNOUNCE] Git v2.23.0-rc0 - Initial test failures on NonStop”
  1. Randall S. BeckerJul 30, 2019
  2. Junio C HamanoJul 30, 2019
  3. Matheus Tavares BernardinoJul 30, 2019
  4. Randall S. BeckerJul 30, 2019
  5. Junio C HamanoJul 30, 2019
  6. Jeff KingJul 30, 2019
  7. Randall S. BeckerJul 30, 2019
  8. Todd ZullingerJul 30, 2019
  9. Jeff KingJul 30, 2019
  10. Junio C HamanoJul 30, 2019
  11. SZEDER GáborJul 30, 2019
  12. Jeff KingJul 31, 2019
  13. Jeff KingJul 31, 2019
  14. Jeff KingJul 31, 2019
  15. Todd ZullingerJul 31, 2019
  16. Jeff KingJul 31, 2019
  17. Jeff KingJul 31, 2019
  18. Junio C HamanoJul 31, 2019
  19. non-cryptographic hash algorithms in gitJeff King, Jul 31, 2019
  20. René ScharfeJul 31, 2019
  21. Jeff KingJul 31, 2019
  22. Todd ZullingerJul 31, 2019
  23. Junio C HamanoJul 31, 2019
  24. Randall S. BeckerJul 30, 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.