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

Re: [PATCH] clean: new option --exclude-from

From
Jeff King <peff@peff.net>
Date
Dec 2, 2015, 17:51 UTC
Message-ID
<20151202175144.GA18550@sigill.intra.peff.net>
In-Reply-To
<xmqqd1uo69vf.fsf@gitster.mtv.corp.google.com>
On Wed, Dec 02, 2015 at 09:25:24AM -0800, Junio C Hamano wrote:
Show 18 quoted lines
> I do not think we should liberally add options that apply to
> anything "git" in the first place [*1*].  Limit them to ones that
> are really special and fundamental that changes the way Git
> operates, i.e. "Where is our $GIT_DIR?" is a good thing for users to
> be able to tell "git" itself.  Compared to that, the ignore patterns
> is a fringe that is used only by commands that care about the
> working tree (e.g. the global option in "git --exclude='*.o'
> ls-tree" would be meaningless).
> 
> 
> [Footnote]
> 
> *1* It would add unnecessary confusion to the end users; they have
>     to decide if they need to pass an option before or after the
>     subcommand name.  If the motivation behind the "git --option cmd"
>     is to share code and semantics for common "--option", we should
>     instead further refactor command line option handling, just like
>     the code for config handling allows us to share config_default.

My motivation isn't exactly code sharing. It is that you sometimes want to affect sub-commands of a program, and cannot pass command line options to them yourself.

For instance, "git-stash --include-untracked" will call "git clean" under the hood. There is no way to say "...and treat foo.* as ignored for this invocation". It could grow its own "-e" option, but that does not help any other third-party scripts which call "git clean".

So IMHO this is not really about command-line options, but about the environment in which a command is executed. Environment variables are the obvious way to do that; "git --foo" options are just syntactic sugar to set the variables. We could just add variables without matching options.

I agree that we could end up proliferating such options (or environment variables). Using the logic above, you could argue that I should be able to affect any option of any sub-command in a script, which just gets silly. My rule of thumb would be that if there is some implicit state in the on-disk repo (e.g., what is in your .git/config) that you might want to override for a one-shot invocation, then it may be a reasonable candidate. The "git -c" config override is such an example.

In this case, it is basically adding to ".git/info/exclude", which follows the same rule.

But like I said, I do not feel all that strongly about this particular option. I would not use it myself. Just trying to make my reasoning clear. :)

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 21 in “clean: new option --exclude-from”
  1. clean: new option --exclude-fromJames, Nov 26, 2015
  2. Eric SunshineNov 30, 2015
  3. Jeff KingDec 2, 2015
  4. Junio C HamanoDec 2, 2015
  5. Jeff KingDec 2, 2015
  6. Junio C HamanoDec 2, 2015
  7. Jeff KingDec 2, 2015
  8. Junio C HamanoDec 2, 2015
  9. Jeff KingDec 2, 2015
  10. Junio C HamanoDec 6, 2015
  11. Jeff KingDec 7, 2015
  12. Eric SunshineDec 1, 2015
  13. 1/2 modernize t7300James, Dec 6, 2015
  14. 2/2 clean: new option --exclude-fromJames, Dec 6, 2015
  15. Jeff KingDec 7, 2015
  16. Junio C HamanoDec 7, 2015
  17. Eric SunshineDec 7, 2015
  18. Junio C HamanoDec 7, 2015
  19. Eric SunshineDec 7, 2015
  20. Junio C HamanoDec 7, 2015
  21. Eric SunshineDec 7, 2015

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.