[PATCH v4 0/9] Correct offsets of hunks when one is skipped

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>

I've fixed the second patch to match what was in pu and added some
extra code to patch 4 to handle zero sha1 hashes where the length
varies.

Cover letter to v1:

While working on a patch series to stage selected lines from a hunk
without having to edit it I got worried that subsequent patches would
be applied in the wrong place which lead to this series to correct the
offsets of hunks following those that are skipped or edited.

Interdiff to v3:

diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 05540ee9ef..a9a9478a29 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -15,6 +15,9 @@ diff_cmp () {
 	do
 		sed  -e '/^index/s/[0-9a-f]*[1-9a-f][0-9a-f]*\.\./1234567../' \
 		     -e '/^index/s/\.\.[0-9a-f]*[1-9a-f][0-9a-f]*/..9abcdef/' \
+		     -e '/^index/s/ 00*\.\./ 0000000../' \
+		     -e '/^index/s/\.\.00*$/..0000000/' \
+		     -e '/^index/s/\.\.00* /..0000000 /' \
 		     "$x" >"$x.filtered"
 	done
 	test_cmp "$1.filtered" "$2.filtered"
@@ -32,7 +35,7 @@ test_expect_success 'status works (initial)' '
 '
 
 test_expect_success 'setup expected' '
-	cat >expected <<-EOF
+	cat >expected <<-\EOF
 	new file mode 100644
 	index 0000000..d95f3ad
 	--- /dev/null
@@ -69,7 +72,7 @@ test_expect_success 'status works (commit)' '
 '
 
 test_expect_success 'setup expected' '
-	cat >expected <<-EOF
+	cat >expected <<-\EOF
 	index 180b47c..b6f2c08 100644
 	--- a/file
 	+++ b/file
@@ -93,7 +96,7 @@ test_expect_success 'revert works (commit)' '
 
 
 test_expect_success 'setup expected' '
-	cat >expected <<-EOF
+	cat >expected <<-\EOF
 	EOF
 '
 
@@ -105,7 +108,7 @@ test_expect_success 'dummy edit works' '
 '
 
 test_expect_success 'setup patch' '
-	cat >patch <<-EOF
+	cat >patch <<-\EOF
 	@@ -1,1 +1,4 @@
 	 this
 	+patch
@@ -129,7 +132,7 @@ test_expect_success 'bad edit rejected' '
 '
 
 test_expect_success 'setup patch' '
-	cat >patch <<-EOF
+	cat >patch <<-\EOF
 	this patch
 	is garbage
 	EOF
@@ -142,7 +145,7 @@ test_expect_success 'garbage edit rejected' '
 '
 
 test_expect_success 'setup patch' '
-	cat >patch <<-EOF
+	cat >patch <<-\EOF
 	@@ -1,0 +1,0 @@
 	 baseline
 	+content
@@ -152,7 +155,7 @@ test_expect_success 'setup patch' '
 '
 
 test_expect_success 'setup expected' '
-	cat >expected <<-EOF
+	cat >expected <<-\EOF
 	diff --git a/file b/file
 	index b5dd6c9..f910ae9 100644
 	--- a/file
@@ -225,7 +228,7 @@ test_expect_success 'setup again' '
 
 # Write the patch file with a new line at the top and bottom
 test_expect_success 'setup patch' '
-	cat >patch <<-EOF
+	cat >patch <<-\EOF
 	index 180b47c..b6f2c08 100644
 	--- a/file
 	+++ b/file
@@ -242,7 +245,7 @@ test_expect_success 'setup patch' '
 test_expect_success 'setup expected' '
 	echo diff --git a/file b/file >expected &&
 	cat patch |sed "/^index/s/ 100644/ 100755/" >>expected &&
-	cat >expected-output <<-EOF
+	cat >expected-output <<-\EOF
 	--- a/file
 	+++ b/file
 	@@ -1,2 +1,4 @@
@@ -277,7 +280,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '
 '
 
 test_expect_success 'setup expected' '
-	cat >expected <<-EOF
+	cat >expected <<-\EOF
 	diff --git a/non-empty b/non-empty
 	deleted file mode 100644
 	index d95f3ad..0000000
@@ -300,7 +303,7 @@ test_expect_success 'deleting a non-empty file' '
 '
 
 test_expect_success 'setup expected' '
-	cat >expected <<-EOF
+	cat >expected <<-\EOF
 	diff --git a/empty b/empty
 	deleted file mode 100644
 	index e69de29..0000000


Phillip Wood (9):
  add -i: add function to format hunk header
  t3701: indent here documents
  t3701: use test_write_lines and write_script
  t3701: don't hard code sha1 hash values
  t3701: add failing test for pathological context lines
  add -p: adjust offsets of subsequent hunks when one is skipped
  add -p: calculate offset delta for edited patches
  add -p: fix counting when splitting and coalescing
  add -p: don't rely on apply's '--recount' option

 git-add--interactive.perl  | 106 +++++++++++++----
 t/t3701-add-interactive.sh | 291 +++++++++++++++++++++++++--------------------
 2 files changed, 243 insertions(+), 154 deletions(-)

-- 
2.16.1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux