bugGNU patch - Bugs: bug #33065, Allow idempotent patching

 
 

bug #33065: Allow idempotent patching

Submitted by:  Philip Prindeville <pprindeville>
Submitted on:  Wed 13 Apr 2011 04:54:02 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Wont Fix
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 03 Jan 2013 09:27:20 PM UTC, comment #3:

The description of the --forward option in the man page isn't very clear. Here is a better version:

When a patch does not apply, patch usually checks if the patch
looks like it has been reversed. The --forward option prevents
that.

Patch doesn't ignore (or "silently apply") patches like three-way merge usually does. The result wouldn't be reliable enough with the information available. If you insist on ignoring patches that look like they have already been applied, do so by checking if they can be reverse applied.

Andreas Gruenbacher <agruen>
Project Administrator
Thu 03 Jan 2013 11:03:33 AM UTC, comment #2:

Consider the following in bash:
$patch -s --forward -i mypatch.txt myfile.txt
$echo $?
0
$patch -s --forward -i mypatch.txt myfile.txt
Reversed (or previously applied) patch detected! Skipping patch.
1 out of 1 hunk ignored -- saving rejects to file myfile.txt.rej
$echo $?
1

(i.e. patching one file twice with the same patch)

If I read the manual page correctly, '-s --forward' should silently apply a forward patch, and just drop it if applied already. It does this, but prints a warning and returns non-zero, which is not what one wants when writing shell scripts.

This was tried with patch v. 2.6.1

Kalle Raiskila <kraiskil>
Wed 13 Apr 2011 06:17:14 PM UTC, comment #1:

I am not sure what you mean. A patch that has already been applied can be reverse applied, which reverts it. (This may fail if the patch modifies the same file more than once though.)

Also note that patch uses a heuristic to determine if a patch has already been applied, and that this heuristic can fail. Trying to revert the patch with --reverse --dry-run is safer. This can also fail if a patch file modifies the same file more than once though.

Andreas Gruenbacher <agruen>
Project Administrator
Wed 13 Apr 2011 04:54:02 PM UTC, original submission:

Software projects building their own patched kernel are often the source of kernel fixes. This patches will appear in the project tree and be submitted upstream, eventually appearing in kernel releases.

This creates scenarios where a patch might be attempted on a kernel release that's already been applied.

The --forward flag enables two separate and orthogonal conditions: already applied patches and reversed patches.

Separate options are needed to control reversed and already applied patches. The --forward option partially overlaps with --reverse.

I'm proposing an option called --idempotent that allows already applied patches to be quietly ignored.

Philip Prindeville <pprindeville>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by kraiskil (Posted a comment)
  • -unavailable- added by agruen (Posted a comment)
  • -unavailable- added by pprindeville (Submitted the item)
  • -unavailable- added by pprindeville
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 03 Jan 2013 09:27:20 PM UTCagruenStatusNeed Info=>Wont Fix
      Open/ClosedOpen=>Closed
    Wed 13 Apr 2011 06:17:14 PM UTCagruenStatusNone=>Need Info
    Wed 13 Apr 2011 04:54:02 PM UTCpprindevilleCarbon-Copy-=>Added pprindeville

    Back to the top


    Powered by Savane 3.1-cleanup