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

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

From
KHKristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Date
May 22, 2025, 22:24 UTC
Message-ID
<91c86145-1a78-465e-a08c-2fb727dc5a02@app.fastmail.com>
In-Reply-To
<20250522220235.8650-1-mark@chromium.org>
On Fri, May 23, 2025, at 00:02, Mark Mentovai wrote:
> Commit 01aff0a (apply: correctly reverse patch's pre- and post-image
> mode bits; 2023-12-26) revised reverse_patches() to maintain the desired

The way the commit is referred to is almost like the usual and recommended

    git show -s --pretty=reference
But with a semicolon instead of a comma.
> property that when only one of patch::old_mode and patch::new_mode is
> set, the mode will be carried in old_mode. That property is generally
> correct, with one notable notable exception: when creating a file, only
s/notable notable/notable/
Show 10 quoted lines
> new_mode will be set. Since reversing a deletion results in a creation,
> new_mode must be set in that case.
>
> Omitting handling for this case meant that reversing a patch that
> removed an executable file would not result in the executable permission
> being set on the re-created file.
>
> When git apply --reverse is used, reverse_patches() will now additionaly
> swap old_mode and new_mode for what's represented in the patch as a file
> deletion, as it is transformed into a file creation under reversal.

The usual way to refer to code behavior is to talk about the code without this patch/commit in the present tense. I think this is talking about how the code behaves with this patch applied/with this commit.

In my opinion it helps the narrative flow since something right-now is problematic. Therefore (see next point) do this and that to fix the situation.

> Tests are added that ensure that git apply sets file modes correctly on
> file creation, both in the normal (forward) and reverse direction.
> Existing test coverage for file modes focused only on mode changes of
> existing files, and only in the forward direction.

It’s recommended to describe changes as “do this and that” to the code. “Add tests”, not “added tests” or “tests are added” (and the latter here seems to use a passive construct that doesn’t feel in line with the preceding paragraphs).

-- 
Kristoffer
Previous: Mark MentovaiNext: Junio C Hamano
Message 2 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.