Changes between Version 4 and Version 5 of CommittersTipsAndTricks


Ignore:
Timestamp:
Jun 2, 2008, 1:18:27 PM (16 years ago)
Author:
raimue (Rainer Müller)
Comment:

New version of the trac-patch script

Legend:

Unmodified
Added
Removed
Modified
  • CommittersTipsAndTricks

    v4 v5  
    2222== Apply patches directly from Trac URL ==
    2323
     24=== Installation ===
    2425Add the following functions to your `.bashrc` in order to apply patches directly from Trac.
    2526 
     
    3031
    3132function trac-patch {
    32     trac-get $1 || return
    33     patch -p0 < $(basename $1)
     33    local cmd=""
     34    while [[ $1 == -* ]]; do
     35        if [[ "$1" == "--" ]]; then
     36            break
     37        fi
     38
     39        cmd="$cmd $1"
     40        shift
     41    done
     42
     43    if [[ -z $cmd ]]; then
     44        cmd="-p0"
     45    fi 
     46
     47    trac-get $1
     48    patch $cmd < $(basename $1)
    3449}
    3550}}}
     51
     52=== Usage ===
    3653
    3754Use like this:
     
    4562$ trac-patch http://trac.macports.org/attachment/ticket/.../Portfile.diff
    4663}}}
     64
     65You can also add options which will get passed through to the patch tool. This is especially useful when the patch needs another prefix level.
     66{{{
     67$ trac-patch -p1 http://trac.macports.org/attachment/ticket/.../Portfile.diff
     68}}}
     69If you don't add any option, `-p0` is used as a default. This should be the most common case.