Bug 5917 - record (e.g. `hg ci -i` and `hg split`) crashes with "bad hunk #1" if diff makes a file empty
Summary: record (e.g. `hg ci -i` and `hg split`) crashes with "bad hunk #1" if diff ma...
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: 4.6
Hardware: PC Linux
: wish feature
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-13 19:31 UTC by Martin von Zweigbergk
Modified: 2018-06-26 00:00 UTC (History)
1 user (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin von Zweigbergk 2018-06-13 19:31 UTC
Here's a patch showing a test case that passes:

diff --git a/tests/test-commit-interactive-curses.t b/tests/test-commit-interactive-curses.t
--- a/tests/test-commit-interactive-curses.t
+++ b/tests/test-commit-interactive-curses.t
@@ -214,6 +214,16 @@ Amend option works
   @@ -0,0 +1,1 @@
   +hello world
 
+Make file empty
+  $ echo -n > x
+  $ cat <<EOF >testModeCommands
+  > X
+  > EOF
+  $ hg ci -i -m emptify -d "0 0"
+  abort: bad hunk #1
+  [255]
+  $ hg revert x
+
 Editing a hunk puts you back on that hunk when done editing (issue5041)
 To do that, we change two lines in a file, pretend to edit the second line,
 exit, toggle the line selected at the end of the edit and commit.
Comment 1 HG Bot 2018-06-18 09:45 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/03350f5234a4
Jun Wu <quark@fb.com>
crecord: fix line number in hunk header (issue5917)

`@@ -1,1 +-1,0 @@` is not a valid patch hunk header.
Change it to `@@ -1,1 +0,0 @@`.

Differential Revision: https://phab.mercurial-scm.org/D3737

(please test the fix)
Comment 2 Bugzilla 2018-06-26 00:00 UTC
Bug was set to TESTING for 7 days, resolving