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

Re: [PATCH v2 0/2] Add --no-filters option to git-add

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 20, 2021, 21:34 UTC
Message-ID
<xmqq4ki6a0ex.fsf@gitster.g>
In-Reply-To
<pull.880.v2.git.1613840865.gitgitgadget@gmail.com>
"Andrej Shadura via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> It is possible for a user to disable attribute-based filtering when
> committing by doing one of the following:
>
>  * Create .git/info/attributes unapplying all possible transforming
>    attributes.
>  * Use git hash-object and git update-index to stage files manually.
>
> Doing the former requires keeping an up-to-date list of all attributes which
> can transform files when committing or checking out. Doing the latter is
> difficult, error-prone and slow when done from scripts.
>
> Instead, similarly to git hash-object, --no-filter can be added to git add
> to enable temporarily disabling filtering in an easy to use way.

I think brian's review covered if such a feature is desirable to sufficient level, and I do not have anything to add in that area, so I'll limit my comment to the general design and implementation.

In general, think three times before introducing --no-something option. It often is much cleaner and futureproof if you instead introduced --something option whose value defaults to true instead, so that the end-user can say --no-something from the command line.

>       -		OPT_BOOL( 0 , "no-filters", &no_filters, N_("store file as is without filters")),
>      -+		OPT_BIT(0 , "no-filters", &flags, N_("store file as is without filters"),
>      ++		OPT_BIT(0, "no-filters", &flags, N_("store file as is without filters"),
>       +			HASH_RAW),

In other words, these should give "filters" option, and the code should initialize the flags word with USE_CLEAN_FILTER bit on by default (the use of "clean" here comes from "clean vs smudge", one of the pair of filters end-user can customize the path the data takes going into Git from the outside world; and the "clean" and "smudge" datapaths also trigger non-custom standard ones like crlf munging).

That way when a configuration variable support is introduced to allow the users to say "I by default refuse to use the clean filters when running 'git add'" by setting say "[add] cleanfilter = false", the user can override that with "--filters" from the command line "for just this time". The same goes for an alias that hardcodes "--no-filters" on the command line, where allowing "--filters" lets the users override it.

Thanks.
Previous: Andrej Shadura via GitGitGadget
Message 11 of 11 in “Add --no-filters option to git-add”
  1. 0/2 Add --no-filters option to git-addAndrej Shadura via GitGitGadget, Feb 19, 2021
  2. 1/2 add: add option --no-filters to disable attribute-based filteringAndrej Shadura via GitGitGadget, Feb 19, 2021
  3. 2/2 hash-object: use the new HASH_RAW flag instead of setting path to NULLAndrej Shadura via GitGitGadget, Feb 19, 2021
  4. brian m. carlsonFeb 19, 2021
  5. Andrej ShaduraFeb 20, 2021
  6. Andrej ShaduraFeb 20, 2021
  7. brian m. carlsonFeb 20, 2021
  8. 0/2 Add --no-filters option to git-addAndrej Shadura via GitGitGadget, Feb 20, 2021
  9. 1/2 add: add option --no-filters to disable attribute-based filteringAndrej Shadura via GitGitGadget, Feb 20, 2021
  10. 2/2 hash-object: use the new HASH_RAW flag instead of setting path to NULLAndrej Shadura via GitGitGadget, Feb 20, 2021
  11. Junio C HamanoFeb 20, 2021

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.