bugGNU patch - Bugs: bug #33081, auto detect strip level

 
 

bug #33081: auto detect strip level

Submitted by:  Dustin Kirkland <kirkland>
Submitted on:  Fri 15 Apr 2011 02:05:55 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Open

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

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

 

Fri 15 Apr 2011 02:05:55 AM UTC, original submission:

Howdy!

As an Ubuntu distribution developer and packager, I often use diff and patch hundreds of times per day. One thing that costed me quite of bit of time, however, was reading the first few lines of a patch file to manually determine the strip level.

Eventually, I decided to wrap patch itself in a shell script that tries each patch level from 0 - 16 with the --dry-run parameter, and if it finds one that works, then it actually uses that strip level and really applies the patch! It's a sort of "do what I mean" approach to patch, that's a little friendlier to deal with.

For bonus points, I also added support to the shell script to detect if the patch argument looked like a URL, then retrieve it via wget before trying to apply it.

I called my shell script "apply-patch", which we're temporarily shipping in the Ubuntu project/package called "bikeshed" (a place for those tools that don't quite fit anywhere else).

Two questions for the great custodians of patch...

1) Would you be willing/interested in accepting a POSIX shell script (and manpage) like this into your patch project? I'll attach both for your review.

2) Alternatively, I spent several hours trying to hack similar support into patch.c and pch.c, but unfortunately, the use of global variables, and lack of any real central, re-entrant point in the code makes it difficult to iterate through a sequence of possible strip levels. But if you would rather see this sort of code go directly into the C source, and you can offer some pointers, I would be happy to work on this.

Cheers,
:-Dustin

Dustin Kirkland <kirkland>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #23247:  apply-patch added by kirkland (2kB - application/octet-stream)
file #23248:  apply-patch.1 added by kirkland (1kB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by kirkland (Submitted the item)
  •  

    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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 15 Apr 2011 02:05:55 AM UTCkirklandAttached File-=>Added apply-patch, #23247
      Attached File-=>Added apply-patch.1, #23248

    Back to the top


    Powered by Savane 3.1-cleanup