diff mbox series

t4216-log-bloom.sh broken ?

Message ID 20240502055621.GA29945@tb-raspi4 (mailing list archive)
State New
Headers show
Series t4216-log-bloom.sh broken ? | expand

Commit Message

Torsten Bögershausen May 2, 2024, 5:56 a.m. UTC
[]

Highjacking the Git v2.45.0 announcement:
There are 4 test cases in t4216-log-bloom.sh, that do not pass on one
Mac here (they pass on another machine)

I haven't digged further, but here are some log files,
hopefully helpful to somebody.


not ok 141 - Bloom reader notices too-small data chunk
#
#               check_corrupt_graph BDAT clear 00000000 &&
#               echo "warning: ignoring too-small changed-path chunk" \
#                       "(4 < 12) in commit-graph file" >expect.err &&
#               test_cmp expect.err err
#
not ok 142 - Bloom reader notices out-of-bounds filter offsets
#
#               check_corrupt_graph BIDX 12 FFFFFFFF &&
#               # use grep to avoid depending on exact chunk size
#               grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err

#
not ok 143 - Bloom reader notices too-small index chunk
#
#               # replace the index with a single entry, making most
#               # lookups out-of-bounds
#               check_corrupt_graph BIDX clear 00000000 &&
#               echo "warning: commit-graph changed-path index chunk" \
#                       "is too small" >expect.err &&
#               test_cmp expect.err err
#
not ok 144 - Bloom reader notices out-of-order index offsets
#
#               # we do not know any real offsets, but we can pick
#               # something plausible; we should not get to the point of
#               # actually reading from the bogus offsets anyway.
#               corrupt_graph BIDX 4 0000000c00000005 &&
#               echo "warning: ignoring decreasing changed-path index offsets" \
#                       "(12 > 5) for positions 1 and 2 of .git/objects/info/commit-graph" >expect.err &&
#               git -c core.commitGraph=false log -- A/B/file2 >expect.out &&
#               git -c core.commitGraph=true log -- A/B/file2 >out 2>err &&
#               test_cmp expect.out out &&
#               test_cmp expect.err err
#
# failed 4 among 144 test(s)
1..144


ok 140 - Bloom generation backfills empty commits

expecting success of 4216.141 'Bloom reader notices too-small data chunk':
	check_corrupt_graph BDAT clear 00000000 &&
	echo "warning: ignoring too-small changed-path chunk" \
		"(4 < 12) in commit-graph file" >expect.err &&
	test_cmp expect.err err

++ check_corrupt_graph BDAT clear 00000000
++ corrupt_graph BDAT clear 00000000
++ graph=.git/objects/info/commit-graph
++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
++ test 0 = 0
++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
		} && (exit "$eval_ret"); eval_ret=$?; :'
++ git commit-graph write --reachable --changed-paths
++ corrupt_chunk_file .git/objects/info/commit-graph BDAT clear 00000000
++ fn=.git/objects/info/commit-graph
++ shift
++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten
++ git -c core.commitGraph=false log -- A/B/file2
++ git -c core.commitGraph=true log -- A/B/file2
++ test_cmp expect.out out
++ test 2 -ne 2
++ eval 'diff -u' '"$@"'
+++ diff -u expect.out out
++ echo 'warning: ignoring too-small changed-path chunk' '(4 < 12) in commit-graph file'
++ test_cmp expect.err err
++ test 2 -ne 2
++ eval 'diff -u' '"$@"'
+++ diff -u expect.err err
error: last command exited with $?=1
++ rm -rf .git/objects/info/commit-graph
++ exit 1
++ eval_ret=1
++ :
not ok 144 - Bloom reader notices out-of-order index offsets

Comments

Junio C Hamano May 2, 2024, 4:06 p.m. UTC | #1
Torsten Bögershausen <tboegi@web.de> writes:

> []
>
> Highjacking the Git v2.45.0 announcement:

I am not sure why you want to do so.  You are perfectly capable of
sending a new message to the list (and I know you have done so in
the past).  Why would linux-kernel@ list want to hear about the
macOS issues?

