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

Re: [PATCH/RFC/GSoC 0/2] add a add.patch config variable

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 22, 2016, 06:42 UTC
Message-ID
<alpine.DEB.2.20.1604220836060.2826@virtualbox>
In-Reply-To
<34fb607f-1c4c-528a-cb5d-eca95e0e7c68@web.de>
Hi Dominik,
On Thu, 21 Apr 2016, Dominik Fischer wrote:
> Indeed this needs more explanations for everyone who did not read the posts
> before.

Such as is the case for me. And most future readers of the commit messages ;-)

> I strove to create an add.patch configuration option that did the same as
> always passing the parameter --patch to git-add.

Ah. So a much more intriguing mail subject would be "add: optionally imply --patch by default"?

Show 6 quoted lines
> Junio C Hamano then made me aware that when set, this option would
> influence and possibly destroy other commands that internally use
> git-add. So I implemented the recursion counter, which is now the first
> of the two commits. With this, git-add is able to only consider the
> configuration option when run directly by the user, not affecting any
> commands building upon it.

Hmm. But what if `git add` was not run by the user, but rather by a script? I am wary that the recursion counter may not really be able to answer the question "Was this `git add` called by the user *directly*?".

> I would be interested whether this is a suited method to restrict the
> effect of a configuration option to cases where a command is explicitly
> invoked by the user.
As I said, I do not think this method can do that reliably.

Traditionally, we recommend aliases in such a case. They are just as opt-in and also config settings:

	git config [--global] alias.ap 'add -p'
Then, `git ap m*.cpp` would work just like you would expect.

Ciao, Johannes

Previous: Johannes Schindelin
Message 10 of 10 in “add a add.patch config variable”
  1. 0/2 add a add.patch config variableXZS, Apr 21, 2016
  2. 1/2 count recursion depthXZS, Apr 21, 2016
  3. 2/2 add a add.patch config variableXZS, Apr 21, 2016
  4. Johannes SchindelinApr 21, 2016
  5. Dominik FischerApr 21, 2016
  6. Matthieu MoyApr 21, 2016
  7. Junio C HamanoApr 21, 2016
  8. Dominik FischerApr 21, 2016
  9. Johannes SchindelinApr 22, 2016
  10. Johannes SchindelinApr 22, 2016

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.