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

 
 

bug #33081: auto detect strip level

Submitter:  Dustin Kirkland <kirkland>
Submitted:  Fri 15 Apr 2011 02:05:55 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

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 Files:
   
   
Comment:
   

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

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-04-15 kirkland Attached File- Added apply-patch, #23247
        Attached File- Added apply-patch.1, #23248

    Back to the top

    Powered by Savane 3.14-eb11.
    Corresponding source code