> There are 4 test cases in t4216-log-bloom.sh, that do not pass on one
> Mac here (they pass on another machine)

Another machine being another mac?

> expecting success of 4216.141 'Bloom reader notices too-small data chunk':
> 	check_corrupt_graph BDAT clear 00000000 &&
> 	echo "warning: ignoring too-small changed-path chunk" \
> 		"(4 < 12) in commit-graph file" >expect.err &&
> 	test_cmp expect.err err
>
> ++ check_corrupt_graph BDAT clear 00000000
> ++ corrupt_graph BDAT clear 00000000
> ++ graph=.git/objects/info/commit-graph
> ++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
> ++ test 0 = 0
> ++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
> 		} && (exit "$eval_ret"); eval_ret=$?; :'
> ++ git commit-graph write --reachable --changed-paths
> ++ corrupt_chunk_file .git/objects/info/commit-graph BDAT clear 00000000
> ++ fn=.git/objects/info/commit-graph
> ++ shift
> ++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> ++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> ++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> ++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
> override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten

Is this failure preventing the later steps of the test work as
expected, I wonder.  Is there something curious with the permission
bits of /Users/tb/NoBackup/projects/git/git.pu/ directory or its t/
subdirectory?  Is there something curious with the "umask" of the
user running the test?  Are they different from what you see on your
other mac that does not exhibit the problems?

Thanks.
Junio C Hamano May 2, 2024, 4:26 p.m. UTC | #2
Torsten Bögershausen <tboegi@web.de> writes:

> ++ check_corrupt_graph BDAT clear 00000000
> ++ corrupt_graph BDAT clear 00000000
> ++ graph=.git/objects/info/commit-graph
> ++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
> ++ test 0 = 0
> ++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
> 		} && (exit "$eval_ret"); eval_ret=$?; :'
> ++ git commit-graph write --reachable --changed-paths
> ++ corrupt_chunk_file .git/objects/info/commit-graph BDAT clear 00000000
> ++ fn=.git/objects/info/commit-graph
> ++ shift
> ++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> ++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> ++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> ++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
> override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten

Another probing question.  Do t5318, t5319, t5324, and t5328 pass?

The "mv" is part of the corrupt_chunk_file helper is used by this:

    corrupt_graph () {
            graph=.git/objects/info/commit-graph &&
            test_when_finished "rm -rf $graph" &&
            git commit-graph write --reachable --changed-paths &&
            corrupt_chunk_file $graph "$@"
    }

and reads like this:

    corrupt_chunk_file () {
            fn=$1; shift
            perl "$TEST_DIRECTORY"/lib-chunk/corrupt-chunk-file.pl \
                    "$@" <"$fn" >"$fn.tmp" &&
            mv "$fn.tmp" "$fn"
    }

If the final "mv" is what is failing in the above trace, the test
tried to corrupt the objects/info/commit-graph file, expecting that
later steps will notice breakage.  But if the broken file written in
commit-graph.tmp failed to become the final commit-graph, later
steps will see healthy graph file and it is understandable that we
do not see any breakage that we expect, thus failing the test.

Is "mv" somehow configured to always go interactive on that box and
on that box alone?  For example if you have ~/bin/mv that does
something silly like

	#!/bin/bash
	exec /bin/mv -i "$@

and have ~/bin early in $PATH, it may be sufficient to explain the
error we see (I am not claiming that is the only way to cause this
test failure; it is just one possible one).
Torsten Bögershausen May 2, 2024, 6:59 p.m. UTC | #3
On Thu, May 02, 2024 at 09:06:41AM -0700, Junio C Hamano wrote:
> Torsten Bögershausen <tboegi@web.de> writes:
>
> > There are 4 test cases in t4216-log-bloom.sh, that do not pass on one
> > Mac here (they pass on another machine)
>
> Another machine being another mac?

Yes, different mac, different MacOs, different $PATH probably.

