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

Re: [PATCH] Introduce a hook to run after formatting patches

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2014, 17:02 UTC
Message-ID
<xmqqoas4wif0.fsf@gitster.dls.corp.google.com>
In-Reply-To
<CAGZ79kZ=1qekoKfY5cwdmDp68oU-poTcc6A4Fa7u5LhwCB5HyQ@mail.gmail.com>
Stefan Beller <sbeller@google.com> writes:
> Do we have similar filters somewhere in place already,
> so I could have a look at the code architecture,
> the api, and how the user would operate that?

The clean/smudge filters interacts with the payload data and the end user configuration in a similar way, I would say.

> The way you're proposing, doesn't sound as if a hook would be the right
> thing for such filtering.
That depends on how you define "what a hook is", I think.
> The one big thing I liked over the first patch in this thread was
> the 'maintainability', i.e. if it were a hook, I could set that up
> and forget about it.  No need to change my behavior in using git,
> but still I have the desired postprocessed results.

In the message you are responding, I said "detect a request to use", exactly because I wanted to leave it up to you to design what form(s) that "request detection" takes. One of the forms could be "a script with this $filename exists in $GIT_DIR/", and the $filname may be "hooks/format-patch-redaction-filter".

Of course, any "configured into repository" solution must have a command line override, so the order you would develop this would be:

 (0) make the code that interracts with the filter if given by the
     user work, without worrying about how the user specifies the
     filter.
 (1) add a --command-line-option=<filter-name> to trigger the code
     you wrote in (0) above.
 (2) add a --no-command-line-option to defeat the configured filter,
     without worrying about how the user configures.  For your new
     command line option --frotz, "git cmd --frotz --no-frotz"
     should make your cmd refrain from doing frotz.
 (3) add configuration variable to point at a filter script,
     e.g. "format.redactionFilter"; you must make sure that this is
     disabled with "--no-*" you added in (2) above;
 (4) perhaps add support for "hooks/format-patch-redaction-filter",
     if you strongly feel like it.  The user must be able to disable
     this with the same "--no-*" added in (2).

I'd say (4) is optional; by the time you reach (3), you already have the same "write once and forget" capability.

Previous: Stefan Beller
Message 12 of 12 in “Introduce a hook to run after formatting patches”
  1. Introduce a hook to run after formatting patchesStefan Beller, Nov 15, 2014
  2. Philip OakleyNov 15, 2014
  3. Junio C HamanoNov 16, 2014
  4. Stefan BellerNov 17, 2014
  5. Junio C HamanoNov 17, 2014
  6. Junio C HamanoNov 17, 2014
  7. Christian CouderNov 18, 2014
  8. Stefan BellerNov 20, 2014
  9. Junio C HamanoNov 20, 2014
  10. Christian CouderNov 21, 2014
  11. Stefan BellerNov 18, 2014
  12. Junio C HamanoNov 18, 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.