From: Clemens Buchacher <hidden> Date: 2016-06-15 22:45:15
git apply does not handle diffs without context correctly. Configuring git
gui to show zero context lines therefore breaks staging.
Signed-off-by: Clemens Buchacher <redacted>
---
In reply to this patch I will send a first attempt at fixing this problem
instead of avoiding it. There does not seem to be a straightforward
solution, however, so this should hide the bug for now.
git-gui/git-gui.sh | 2 +-
git-gui/lib/diff.tcl | 2 +-
git-gui/lib/option.tcl | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
@@ -125,7 +125,7 @@ proc do_options {} {{bgui.matchtrackingbranch{mc"Match Tracking Branches"}}{bgui.fastcopyblame{mc"Blame Copy Only On Changed Files"}}{i-20..200gui.copyblamethreshold{mc"Minimum Letters To Blame Copy On"}}-{i-0..99gui.diffcontext{mc"Number of Diff Context Lines"}}+{i-1..99gui.diffcontext{mc"Number of Diff Context Lines"}}{i-0..99gui.commitmsgwidth{mc"Commit Message Text Width"}}{tgui.newbranchtemplate{mc"New Branch Name Template"}}}{
From: Clemens Buchacher <hidden> Date: 2016-06-15 22:45:15
git apply does not work correctly with zero-context patches. It does a
little better with --unidiff-zero.
---
This appears to fix staging hunks with zero context lines in the majority of
cases. Staging individual lines still is a problem frequently.
In any case, it's easy enough to break zero-context diff & patch like this:
echo a > victim
git add victim
echo b >> victim
git diff -U0 | git apply --cached --unidiff-zero
git diff
So before delving into this problem to deeply, I'd like to find out who
needs fixing exactly. Is there documentation defining how zero-context git
diff output should look like? Or is git apply the culprit in the bug above?
Or do we even want to support applying zero-context patches? If not, we
should detect and fail such attempts.
Clemens
git-gui/lib/diff.tcl | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
From: Clemens Buchacher <hidden> Date: 2016-06-15 22:45:16
On Sat, Aug 30, 2008 at 09:43:19PM +0200, Johannes Sixt wrote:
Clemens Buchacher schrieb:
quoted
git apply does not work correctly with zero-context patches. It does a
little better with --unidiff-zero.
No, NO, NOOOOO! This kills your data!
Okay. Since we have 'Stage Line for Commit', supporting this would be almost
pointless anyways. So let's forget about trying to fix this and simply
disable zero-context diff in git-gui, as per my original patch
[PATCH] git gui: show diffs with a minimum of 1 context line
Clemens
From: Clemens Buchacher <hidden> Date: 2016-06-15 22:45:16
Staging hunks without context does not work, because line number
information would have to be recomputed for individual hunks. Since it is
already possible to stage individual lines using 'Stage Line for Commit',
zero context diffs are not really necessary for git gui, however.
Signed-off-by: Clemens Buchacher <redacted>
---
Same patch, different commit message.
git-gui/git-gui.sh | 2 +-
git-gui/lib/diff.tcl | 2 +-
git-gui/lib/option.tcl | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
@@ -125,7 +125,7 @@ proc do_options {} {{bgui.matchtrackingbranch{mc"Match Tracking Branches"}}{bgui.fastcopyblame{mc"Blame Copy Only On Changed Files"}}{i-20..200gui.copyblamethreshold{mc"Minimum Letters To Blame Copy On"}}-{i-0..99gui.diffcontext{mc"Number of Diff Context Lines"}}+{i-1..99gui.diffcontext{mc"Number of Diff Context Lines"}}{i-0..99gui.commitmsgwidth{mc"Commit Message Text Width"}}{tgui.newbranchtemplate{mc"New Branch Name Template"}}}{
From: Shawn O. Pearce <hidden> Date: 2016-06-15 22:45:16
Clemens Buchacher [off-list ref] wrote:
git apply does not handle diffs without context correctly. Configuring git
gui to show zero context lines therefore breaks staging.
Signed-off-by: Clemens Buchacher <redacted>
From: Clemens Buchacher <hidden> Date: 2016-06-15 22:45:16
On Mon, Sep 01, 2008 at 12:33:59PM -0700, Shawn O. Pearce wrote:
Clemens Buchacher [off-list ref] wrote:
quoted
git apply does not handle diffs without context correctly. Configuring git
gui to show zero context lines therefore breaks staging.
Signed-off-by: Clemens Buchacher <redacted>
Thanks, this is queued for 'maint'.
Actually, if you don't mind, I changed the commit message because 'git
apply' is not really to blame here:
Staging hunks without context does not work, because line number
information would have to be recomputed for individual hunks. Since it is
already possible to stage individual lines using 'Stage Line for Commit',
zero context diffs are not really necessary for git gui, however.
Signed-off-by: Clemens Buchacher <redacted>
From: Shawn O. Pearce <hidden> Date: 2016-06-15 22:45:16
Clemens Buchacher [off-list ref] wrote:
Actually, if you don't mind, I changed the commit message because 'git
apply' is not really to blame here:
Staging hunks without context does not work, because line number
information would have to be recomputed for individual hunks. Since it is
already possible to stage individual lines using 'Stage Line for Commit',
zero context diffs are not really necessary for git gui, however.