>
> > expecting success of 4216.141 'Bloom reader notices too-small data chunk':
> > 	check_corrupt_graph BDAT clear 00000000 &&
> > 	echo "warning: ignoring too-small changed-path chunk" \
> > 		"(4 < 12) in commit-graph file" >expect.err &&
> > 	test_cmp expect.err err
> >
> > ++ check_corrupt_graph BDAT clear 00000000
> > ++ corrupt_graph BDAT clear 00000000
> > ++ graph=.git/objects/info/commit-graph
> > ++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
> > ++ test 0 = 0
> > ++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
> > 		} && (exit "$eval_ret"); eval_ret=$?; :'
> > ++ git commit-graph write --reachable --changed-paths
> > ++ corrupt_chunk_file .git/objects/info/commit-graph BDAT clear 00000000
> > ++ fn=.git/objects/info/commit-graph
> > ++ shift
> > ++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> > ++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> > ++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> > ++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
> > override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten
>
> Is this failure preventing the later steps of the test work as
> expected, I wonder.  Is there something curious with the permission
> bits of /Users/tb/NoBackup/projects/git/git.pu/ directory or its t/
> subdirectory?  Is there something curious with the "umask" of the
> user running the test?  Are they different from what you see on your
> other mac that does not exhibit the problems?
>
> Thanks.
>
>

mv is /bin/mv, that seems to be good:

$ type mv
mv is /bin/mv

$ alias | grep mv

$ which mv
/bin/mv

$ umask
0022

I don't know, why we see
r--r--r--  tb/staff for .git/objects/info/commit-graph

But, the "-r--r--r--" may be part of the problem, here is another one:
$ find . -name commit-graph -print0 | xargs -0 ls -l
-r--r--r--  1 tb  staff  1792 May  2 12:12 ./trash directory.t5318-commit-graph/bare/objects/info/commit-graph
(And some more 6 in total. All with -r--r--r--)

Which means, yes, t5318 does not pass either:
t5318-commit-graph.sh not ok 101 - reader notices too-small oid fanout chunk
t5318-commit-graph.sh not ok 102 - reader notices fanout/lookup table mismatch
t5318-commit-graph.sh not ok 103 - reader notices out-of-bounds fanout
t5318-commit-graph.sh not ok 104 - reader notices too-small commit data chunk
t5318-commit-graph.sh not ok 105 - reader notices out-of-bounds extra edge
t5318-commit-graph.sh not ok 106 - reader notices too-small generations chunk

Same problem here:
++ mv full/.git/objects/info/commit-graph.tmp full/.git/objects/info/commit-graph
override r--r--r--  tb/staff for full/.git/objects/info/commit-graph? (y/n [n]) not overwritten

The rest of the test suite passes, I see the same failures even under a
fresh cloned repo.

