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

Re: [PATCH 1/5] apply: error on --intent-to-add outside gitdir

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2025, 18:34 UTC
Message-ID
<xmqqfrfh13k5.fsf@gitster.g>
In-Reply-To
<20250628225819.1294068-3-ray@ameretat.dev>
"Raymond E. Pasco" <ray@ameretat.dev> writes:
> It makes no sense to register an intent to add outside a repository. We
> should error out here.

I am not so sure, especially if you still keep the original "if we are using 'git apply' as a better GNU patch, ignore -N" logic.

Not that I am suggesting to also error out when -N is given without --index or --cached, that is.

I think the most problematic is the claim "it makes no sense" is not linked to the conclusion "we should error out". The behaviour of the original code, and the behaviour of the code with this patch in "a better GNU patch" mode is based on "it makes no sense in such a context, hence we just ignore (instead of erroring out)", which makes perfect sense as well.

Show 24 quoted lines
> Based-on-patch-by: Johannes Altmanninger <aclopte@gmail.com>
> Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
> ---
>  apply.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/apply.c b/apply.c
> index 8bbe6ed224..e7856ae6b3 100644
> --- a/apply.c
> +++ b/apply.c
> @@ -174,8 +174,12 @@ int check_apply_state(struct apply_state *state, int force_apply)
>  			return error(_("'%s' outside a repository"), "--cached");
>  		state->check_index = 1;
>  	}
> -	if (state->ita_only && (state->check_index || is_not_gitdir))
> -		state->ita_only = 0;
> +	if (state->ita_only) {
> +		if (is_not_gitdir)
> +			return error(_("'%s' outside a repository"), "--intent-to-add");
> +		if (state->check_index)
> +			state->ita_only = 0;
> +	}
>  	if (state->check_index)
>  		state->unsafe_paths = 0;
Previous: Raymond E. PascoNext: Raymond E. Pasco
Message 3 of 25 in “fix apply --intent-to-add”
  1. 0/5 fix apply --intent-to-addRaymond E. Pasco, Jun 28, 2025
  2. 1/5 apply: error on --intent-to-add outside gitdirRaymond E. Pasco, Jun 28, 2025
  3. Junio C HamanoJun 30, 2025
  4. Raymond E. PascoJul 1, 2025
  5. 2/5 apply: read in the index in --intent-to-add modeRaymond E. Pasco, Jun 28, 2025
  6. Junio C HamanoJun 30, 2025
  7. Raymond E. PascoJul 1, 2025
  8. 3/5 apply: only write intents to add for new filesRaymond E. Pasco, Jun 28, 2025
  9. Junio C HamanoJun 30, 2025
  10. Raymond E. PascoJul 1, 2025
  11. 4/5 t4140: test apply --intent-to-add interactionsRaymond E. Pasco, Jun 28, 2025
  12. 5/5 apply docs: clarify wording for --intent-to-addRaymond E. Pasco, Jun 28, 2025
  13. Lidong YanJun 29, 2025
  14. Raymond E. PascoJun 30, 2025
  15. 0/4 fix apply --intent-to-addRaymond E. Pasco, Jul 2, 2025
  16. 1/4 apply: read in the index in --intent-to-add modeRaymond E. Pasco, Jul 2, 2025
  17. 2/4 apply: only write intents to add for new filesRaymond E. Pasco, Jul 2, 2025
  18. 3/4 t4140: test apply --intent-to-add interactionsRaymond E. Pasco, Jul 2, 2025
  19. 4/4 apply docs: clarify wording for --intent-to-addRaymond E. Pasco, Jul 2, 2025
  20. 0/4 fix apply --intent-to-addRaymond E. Pasco, Jul 7, 2025
  21. 1/4 apply: read in the index in --intent-to-add modeRaymond E. Pasco, Jul 7, 2025
  22. 2/4 apply: only write intents to add for new filesRaymond E. Pasco, Jul 7, 2025
  23. 3/4 t4140: test apply --intent-to-add interactionsRaymond E. Pasco, Jul 7, 2025
  24. 4/4 apply docs: clarify wording for --intent-to-addRaymond E. Pasco, Jul 7, 2025
  25. Junio C HamanoJul 7, 2025

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.