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

Re: [PATCH] git-apply.txt: correct description of --cached

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 10, 2020, 16:18 UTC
Message-ID
<xmqqeeoecw4e.fsf@gitster.c.googlers.com>
In-Reply-To
<20200810110338.52203-1-ray@ameretat.dev>
"Raymond E. Pasco" <ray@ameretat.dev> writes:
Show 21 quoted lines
> The blurb for "--cached" says it implies "--index", but in reality
> "--cached" and "--index" are distinct modes with different behavior.
>
> Remove the sentence "This implies `--index`." to make the description
> accurate.
>
> Signed-off-by: Raymond E. Pasco <ray@ameretat.dev>
> ---
>  Documentation/git-apply.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
> index b9aa39000f..373a9354b5 100644
> --- a/Documentation/git-apply.txt
> +++ b/Documentation/git-apply.txt
> @@ -72,7 +72,7 @@ OPTIONS
>  --cached::
>  	Apply a patch without touching the working tree. Instead take the
>  	cached data, apply the patch, and store the result in the index
> -	without using the working tree. This implies `--index`.
> +	without using the working tree.

The updated text is not wrong per-se, but I have a feeling that this is barking up a wrong tree. The implication is probably referring to the fact that "--index" does certain verification and "--cached" does the same (i.e. the patch must be applicable to what is in the index). We may want to update the description for both options.

How about simplifying them like this, perhaps?
 Documentation/git-apply.txt | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/Documentation/git-apply.txt b/Documentation/git-apply.txt
index b9aa39000f..92b5f0ae22 100644
--- a/Documentation/git-apply.txt
+++ b/Documentation/git-apply.txt
@@ -58,21 +58,18 @@ OPTIONS
 --check::
 	Instead of applying the patch, see if the patch is
 	applicable to the current working tree and/or the index
-	file and detects errors.  Turns off "apply".
+	file and detects errors.  Turns off `--apply`.
 
 --index::
-	When `--check` is in effect, or when applying the patch
-	(which is the default when none of the options that
-	disables it is in effect), make sure the patch is
-	applicable to what the current index file records.  If
-	the file to be patched in the working tree is not
-	up to date, it is flagged as an error.  This flag also
-	causes the index file to be updated.
+	Apply the patch to both the contents in the index and in the
+	working tree.  It is an error if the patched file in the
+	working tree is not up to date.
 
 --cached::
-	Apply a patch without touching the working tree. Instead take the
-	cached data, apply the patch, and store the result in the index
-	without using the working tree. This implies `--index`.
+	Apply the patch only to the contents in the index but not to
+	the working tree.  It is OK if the contents in the index
+	and in the working tree are different, as the latter is
+	never looked at.
 
 --intent-to-add::
 	When applying the patch only to the working tree, mark new
Previous: Raymond E. PascoNext: Phillip Wood
Message 27 of 53 in “apply: Allow "new file" patches on i-t-a entries”
  1. apply: Allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 4, 2020
  2. Junio C HamanoAug 4, 2020
  3. Raymond E. PascoAug 4, 2020
  4. apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 4, 2020
  5. apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 4, 2020
  6. Junio C HamanoAug 4, 2020
  7. Raymond E. PascoAug 5, 2020
  8. 0/3 apply: handle i-t-a entries in indexRaymond E. Pasco, Aug 6, 2020
  9. 1/3 apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 6, 2020
  10. 2/3 apply: make i-t-a entries never match worktreeRaymond E. Pasco, Aug 6, 2020
  11. Junio C HamanoAug 6, 2020
  12. Raymond E. PascoAug 6, 2020
  13. 3/3 t4140: test apply with i-t-a pathsRaymond E. Pasco, Aug 6, 2020
  14. Junio C HamanoAug 6, 2020
  15. Raymond E. PascoAug 7, 2020
  16. 0/3 apply: handle i-t-a entries in indexRaymond E. Pasco, Aug 8, 2020
  17. 1/3 apply: allow "new file" patches on i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  18. Phillip WoodAug 8, 2020
  19. 2/3 apply: make i-t-a entries never match worktreeRaymond E. Pasco, Aug 8, 2020
  20. Phillip WoodAug 8, 2020
  21. Raymond E. PascoAug 8, 2020
  22. Phillip WoodAug 8, 2020
  23. Raymond E. PascoAug 8, 2020
  24. Phillip WoodAug 9, 2020
  25. Junio C HamanoAug 9, 2020
  26. git-apply.txt: correct description of --cachedRaymond E. Pasco, Aug 10, 2020
  27. Junio C HamanoAug 10, 2020
  28. Phillip WoodAug 12, 2020
  29. Junio C HamanoAug 12, 2020
  30. Raymond E. PascoAug 12, 2020
  31. Phillip WoodAug 12, 2020
  32. 3/3 t4140: test apply with i-t-a pathsRaymond E. Pasco, Aug 8, 2020
  33. Phillip WoodAug 23, 2020
  34. 1/1 diff-lib: use worktree mode in diffs from i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  35. Martin ÅgrenAug 8, 2020
  36. Raymond E. PascoAug 8, 2020
  37. Martin ÅgrenAug 8, 2020
  38. Junio C HamanoAug 9, 2020
  39. t4069: test diff behavior with i-t-a pathsRaymond E. Pasco, Aug 10, 2020
  40. diff-lib: use worktree mode in diffs from i-t-a entriesRaymond E. Pasco, Aug 10, 2020
  41. diff-lib: use worktree mode in diffs from i-t-a entriesRaymond E. Pasco, Aug 10, 2020
  42. Junio C HamanoAug 10, 2020
  43. Eric SunshineAug 10, 2020
  44. Eric SunshineAug 10, 2020
  45. Junio C HamanoAug 10, 2020
  46. Eric SunshineAug 10, 2020
  47. Junio C HamanoAug 10, 2020
  48. Raymond E. PascoAug 10, 2020
  49. Eric SunshineAug 10, 2020
  50. Junio C HamanoAug 11, 2020
  51. 0/2 apply: reject modification diffs to i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  52. 1/2 apply: reject modification diffs to i-t-a entriesRaymond E. Pasco, Aug 8, 2020
  53. 2/2 t4140: test failure of diff from empty blob to i-t-a pathRaymond E. Pasco, Aug 8, 2020

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.