Any hints are appreciated.
SZEDER Gábor May 2, 2024, 7:26 p.m. UTC | #4
On Thu, May 02, 2024 at 08:59:03PM +0200, Torsten Bögershausen wrote:
> On Thu, May 02, 2024 at 09:06:41AM -0700, Junio C Hamano wrote:
> > Torsten Bögershausen <tboegi@web.de> writes:
> >
> > > There are 4 test cases in t4216-log-bloom.sh, that do not pass on one
> > > Mac here (they pass on another machine)
> >
> > Another machine being another mac?
> 
> Yes, different mac, different MacOs, different $PATH probably.
> 
> >
> > > expecting success of 4216.141 'Bloom reader notices too-small data chunk':
> > > 	check_corrupt_graph BDAT clear 00000000 &&
> > > 	echo "warning: ignoring too-small changed-path chunk" \
> > > 		"(4 < 12) in commit-graph file" >expect.err &&
> > > 	test_cmp expect.err err
> > >
> > > ++ check_corrupt_graph BDAT clear 00000000
> > > ++ corrupt_graph BDAT clear 00000000
> > > ++ graph=.git/objects/info/commit-graph
> > > ++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
> > > ++ test 0 = 0
> > > ++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
> > > 		} && (exit "$eval_ret"); eval_ret=$?; :'
> > > ++ git commit-graph write --reachable --changed-paths
> > > ++ corrupt_chunk_file .git/objects/info/commit-graph BDAT clear 00000000
> > > ++ fn=.git/objects/info/commit-graph
> > > ++ shift
> > > ++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> > > ++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> > > ++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BDAT clear 00000000
> > > ++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
> > > override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten
> >
> > Is this failure preventing the later steps of the test work as
> > expected, I wonder.  Is there something curious with the permission
> > bits of /Users/tb/NoBackup/projects/git/git.pu/ directory or its t/
> > subdirectory?  Is there something curious with the "umask" of the
> > user running the test?  Are they different from what you see on your
> > other mac that does not exhibit the problems?
> >
> > Thanks.
> >
> >
> 
> mv is /bin/mv, that seems to be good:
> 
> $ type mv
> mv is /bin/mv
> 
> $ alias | grep mv
> 
> $ which mv
> /bin/mv
> 
> $ umask
> 0022
> 
> I don't know, why we see
> r--r--r--  tb/staff for .git/objects/info/commit-graph
> 
> But, the "-r--r--r--" may be part of the problem, here is another one:
> $ find . -name commit-graph -print0 | xargs -0 ls -l
> -r--r--r--  1 tb  staff  1792 May  2 12:12 ./trash directory.t5318-commit-graph/bare/objects/info/commit-graph
> (And some more 6 in total. All with -r--r--r--)
> 
> Which means, yes, t5318 does not pass either:
> t5318-commit-graph.sh not ok 101 - reader notices too-small oid fanout chunk
> t5318-commit-graph.sh not ok 102 - reader notices fanout/lookup table mismatch
> t5318-commit-graph.sh not ok 103 - reader notices out-of-bounds fanout
> t5318-commit-graph.sh not ok 104 - reader notices too-small commit data chunk
> t5318-commit-graph.sh not ok 105 - reader notices out-of-bounds extra edge
> t5318-commit-graph.sh not ok 106 - reader notices too-small generations chunk
> 
> Same problem here:
> ++ mv full/.git/objects/info/commit-graph.tmp full/.git/objects/info/commit-graph
> override r--r--r--  tb/staff for full/.git/objects/info/commit-graph? (y/n [n]) not overwritten

'mv' in macOS doesn't conform to POSIX, and asks for confirmation when
the destination exists (is read-only?) even without '-i' and even when
its stdin is not a terminal, which it won't get as its stdin in our
test suite is redirected from /dev/null.

This is a recurring issue, see e.g.:

  https://public-inbox.org/git/20180616143513.10086-1-szeder.dev@gmail.com/
  c20d4d702f (t1450: use "mv -f" within loose object directory, 2017-01-24)

'mv -f' did the trick in the past.
Junio C Hamano May 2, 2024, 7:55 p.m. UTC | #5
SZEDER Gábor <szeder.dev@gmail.com> writes:

>> Yes, different mac, different MacOs, different $PATH probably.
>> ...
>
> 'mv' in macOS doesn't conform to POSIX, and asks for confirmation when
> the destination exists (is read-only?) even without '-i' and even when
> its stdin is not a terminal, which it won't get as its stdin in our
> test suite is redirected from /dev/null.
>
> This is a recurring issue, see e.g.:
>
>   https://public-inbox.org/git/20180616143513.10086-1-szeder.dev@gmail.com/
>   c20d4d702f (t1450: use "mv -f" within loose object directory, 2017-01-24)
>
> 'mv -f' did the trick in the past.

Hmph, while that is a good data point to explain why this one fails,
it is a very unsatisfactory workaround, compared to a world where we
do not have to worry about such a broken mv (perhaps by noticing a
broken macOS /bin/mv and automatically doing mv () { mv -f "$@" }
for them).

I am curious what other differences Torsten will find out between
good macs and bad ones.  Perhaps we can narrow down the bad apples?
Junio C Hamano May 2, 2024, 8:05 p.m. UTC | #6
Junio C Hamano <gitster@pobox.com> writes:

> ... it is a very unsatisfactory workaround, compared to a world where we
> do not have to worry about such a broken mv (perhaps by noticing a
> broken macOS /bin/mv and automatically doing mv () { mv -f "$@" }
> for them).
>
> I am curious what other differences Torsten will find out between
> good macs and bad ones.  Perhaps we can narrow down the bad apples?

