But this one just made it into Ubuntu Natty (11.04), and my bash history says that I've used it 30+ times already this week...
I think Larry Wall's diff and patch utilities are among the most important programs in all of free software. These are the most fundamental tools that allow us to modify code, share those modifications with one another in both a human and machine readable format, and apply those changes elsewhere. It's not uncommon for me to use the two of them more than a hundred times in a work day.
And yet there's two things that bother me about patch...
- the -p|--strip parameter should be auto detected, if unspecified
- usually, I just want to pass a file in as a parameter using tab-completion, rather than piping it or redirecting it from standard input
Example:
kirkland@x201:/tmp/foo/patch-2.6$ apply-patch debian/patches/lenny-options patching file src/patch.c patching file patch.man
Useful to anyone besides me?
I'm pretty sure I could hack patch.c and pch.c in the upstream source for patch to do this auto detection of strip level, but I wonder if upstream would take it?
:-Dustin
You make awesome utilities.
ReplyDeleteUpstream might be more receptive to an additional command-line arg that turns on autostrip, rather than making it default.
Nice! I often find that I want to wget a patch and apply it. I use a crappy script for doing this, but I often find i need to adjust the strip level, depending on the patch source.
ReplyDeleteI could either convert wpatch to pipe into apply-patch... or my favoured option.. apply-patch learns to support remote retrieval of patches... whatcha think? :)
$ cat ~/bin/wpatch
#!/bin/sh
wget -qO- "$1" | patch -p1
Daviey, brilliant idea :-) Can you open an LP bug? I have some code for adding 'apply-patch URL' support tested and working :-) I'd love to commit it with an LP bug number!
ReplyDelete:-Dustin
Daviey:
ReplyDelete* http://paste.ubuntu.com/586595/
:-Dustin
Couldn't hurt to ask upstream, I think. Any existing script with a patch command not specifying a -p* shouldn't be any more broken if it autodetected, so it doesn't seem like the change would do harm.
ReplyDeleteNice tool, gentoo uses something similiar in it's eutils.eclass (a set of helper functions for the package manager) you might find some inspiration there: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/eutils.eclass (search for "epatch")
ReplyDeleteBTW: you can specify -i to give patch a filename instead of piping stdin