Bug 1084555 - patch false positive return code???
Summary: patch false positive return code???
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: patch
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tim Waugh
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1084558
TreeView+ depends on / blocked
 
Reported: 2014-04-04 16:27 UTC by David Brown
Modified: 2014-04-09 10:36 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-04-09 10:33:47 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
the patch to apply (1.66 KB, patch)
2014-04-04 16:27 UTC, David Brown
no flags Details | Diff
The perl file to apply the patch to (44.70 KB, application/x-perl)
2014-04-04 16:28 UTC, David Brown
no flags Details
Updated perl without the original patch applied (44.29 KB, application/x-perl)
2014-04-07 14:45 UTC, David Brown
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1084558 0 unspecified CLOSED patch false positive return code??? 2021-02-22 00:41:40 UTC

Internal Links: 1084558

Description David Brown 2014-04-04 16:27:35 UTC
Created attachment 882784 [details]
the patch to apply

Description of problem:


Okay here's some information as to what I've gathered so far...

Please disregard the content of the code I'm greping for key words
only to call out the behavior I'm seeing.

So I think patch is reporting a false positive when trying to
apply the patch and I'm unsure of expected behavior.

$ grep '^+.*named_listen_rules' xcat-2.8-named-bind-port.patch | wc -l
7
$ grep named_listen_rules ddns.pm | wc -l
0

So after some inspection of the patch and the code you should expect
if the patch applies to see 7 new lines with 'named_listen_rules' in
the ddns.pm file.

$ patch -p5 < xcat-2.8-named-bind-port.patch 
patching file ddns.pm
Hunk #1 succeeded at 482 (offset 71 lines).
$ echo $?
0

All seems fine to me nothing in the output or the return code seems
to indicate an error, just simply a warning about an offset in one
of the hunks. However after another grep.

$ grep named_listen_rules ddns.pm | wc -l
5

Seems patch only applied the first hunk and didn't apply the second
hunk of the patch file. Is this really expected behaviour?!?!?!

Version-Release number of selected component (if applicable):
patch-2.7.1-7.fc20.x86_64
patch-2.6-6.el6.x86_64

How reproducible:
Very

Actual results:
The first hunk of the patch was applied with the second seems to be
ignored entirely

Expected results:
I expected both hunks of the patch to be applied.


Additional info:
I'm concerned this is a 'feature' in patch, so my actual concern is the
way rpmbuild is calling patch to make sure there aren't some hidden
unpatched hunks that are silently being forgotten in all the patches both
Fedora and Redhat has.

Comment 1 David Brown 2014-04-04 16:28:08 UTC
Created attachment 882785 [details]
The perl file to apply the patch to

Comment 2 David Brown 2014-04-04 16:58:31 UTC
Ah, found that the context in the first hunk of the patch contains 3 before and 4 after. So that is a bit different... 

Odd that patch still didn't produce an error with it though...

Comment 3 David Brown 2014-04-04 16:59:03 UTC
The RHEL bug is #1084558

Comment 4 Tim Waugh 2014-04-07 09:57:34 UTC
This is what I get:

$ patch -p5 < xcat-2.8-named-bind-port.patch 
patching file ddns.pm
Reversed (or previously applied) patch detected!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file ddns.pm.rej

Did you attach the right version of ddns.pm?

Comment 5 David Brown 2014-04-07 14:45:21 UTC
Created attachment 883634 [details]
Updated perl without the original patch applied

Sorry, thought this was the one that wasn't applied, looks like I did that on a different system.

Comment 6 David Brown 2014-04-07 14:48:45 UTC
I think since the context of the patch is really 3 lines before and 4 lines after patch is interpreting the rest of the patch as garbage? or comments?

I thought those were only allowed in the beginning of a patch?

Comment 7 Tim Waugh 2014-04-09 10:33:47 UTC
Here's what "lsdiff -nvv" (from patchutils) says about it:

3	File #1  	a/xCAT-server/lib/xcat/plugins/ddns.pm
	5	Hunk #1	

So yes, that's the problem: there is an extra context line at the end of the first hunk which causes the rest to be taken as garbage.

Here's why. The first hunk's header says "@@ -411,6 +411,16 @@" -- so there should be 6 lines of context in total. That count is wrong.

"recountdiff xcat-2.8-named-bind-port.patch" produces a correct patch (it changes the 6 to 7).


Note You need to log in before you can comment on or make changes to this bug.