In any case, while we are waiting, I did a few "grep":

    $ git grep 'mv \(.*\)\.tmp \1' t
    t/lib-t6000.sh:	mv sed.script.tmp sed.script
    t/t7508-status.sh:	rm "$1" && mv "$1".tmp "$1"
    t/t8011-blame-split-file.sh:	mv one.tmp one &&
    t/t8011-blame-split-file.sh:	mv two.tmp two &&
    t/t9400-git-cvsserver-server.sh:	mv merge.tmp merge &&
    t/t9400-git-cvsserver-server.sh:	mv merge.tmp merge &&
    t/t9802-git-p4-filetype.sh:		mv empty-symlink,v.tmp empty-symlink,v

    $ git grep 'mv "\(.*\)\.tmp" "\1"' t
    t/lib-chunk.sh:	mv "$fn.tmp" "$fn"
    t/t3404-rebase-interactive.sh:	mv "$1.tmp" "$1"
    t/t5515-fetch-merge-logic.sh:	mv "$file.tmp" "$file"
    t/t7600-merge.sh:) >"$1.tmp" && mv "$1.tmp" "$1"
    t/t9001-send-email.sh:	mv "$1.tmp" "$1"
    t/t9001-send-email.sh:	mv "$1.tmp" "$1"

    $ git grep 'mv \(.*\)+ \1' t
    t/t4025-hunk-header.sh:	mv file+ file
    t/t6402-merge-rename.sh:	mv A+ A &&
    t/t6402-merge-rename.sh:	mv A+ A &&
    t/t6432-merge-recursive-space-options.sh:	mv text.txt+ text.txt &&
    t/t6432-merge-recursive-space-options.sh:	mv text.txt+ text.txt &&

There is nothing other than the one we found in lib-chunk.sh that
work on files under .git/objects/ that are made read-only, so we
should be OK with a workaround like the attached.

 t/lib-chunk.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git c/t/lib-chunk.sh w/t/lib-chunk.sh
index a7cd9c3c6d..9f01df190b 100644
--- c/t/lib-chunk.sh
+++ w/t/lib-chunk.sh
@@ -13,5 +13,6 @@ corrupt_chunk_file () {
 	fn=$1; shift
 	perl "$TEST_DIRECTORY"/lib-chunk/corrupt-chunk-file.pl \
 		"$@" <"$fn" >"$fn.tmp" &&
-	mv "$fn.tmp" "$fn"
+	# some vintages of macOS 'mv' fails to overwrite a read-only file.
+	mv -f "$fn.tmp" "$fn"
 }
Junio C Hamano May 2, 2024, 8:15 p.m. UTC | #7
Junio C Hamano <gitster@pobox.com> writes:

> I am curious what other differences Torsten will find out between
> good macs and bad ones.  Perhaps we can narrow down the bad apples?

So, "no, your 'mv' is broken" seems to be the answer to the question
on the Subject line, and it is rather well-known, it seems.

----- >8 --------- >8 --------- >8 --------- >8 -----
Subject: [PATCH] t/lib-chunk: work around broken "mv" on some vintage of macOS

