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

Re: [PATCH v3] notes: teach the -e option to edit messages in editor

From
Taylor Blau <me@ttaylorr.com>
Date
Oct 21, 2024, 19:52 UTC
Message-ID
<Zxaw+pUMT4juAePD@nand.local>
In-Reply-To
<CAPig+cSw_F97nBzO3Z7t2Zrv5TZwGnYiQLhpq2iKgLfxhhxvfQ@mail.gmail.com>
On Mon, Oct 21, 2024 at 02:28:05PM -0400, Eric Sunshine wrote:
Show 24 quoted lines
> On Mon, Oct 21, 2024 at 12:53 PM Taylor Blau <me@ttaylorr.com> wrote:
> > On Mon, Oct 21, 2024 at 02:38:15PM +0000, Samuel Adekunle Abraham via GitGitGadget wrote:
> > > +     MSG="Edited notes message" git notes add -m "Initial notes message" -e &&
> > > +     echo "Edited notes message" >expect &&
> >
> > Very nice use of the fake_editor script here.
> >
> > It is a little cumbersome to repeat the same message in MSG= and when
> > populating the 'expect' file. Perhaps instead this could be written as:
> >
> >     echo "edited notes message" >expect &&
> >     MSG="$(cat expect)" git notes -add -m "initial" -e
>
> This suggested rewrite feels unusually roundabout and increases
> cognitive load for readers who now have to trace the message flow from
> script to file and back into script, and to consider how the loss of
> trailing newline caused by use of $(...) impacts the behavior. It also
> wastes a subprocess (which can be expensive on some platforms, such as
> Windows). If we're really concerned about this minor duplication of
> the message, we can instead do this:
>
>     msg="edited notes message" &&
>     echo "$msg" >expect &&
>     MSG="$msg" git notes -add -m "initial" -e

I am not sure I agree that the suggested version is clearer. The way I read mine is that we are writing what we expect to see in "expect", and then setting up MSG to be the same thing.

I definitely do not feel strongly between the two and would rather avoid nitpicking something as trivial as this when compared to the rest of the patch, especially considering that I would be equally happy with your version.

I think the whole thing is a little bit of a moot point, though, because by far the thing that is least clear here is that setting MSG has the side-effect of modifying the behavior of the fake-editor that we set up earlier in the script. So I don't know that optimizing for clarity in how we setup and write to the "expect" file is the right thing to spend our time on.

Thanks, Taylor

Previous: Eric SunshineNext: Samuel Adekunle Abraham via GitGitGadget
Message 17 of 22 in “notes: teach the -e option to edit messages in editor”
  1. notes: teach the -e option to edit messages in editorSamuel Adekunle Abraham via GitGitGadget, Oct 19, 2024
  2. brian m. carlsonOct 19, 2024
  3. Kristoffer HaugsbakkOct 19, 2024
  4. Samuel AbrahamOct 19, 2024
  5. Kristoffer HaugsbakkOct 19, 2024
  6. Samuel AbrahamOct 19, 2024
  7. Kristoffer HaugsbakkOct 19, 2024
  8. Samuel AbrahamOct 19, 2024
  9. notes: teach the -e option to edit messages in editorSamuel Adekunle Abraham via GitGitGadget, Oct 20, 2024
  10. Patrick SteinhardtOct 21, 2024
  11. Samuel AbrahamOct 21, 2024
  12. Eric SunshineOct 21, 2024
  13. notes: teach the -e option to edit messages in editorSamuel Adekunle Abraham via GitGitGadget, Oct 21, 2024
  14. Taylor BlauOct 21, 2024
  15. Samuel AbrahamOct 21, 2024
  16. Eric SunshineOct 21, 2024
  17. Taylor BlauOct 21, 2024
  18. notes: teach the -e option to edit messages in editorSamuel Adekunle Abraham via GitGitGadget, Oct 21, 2024
  19. Taylor BlauOct 21, 2024
  20. Samuel AbrahamOct 21, 2024
  21. Patrick SteinhardtOct 23, 2024
  22. Samuel AbrahamOct 23, 2024

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.