]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/reftable-unit-test-nfs-workaround'
authorJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2024 20:21:35 +0000 (13:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2024 20:21:35 +0000 (13:21 -0700)
A unit test for reftable code tried to enumerate all files in a
directory after reftable operations and expected to see nothing but
the files it wanted to leave there, but was fooled by .nfs* cruft
files left, which has been corrected.

* ps/reftable-unit-test-nfs-workaround:
  reftable: fix tests being broken by NFS' delete-after-close semantics

reftable/stack_test.c

index 7336757cf534058dd6f3e8346d15874036c5b763..0dc9a44648e45ec3b61b9b4572ecd504035f11d8 100644 (file)
@@ -38,7 +38,17 @@ static int count_dir_entries(const char *dirname)
                return 0;
 
        while ((d = readdir(dir))) {
-               if (!strcmp(d->d_name, "..") || !strcmp(d->d_name, "."))
+               /*
+                * Besides skipping over "." and "..", we also need to
+                * skip over other files that have a leading ".". This
+                * is due to behaviour of NFS, which will rename files
+                * to ".nfs*" to emulate delete-on-last-close.
+                *
+                * In any case this should be fine as the reftable
+                * library will never write files with leading dots
+                * anyway.
+                */
+               if (starts_with(d->d_name, "."))
                        continue;
                len++;
        }