When the destination is read-only, "mv" on some version of macOS
asks whether to replace the destination even though in the test its
stdin is not a terminal (and thus doesn't conform to POSIX[1]).

The helper to corrupt a chunk-file is designed to work on the
files like commit-graph and multi-pack-index files that are
generally read-only, so use "mv -f" to work around this issue.

Helped-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/lib-chunk.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/t/lib-chunk.sh b/t/lib-chunk.sh
index a7cd9c3c6d..9f01df190b 100644
--- a/t/lib-chunk.sh
+++ b/t/lib-chunk.sh
@@ -13,5 +13,6 @@ corrupt_chunk_file () {
 	fn=$1; shift
 	perl "$TEST_DIRECTORY"/lib-chunk/corrupt-chunk-file.pl \
 		"$@" <"$fn" >"$fn.tmp" &&
-	mv "$fn.tmp" "$fn"
+	# some vintages of macOS 'mv' fails to overwrite a read-only file.
+	mv -f "$fn.tmp" "$fn"
 }
Torsten Bögershausen May 2, 2024, 8:51 p.m. UTC | #8
On Thu, May 02, 2024 at 01:15:57PM -0700, Junio C Hamano wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
> > I am curious what other differences Torsten will find out between
> > good macs and bad ones.  Perhaps we can narrow down the bad apples?
>
> So, "no, your 'mv' is broken" seems to be the answer to the question
> on the Subject line, and it is rather well-known, it seems.

[]

>  		"$@" <"$fn" >"$fn.tmp" &&
> -	mv "$fn.tmp" "$fn"
> +	# some vintages of macOS 'mv' fails to overwrite a read-only file.
> +	mv -f "$fn.tmp" "$fn"

Thanks folks for digging - the patch makes both test cases pass.
Some official information:

$ man mv

on the both machines says
[snip]
If the destination path does not have a mode which permits writing,
mv prompts the user for confirmation as specified for the -i option.

To summarize what I have at hand right now:
MacOs 11.7.10 fails t4216 and t5318, both pass under MacOs 13.6.6

But why doesn't `mv` not hang then ?
Junio C Hamano May 2, 2024, 9:20 p.m. UTC | #9
Torsten Bögershausen <tboegi@web.de> writes:

> Thanks folks for digging - the patch makes both test cases pass.
> Some official information:
>
> $ man mv
>
> on the both machines says
> [snip]
> If the destination path does not have a mode which permits writing,
> mv prompts the user for confirmation as specified for the -i option.
>
> To summarize what I have at hand right now:
> MacOs 11.7.10 fails t4216 and t5318, both pass under MacOs 13.6.6
>
> But why doesn't `mv` not hang then ?

It is a sensible choice for the command to assume a "safer" no and
continuing rather than hanging, so that part is understandable.

So presumably 13.6.6 has a working "mv" but their "man mv" is not
updated to how the command actually works?

In any case, let me declare victory and queue the patch I sent
earlier.

Thanks.
diff mbox series

Patch

--- expect.err	2024-05-02 05:51:10.000000000 +0000
+++ err	2024-05-02 05:51:10.000000000 +0000
@@ -1 +0,0 @@ 
-warning: ignoring too-small changed-path chunk (4 < 12) in commit-graph file
error: last command exited with $?=1
++ rm -rf .git/objects/info/commit-graph
++ exit 1
++ eval_ret=1
++ :
not ok 141 - Bloom reader notices too-small data chunk


expecting success of 4216.142 'Bloom reader notices out-of-bounds filter offsets':
	check_corrupt_graph BIDX 12 FFFFFFFF &&
	# use grep to avoid depending on exact chunk size
	grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err

++ check_corrupt_graph BIDX 12 FFFFFFFF
++ corrupt_graph BIDX 12 FFFFFFFF
++ graph=.git/objects/info/commit-graph
++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
++ test 0 = 0
++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
		} && (exit "$eval_ret"); eval_ret=$?; :'
++ git commit-graph write --reachable --changed-paths
++ corrupt_chunk_file .git/objects/info/commit-graph BIDX 12 FFFFFFFF
++ fn=.git/objects/info/commit-graph
++ shift
++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX 12 FFFFFFFF
++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX 12 FFFFFFFF
++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX 12 FFFFFFFF
++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten
++ git -c core.commitGraph=false log -- A/B/file2
++ git -c core.commitGraph=true log -- A/B/file2
++ test_cmp expect.out out
++ test 2 -ne 2
++ eval 'diff -u' '"$@"'
+++ diff -u expect.out out
++ grep 'warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph' err
error: last command exited with $?=1
++ rm -rf .git/objects/info/commit-graph
++ exit 1
++ eval_ret=1
++ :
not ok 142 - Bloom reader notices out-of-bounds filter offsets

expecting success of 4216.143 'Bloom reader notices too-small index chunk':
	# replace the index with a single entry, making most
	# lookups out-of-bounds
	check_corrupt_graph BIDX clear 00000000 &&
	echo "warning: commit-graph changed-path index chunk" \
		"is too small" >expect.err &&
	test_cmp expect.err err

