Volume XXII, number 280Wednesday, October 7, 2026Latest message 58 minutes ago

The Git List

News and archive of git@vger.kernel.org, since April 2005

patcht7703: ignore 'total' line when comparing ls -l output

2 messages between May 4, 2026 and May 5, 2026, from Joerg Thalheim, Patrick Steinhardt.

Plain Markdown or JSON for tools and agents. Diffs are folded; open one to read it.

Joerg ThalheimMay 4, 2026, 10:14 UTC on lore
From: Jörg Thalheim <joerg@thalheim.io>

The 'total N' header from ls -l reports the block count, which on copy-on-write or compressing filesystems such as ZFS can change between two back-to-back invocations even when the directory contents are identical. The MIDX retention checks introduced in 6ce9d558ce (midx-write: skip rewriting MIDX with --stdin-packs unless needed, 2025-12-11) compare full ls -l output and thus fail spuriously on such filesystems. Strip the header line before comparing.

Signed-off-by: Jörg Thalheim <joerg@thalheim.io>
---
 t/t7703-repack-geometric.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Show changes to t/t7703-repack-geometric.sh +4 −4
diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh
index 04d5d8fc33..9b5a428620 100755
--- a/t/t7703-repack-geometric.sh
+++ b/t/t7703-repack-geometric.sh
@@ -299,9 +299,9 @@ test_expect_success '--geometric --write-midx retains up-to-date MIDX without bi
 		test_path_is_file .git/objects/pack/multi-pack-index &&
 		test-tool chmtime =0 .git/objects/pack/multi-pack-index &&
 
-		ls -l .git/objects/pack/ >expect &&
+		ls -l .git/objects/pack/ | sed 1d >expect &&
 		git repack --geometric=2 --write-midx --no-write-bitmap-index &&
-		ls -l .git/objects/pack/ >actual &&
+		ls -l .git/objects/pack/ | sed 1d >actual &&
 		test_cmp expect actual
 	)
 '
@@ -316,9 +316,9 @@ test_expect_success '--geometric --write-midx retains up-to-date MIDX with bitma
 	test_path_is_file repo/.git/objects/pack/multi-pack-index &&
 	test-tool chmtime =0 repo/.git/objects/pack/multi-pack-index &&
 
-	ls -l repo/.git/objects/pack/ >expect &&
+	ls -l repo/.git/objects/pack/ | sed 1d >expect &&
 	git -C repo repack --geometric=2 --write-midx --write-bitmap-index &&
-	ls -l repo/.git/objects/pack/ >actual &&
+	ls -l repo/.git/objects/pack/ | sed 1d >actual &&
 	test_cmp expect actual
 '
 

base-commit: 94f057755b7941b321fd11fec1b2e3ca5313a4e0
-- 
2.53.0
Patrick SteinhardtMay 5, 2026, 06:02 UTC in reply to Joerg Thalheim on lore

Re: [PATCH] t7703: ignore 'total' line when comparing ls -l output

On Mon, May 04, 2026 at 12:14:29PM +0200, Joerg Thalheim wrote:
Show 27 quoted lines
> diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh
> index 04d5d8fc33..9b5a428620 100755
> --- a/t/t7703-repack-geometric.sh
> +++ b/t/t7703-repack-geometric.sh
> @@ -299,9 +299,9 @@ test_expect_success '--geometric --write-midx retains up-to-date MIDX without bi
>  		test_path_is_file .git/objects/pack/multi-pack-index &&
>  		test-tool chmtime =0 .git/objects/pack/multi-pack-index &&
>  
> -		ls -l .git/objects/pack/ >expect &&
> +		ls -l .git/objects/pack/ | sed 1d >expect &&
>  		git repack --geometric=2 --write-midx --no-write-bitmap-index &&
> -		ls -l .git/objects/pack/ >actual &&
> +		ls -l .git/objects/pack/ | sed 1d >actual &&
>  		test_cmp expect actual
>  	)
>  '
> @@ -316,9 +316,9 @@ test_expect_success '--geometric --write-midx retains up-to-date MIDX with bitma
>  	test_path_is_file repo/.git/objects/pack/multi-pack-index &&
>  	test-tool chmtime =0 repo/.git/objects/pack/multi-pack-index &&
>  
> -	ls -l repo/.git/objects/pack/ >expect &&
> +	ls -l repo/.git/objects/pack/ | sed 1d >expect &&
>  	git -C repo repack --geometric=2 --write-midx --write-bitmap-index &&
> -	ls -l repo/.git/objects/pack/ >actual &&
> +	ls -l repo/.git/objects/pack/ | sed 1d >actual &&
>  	test_cmp expect actual
>  '

Hm. So all we're interested in is the mtime of these files as an indicator whether they have been rewritten or not. I don't think there's an easy, portable via POSIX tooling to retrieve that. But we don't need it, because our test-tool already supports this functionality:

    $ test-tool chmtime --get <files>
So how about we do the below patch instead?
Thanks!
Patrick
Show changes to t/t7703-repack-geometric.sh +4 −4
diff --git a/t/t7703-repack-geometric.sh b/t/t7703-repack-geometric.sh
index 04d5d8fc33..ec7032bf5d 100755
--- a/t/t7703-repack-geometric.sh
+++ b/t/t7703-repack-geometric.sh
@@ -299,9 +299,9 @@ test_expect_success '--geometric --write-midx retains up-to-date MIDX without bi
 		test_path_is_file .git/objects/pack/multi-pack-index &&
 		test-tool chmtime =0 .git/objects/pack/multi-pack-index &&
 
-		ls -l .git/objects/pack/ >expect &&
+		test-tool chmtime --get .git/objects/pack/* >expect &&
 		git repack --geometric=2 --write-midx --no-write-bitmap-index &&
-		ls -l .git/objects/pack/ >actual &&
+		test-tool chmtime --get .git/objects/pack/* >actual &&
 		test_cmp expect actual
 	)
 '
@@ -316,9 +316,9 @@ test_expect_success '--geometric --write-midx retains up-to-date MIDX with bitma
 	test_path_is_file repo/.git/objects/pack/multi-pack-index &&
 	test-tool chmtime =0 repo/.git/objects/pack/multi-pack-index &&
 
-	ls -l repo/.git/objects/pack/ >expect &&
+	test-tool chmtime --get repo/.git/objects/pack/* >expect &&
 	git -C repo repack --geometric=2 --write-midx --write-bitmap-index &&
-	ls -l repo/.git/objects/pack/ >actual &&
+	test-tool chmtime --get repo/.git/objects/pack/* >actual &&
 	test_cmp expect actual
 '

Back to recent threads