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

Re: On "interpret-trailers" standalone tool

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 16, 2014, 17:43 UTC
Message-ID
<xmqq38hdi2zr.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAP8UFD0w9xUwuk9UZ_mu=qvjtYN1r5skidweruM8t1KbfQpQyA@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
Show 5 quoted lines
> If the input comes from stdin, then I agree that the command should be
> a filter, so its output should be on stdout. But if the input comes
> from files given as arguments, then I would say that the command
> should behave as an editor and by default it should edit its input
> file inplace.

I do not see where that "should" comes from. I am looking at this more from the angle of obtaining a useful building block, while you seem to be thinking of this as a specialized tool for a narrow set of specifkc tasks.

Thinking of examples in "sort" and "sed", I would say "read multiple files, futz with the contents and spit out a single output stream" is the way people expect a command to operate without being told to operate in some other way. Overwriting existing files should never be the default for safety---otherwise you would require people who want safety to do something like:

    cp realfile tmp
    futz tmp
    verify tmp
    mv tmp realfile

On the other hand, a usual "sort/sed/cat"-like command, even without the "in-place edit" option, can be used as in-place with

    mv realfile tmp
    futz tmp >realfile

easily, and is more flexible as a building block. Of course, that does not rule out an option to work in-place (e.g. in a similar way to "sort -o file file", or "perl -i -e 'y/a-z/A-Z/' frotz nitfol").

Show 10 quoted lines
> Its input and output files should be different only if
> it is given one or more special option,
>
> Otherwise the example you gave:
>
>     $ git format-patch -5 --cover-letter -o +my-series/ my-topic
>     $ git interpret-trailers "some args" ./+my-series/0*.patch
>
> would result in having on stdout all the patches edited by "git
> interpret-trailers".

Didn't I mention that I do not mind "-i" already if in-place edit is desired? Add "-i" to the command line arguments among "some args", and your complaints will disappear, no?

Previous: Christian CouderNext: Junio C Hamano
Message 5 of 7 in “On "interpret-trailers" standalone tool”
  1. Junio C HamanoApr 9, 2014
  2. Christian CouderApr 12, 2014
  3. Junio C HamanoApr 14, 2014
  4. Christian CouderApr 16, 2014
  5. Junio C HamanoApr 16, 2014
  6. Junio C HamanoApr 16, 2014
  7. Junio C HamanoApr 16, 2014

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.