++ check_corrupt_graph BIDX clear 00000000
++ corrupt_graph BIDX clear 00000000
++ graph=.git/objects/info/commit-graph
++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
++ test 0 = 0
++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
		} && (exit "$eval_ret"); eval_ret=$?; :'
++ git commit-graph write --reachable --changed-paths
++ corrupt_chunk_file .git/objects/info/commit-graph BIDX clear 00000000
++ fn=.git/objects/info/commit-graph
++ shift
++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX clear 00000000
++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX clear 00000000
++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX clear 00000000
++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten
++ git -c core.commitGraph=false log -- A/B/file2
++ git -c core.commitGraph=true log -- A/B/file2
++ test_cmp expect.out out
++ test 2 -ne 2
++ eval 'diff -u' '"$@"'
+++ diff -u expect.out out
++ echo 'warning: commit-graph changed-path index chunk' 'is too small'
++ test_cmp expect.err err
++ test 2 -ne 2
++ eval 'diff -u' '"$@"'
+++ diff -u expect.err err
--- expect.err	2024-05-02 05:51:11.000000000 +0000
+++ err	2024-05-02 05:51:11.000000000 +0000
@@ -1 +0,0 @@ 
-warning: commit-graph changed-path index chunk is too small
error: last command exited with $?=1
++ rm -rf .git/objects/info/commit-graph
++ exit 1
++ eval_ret=1
++ :
not ok 143 - Bloom reader notices too-small index chunk

expecting success of 4216.144 'Bloom reader notices out-of-order index offsets':
	# we do not know any real offsets, but we can pick
	# something plausible; we should not get to the point of
	# actually reading from the bogus offsets anyway.
	corrupt_graph BIDX 4 0000000c00000005 &&
	echo "warning: ignoring decreasing changed-path index offsets" \
		"(12 > 5) for positions 1 and 2 of .git/objects/info/commit-graph" >expect.err &&
	git -c core.commitGraph=false log -- A/B/file2 >expect.out &&
	git -c core.commitGraph=true log -- A/B/file2 >out 2>err &&
	test_cmp expect.out out &&
	test_cmp expect.err err

++ corrupt_graph BIDX 4 0000000c00000005
++ graph=.git/objects/info/commit-graph
++ test_when_finished 'rm -rf .git/objects/info/commit-graph'
++ test 0 = 0
++ test_cleanup='{ rm -rf .git/objects/info/commit-graph
		} && (exit "$eval_ret"); eval_ret=$?; :'
++ git commit-graph write --reachable --changed-paths
++ corrupt_chunk_file .git/objects/info/commit-graph BIDX 4 0000000c00000005
++ fn=.git/objects/info/commit-graph
++ shift
++ perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX 4 0000000c00000005
++ command /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX 4 0000000c00000005
++ /usr/bin/perl /Users/tb/NoBackup/projects/git/git.pu/t/lib-chunk/corrupt-chunk-file.pl BIDX 4 0000000c00000005
++ mv .git/objects/info/commit-graph.tmp .git/objects/info/commit-graph
override r--r--r--  tb/staff for .git/objects/info/commit-graph? (y/n [n]) not overwritten
++ echo 'warning: ignoring decreasing changed-path index offsets' '(12 > 5) for positions 1 and 2 of .git/objects/info/commit-graph'
++ git -c core.commitGraph=false log -- A/B/file2
++ git -c core.commitGraph=true log -- A/B/file2
++ test_cmp expect.out out
++ test 2 -ne 2
++ eval 'diff -u' '"$@"'
+++ diff -u expect.out out
++ test_cmp expect.err err
++ test 2 -ne 2
++ eval 'diff -u' '"$@"'
+++ diff -u expect.err err
--- expect.err	2024-05-02 05:51:11.000000000 +0000
+++ err	2024-05-02 05:51:11.000000000 +0000
@@ -1 +0,0 @@ 
-warning: ignoring decreasing changed-path index offsets (12 > 5) for positions 1 and 2 of .git/objects/info/commit-graph