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

Re: [PATCH] t2080: fix cp invocation to copy symlinks instead of following them

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 31, 2021, 14:01 UTC
Message-ID
<871r9n2dlu.fsf@evledraar.gmail.com>
In-Reply-To
<87r1hsl4qb.fsf@evledraar.gmail.com>
On Thu, May 27 2021, Ævar Arnfjörð Bjarmason wrote:
Show 40 quoted lines
> On Wed, May 26 2021, Matheus Tavares wrote:
>
>> t2080 makes a few copies of a test repository and later performs a
>> branch switch on each one of the copies to verify that parallel checkout
>> and sequential checkout produce the same results. However, the
>> repository is copied with `cp -R` which, on some systems, defaults to
>> following symlinks on the directory hierarchy and copying their target
>> files instead of copying the symlinks themselves. AIX is one example of
>> system where this happens. Because the symlinks are not preserved, the
>> copied repositories have paths that do not match what is in the index,
>> causing git to abort the checkout operation that we want to test. This
>> makes the test fail on these systems.
>>
>> Fix this by copying the repository with the POSIX flag '-P', which
>> forces cp to copy the symlinks instead of following them. Note that we
>> already use this flag for other cp invocations in our test suite (see
>> t7001). With this change, t2080 now passes on AIX.
>>
>> Reported-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>> Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
>> ---
>>  t/t2080-parallel-checkout-basics.sh | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/t/t2080-parallel-checkout-basics.sh b/t/t2080-parallel-checkout-basics.sh
>> index 7087818550..3e0f8c675f 100755
>> --- a/t/t2080-parallel-checkout-basics.sh
>> +++ b/t/t2080-parallel-checkout-basics.sh
>> @@ -114,7 +114,7 @@ do
>>  
>>  	test_expect_success "$mode checkout" '
>>  		repo=various_$mode &&
>> -		cp -R various $repo &&
>> +		cp -R -P various $repo &&
>>  
>>  		# The just copied files have more recent timestamps than their
>>  		# associated index entries. So refresh the cached timestamps
>
> Thanks for the quick fix, I can confirm that this makes the test pass on
> AIX 7.2.
There's still a failure[1] in t2082-parallel-checkout-attributes.sh
though, which is new in 2.32.0-rc*. The difference is in an unexpected
BOM:
    
    avar@gcc119:[/scratch/avar/git/t]perl -nle 'print unpack "H*"' trash\ directory.t2082-parallel-checkout-attributes/encoding/A.internal 
    efbbbf74657874
    avar@gcc119:[/scratch/avar/git/t]perl -nle 'print unpack "H*"' trash\ directory.t2082-parallel-checkout-attributes/encoding/utf8-text  
    74657874

I.e. the A.internal starts with 0xefbbbf. The 2nd test of t0028*.sh also fails similarly[2], so perhaps it's some old/iconv/whatever issue not per-se related to any change of yours.

I tried compiling with both NO_ICONV=Y and ICONV_OMITS_BOM=Y, both have the same failure.

In any case, I think AIX test failures (or other obscure platforms I
test) are rather uninteresting per-se, I mainly test on these to smoke
out bad assumptions elsewhere. E.g. non-POSIX code, perhaps in this case
we're relying on some unportable iconv assumption, or maybe not...
    
1.
Initialized empty Git repository in /scratch/avar/git/t/trash directory.t2082-parallel-checkout-attributes/encoding/.git/
+ cd encoding
+ echo text
+ 1> utf8-text
+ write_utf16
+ 0< utf8-text 1> utf16-text
checking prerequisite: NO_UTF16_BOM
mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-NO_UTF16_BOM" &&
(
        cd "$TRASH_DIRECTORY/prereq-test-dir-NO_UTF16_BOM" &&
        test $(printf abc | iconv -f UTF-8 -t UTF-16 | wc -c) = 6
)
+ mkdir -p /scratch/avar/git/t/trash directory.t2082-parallel-checkout-attributes/prereq-test-dir-NO_UTF16_BOM
+ cd /scratch/avar/git/t/trash directory.t2082-parallel-checkout-attributes/prereq-test-dir-NO_UTF16_BOM
+ printf abc
+ iconv -f UTF-8 -t UTF-16
+ wc -c
+ test 6 = 6
prerequisite NO_UTF16_BOM ok
+ echo A working-tree-encoding=UTF-16
+ 1> .gitattributes
+ cp utf16-text A
+ cp utf8-text B
+ git add A B .gitattributes
+ git commit -m encoding
[master (root-commit) 65fa7e8] encoding
 Author: A U Thor <author@example.com>
 3 files changed, 3 insertions(+)
 create mode 100644 .gitattributes
 create mode 100644 A
 create mode 100644 B
+ git cat-file -p :A
+ 1> A.internal
+ test_cmp_bin utf8-text A.internal
utf8-text A.internal differ: char 1, line 1
error: last command exited with $?=1
not ok 2 - parallel-checkout with re-encoding
#
#               set_checkout_config 2 0 &&
#               git init encoding &&
#               (
#                       cd encoding &&
#                       echo text >utf8-text &&
#                       write_utf16 <utf8-text >utf16-text &&
#
#                       echo "A working-tree-encoding=UTF-16" >.gitattributes &&
#                       cp utf16-text A &&
#                       cp utf8-text B &&
#                       git add A B .gitattributes &&
#                       git commit -m encoding &&
#
#                       # Check that A is stored in UTF-8
#                       git cat-file -p :A >A.internal &&
#                       test_cmp_bin utf8-text A.internal &&
#
#                       rm A B &&
#                       test_checkout_workers 2 git checkout A B &&
#
#                       # Check that A (and only A) is re-encoded during checkout
#                       test_cmp_bin utf16-text A &&
#                       test_cmp_bin utf8-text B
#               )
#
2. 

avar@gcc119:[/scratch/avar/git/t]perl -nle 'print unpack "H*"' trash\ directory.t0028-working-tree-encoding/test.utf8.raw 68616c6c6f20746865726521 63616e20796f752072656164206d653f avar@gcc119:[/scratch/avar/git/t]perl -nle 'print unpack "H*"' trash\ directory.t0028-working-tree-encoding/test.utf16.git efbbbf68616c6c6f20746865726521 63616e20796f752072656164206d653f

Previous: Ævar Arnfjörð BjarmasonNext: Matheus Tavares
Message 4 of 15 in “t2080: fix cp invocation to copy symlinks instead of following them”
  1. t2080: fix cp invocation to copy symlinks instead of following themMatheus Tavares, May 26, 2021
  2. Christian CouderMay 27, 2021
  3. Ævar Arnfjörð BjarmasonMay 27, 2021
  4. Ævar Arnfjörð BjarmasonMay 31, 2021
  5. Matheus TavaresMay 31, 2021
  6. Ævar Arnfjörð BjarmasonMay 31, 2021
  7. Đoàn Trần Công DanhJun 2, 2021
  8. Ævar Arnfjörð BjarmasonJun 2, 2021
  9. Bagas SanjayaJun 2, 2021
  10. Đoàn Trần Công DanhJun 2, 2021
  11. Ævar Arnfjörð BjarmasonJun 2, 2021
  12. Đoàn Trần Công DanhJun 2, 2021
  13. Đoàn Trần Công DanhJun 3, 2021
  14. Torsten BögershausenJun 2, 2021
  15. brian m. carlsonJun 3, 2021

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.