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

Re: [PATCH v2] git-p4: fix faulty paths for case insensitive systems

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Aug 20, 2015, 13:17 UTC
Message-ID
<CAPig+cQ8P8BDBGCNprN4GLtZbP0MHdj08LNw2WEJ87K5Ws1AHg@mail.gmail.com>
In-Reply-To
<917E3751-4BC8-4034-9101-30C77426D81C@gmail.com>

On Thu, Aug 20, 2015 at 3:16 AM, Lars Schneider <larsxschneider@gmail.com> wrote:

Show 12 quoted lines
> On 20 Aug 2015, at 06:59, Torsten Bögershausen <tboegi@web.de> wrote:
>> On 08/19/2015 10:04 PM, larsxschneider@gmail.com wrote:
>>> From: Lars Schneider <larsxschneider@gmail.com>
>>> +            find . | grep two/File2.txt &&
>> Should we make sure that two/File2.txt exist?
>> Then the "find | grep" feels like overkill.
>> The line
>> test -f  two/File2.txt &&
>> could do the same (or do I miss something ?)
> That’s what I did first. However, I am running OS X with HFS in
> case-insensitive mode (the default). Consequently “test -f”
> doesn’t care about the case. That’s why I used “grep”.

This explanation may deserves to be recorded as an in-code comment to make the next person who modifies the test code aware of the issue.

Show 5 quoted lines
>>> +            git ls-files > lines &&
>> and here
> I really want to make sure only one file ends up in the repo.
>
>>> +            test_line_count = 1 lines

A more idiomatic way (in Git tests) to check both the file case and the file count would be:

    cat >expect <<-\EOF &&
    two/File2.txt
    EOF
    git ls-files >actual &&
    test_cmp expect actual
Show 17 quoted lines
>>> +    )
>>> +'
>>> +
>>> +test_expect_success 'Clone the repo WITH path fixing' '
>>> +    client_view "//depot/One/... //client/..." &&
>>> +    git p4 clone --fix-paths --use-client-spec --destination="$git" //depot/one &&
>>> +    test_when_finished cleanup_git &&
>>> +    (
>>> +            cd "$git" &&
>>> +            find . | grep TWO/file1.txt &&
>>> +            find . | grep TWO/File2.txt &&
>>> +            find . | grep TWO/file3.txt &&
>> Not sure about the find | grep here either.
> See answers above.
>
>>> +            git ls-files > lines &&
>>> +            test_line_count = 3 lines
Likewise:
    cat >expect <<-\EOF &&
    TWO/File2.txt
    TWO/file1.txt
    TWO/file3.txt
    EOF
    git ls-files >actual &&
    test_cmp expect actual
Show 27 quoted lines
>>> +    )
>>> +'
>>> +
>>> +# It looks like P4 determines the path case based on the first file in
>>> +# lexicographical order. Please note the lower case "two" directory for all
>>> +# files triggered through the addition of "File0.txt".
>>> +test_expect_success 'Add a new file and clone the repo WITH path fixing' '
>>> +    client_view "//depot/... //client/..." &&
>>> +    cd "$cli" &&
>>> +
>>> +    mkdir -p One/two &&
>>> +    > One/two/File0.txt &&
>>> +    p4 add One/two/File0.txt &&
>>> +    p4 submit -d "Add file" &&
>>> +    rm -rf One &&
>>> +
>>> +    client_view "//depot/One/... //client/..." &&
>>> +    git p4 clone --fix-paths --use-client-spec --destination="$git" //depot/one &&
>>> +    test_when_finished cleanup_git &&
>>> +    (
>>> +            cd "$git" &&
>>> +            find . | grep two/File0.txt &&
>>> +            find . | grep two/file1.txt &&
>>> +            find . | grep two/File2.txt &&
>>> +            find . | grep two/file3.txt &&
>>> +            git ls-files > lines &&
>>> +            test_line_count = 4 lines
And:
    cat >expect <<-\EOF &&
    two/File0.txt
    two/File2.txt
    two/file1.txt
    two/file3.txt
    EOF
    git ls-files >actual &&
    test_cmp expect actual
Show 9 quoted lines
>>> +    )
>>> +'
>>> +
>>> +test_expect_success 'kill p4d' '
>>> +    kill_p4d
>>> +'
>>> +
>>> +test_done
>>> --
Previous: Lars SchneiderNext: Junio C Hamano
Message 5 of 9 in “git-p4: fix faulty paths for case insensitive systems”
  1. git-p4: fix faulty paths for case insensitive systemslarsxschneider@gmail.com, Aug 19, 2015
  2. git-p4: fix faulty paths for case insensitive systemslarsxschneider@gmail.com, Aug 19, 2015
  3. Torsten BögershausenAug 20, 2015
  4. Lars SchneiderAug 20, 2015
  5. Eric SunshineAug 20, 2015
  6. Junio C HamanoAug 20, 2015
  7. Lars SchneiderAug 21, 2015
  8. Eric SunshineAug 21, 2015
  9. Torsten BögershausenAug 20, 2015

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.