Skip to content

Commit 5df4d67

Browse files
peffgitster
authored andcommitted
docs: give more hints about how "add -e" works
The previous text was not exactly accurate; it is OK to change space and minus lines, but only in certain ways. This patch attempts to cover explicitly what can be done at the individual line level, and cautions the user that conceptually larger changes (like modifying a line) require some understanding of the patch format. Signed-off-by: Jeff King <[email protected]> Reviewed-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5b57413 commit 5df4d67

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

Documentation/git-add.txt

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,35 @@ See ``Interactive mode'' for details.
9292
edit it. After the editor was closed, adjust the hunk headers
9393
and apply the patch to the index.
9494
+
95-
*NOTE*: Obviously, if you change anything else than the first character
96-
on lines beginning with a space or a minus, the patch will no longer
97-
apply.
95+
The intent of this option is to pick and choose lines of the patch to
96+
apply, or even to modify the contents of lines to be staged. There are
97+
three line types in a patch: addition lines (beginning with a plus),
98+
removal lines (beginning with a minus), and context lines (beginning
99+
with a space). In general, it should be safe to:
100+
+
101+
--
102+
* remove addition lines (don't stage the line)
103+
* modify the content of any addition lines (stage modified contents)
104+
* add new addition lines (stage the new line)
105+
* convert context lines to removal lines (stage removal of line)
106+
* convert removal lines to context lines (don't stage removal)
107+
--
108+
+
109+
Similarly, your patch will likely not apply if you:
110+
+
111+
--
112+
* add context or removal lines
113+
* delete removal or context lines
114+
* modify the contents of context or removal lines
115+
--
116+
+
117+
NOTE: In the first list above, the results given for each action are
118+
with respect to that patch line only. Conceptual changes like
119+
modification of a line in the original file are actually represented by
120+
removal of the old line followed by addition of the new line. Deleting
121+
only the addition line of this pair but leaving the removal line would
122+
therefore convert the modification into a deletion. In other words, use
123+
this feature with caution, as it is easy to stage unintended changes.
98124

99125
-u::
100126
--update::

0 commit comments

Comments
 (0)