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

Re: [PATCH v2 2/2] apply: set file mode when --reverse creates a deleted file

From
Mark Mentovai <mark@chromium.org>
Date
May 24, 2025, 03:19 UTC
Message-ID
<cdca6dcb-3a78-fa0d-b58b-8dfd92924e96@chromium.org>
In-Reply-To
<xmqqbjrivqn2.fsf@gitster.g>
Junio C Hamano wrote:
Show 11 quoted lines
> Mark Mentovai <mark@chromium.org> writes:
>
>> +test_file_mode_common() {
>
> Unlike the two callers, this lacks SP before "()".
>
> I would have expected that "no such file" would be expressed with
> mode 000000 (taken from "git diff --raw" for a removal/creation
> patch), but an empty string works just as well.  The same comment
> about requiring 0-prefix before 644 and 755 applies here, but as
> long as it is done consistently, I wouldn't complain too loudly ;-)
No, it's fine. I'll switch to the 6-digit form.
>> +	test -n "$1" && test_grep "^10$1 " "$2" || test_must_be_empty "$2"

This requires attention anyway. Reading it back, it's buggy: if there's a mode in $1, but the file $2 is erroneously empty, test_grep will evaluate false and evaluation will advance to test_must_be_empty, which will cause the whole expression to evaluate true. This construct only works properly as an if-then-else when the "then" clause can't fail. I will revise this.

Show 10 quoted lines
>> +test_expect_success 'git apply restores file modes (change_x_to_notx)' '
>> +	test_config core.fileMode false &&
>
> Wouldn't this and the subsequent tests want to begin with
>
> 	git reset --hard <commit> &&
>
> to a known good state?  We expect that after successfully running
> this test piece, for example, the path is removed after the last
> patch that removes change-x-to-notx is applied.

Yes, good point. And with just slightly more effort, I can use the same strategy to eliminate the ordering dependency between the the tests in the 1/2 patch.

> Other than that, we seem to have a very good coverage of the
> combinations now.  Thanks for a thorough work.
Thanks for your thoughtful reviews. v3 incoming shortly.
Previous: Junio C HamanoNext: Mark Mentovai
Message 10 of 17 in “apply: set file mode when --reverse creates a deleted file”
  1. apply: set file mode when --reverse creates a deleted fileMark Mentovai, May 22, 2025
  2. Kristoffer HaugsbakkMay 22, 2025
  3. Junio C HamanoMay 22, 2025
  4. Junio C HamanoMay 22, 2025
  5. Mark MentovaiMay 22, 2025
  6. Junio C HamanoMay 23, 2025
  7. 0/2 apply: set file mode when --reverse creates a deleted fileMark Mentovai, May 23, 2025
  8. 2/2 apply: set file mode when --reverse creates a deleted fileMark Mentovai, May 23, 2025
  9. Junio C HamanoMay 23, 2025
  10. Mark MentovaiMay 24, 2025
  11. 1/2 t4129: test that git apply warns for unexpected mode changesMark Mentovai, May 23, 2025
  12. Junio C HamanoMay 23, 2025
  13. Mark MentovaiMay 24, 2025
  14. 0/2 apply: set file mode when --reverse creates a deleted fileMark Mentovai, May 24, 2025
  15. 1/2 t4129: test that git apply warns for unexpected mode changesMark Mentovai, May 24, 2025
  16. 2/2 apply: set file mode when --reverse creates a deleted fileMark Mentovai, May 24, 2025
  17. Junio C HamanoMay 27, 2025

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.