Skip to content

Commit

Permalink
Still more updates to 'p'
Browse files Browse the repository at this point in the history
  • Loading branch information
neilbrown committed May 21, 2006
1 parent 35b574f commit 1c5bfa7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions p
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ commit_one()

discard_one()
{
rm -f "$1"
cp "$1~current~" $1
cmp -s "$1~current~" $1 || { rm -f "$1" ; cp "$1~current~" $1; }
chmod u+w $1
}

Expand Down Expand Up @@ -234,7 +233,8 @@ save_patch()
find_prefix()
{
# set "prefix" to number for -pn by looking at first file in given patch.
file=`lsdiff $1 | head -1`
n=${2-1}
file=`lsdiff $1 | head -$n | tail -1`
orig=$file
prefix=0
while [ \( -n "$file" -a ! -f "$file" \) -o " $file" != " ${file#/}" ]
Expand All @@ -243,7 +243,11 @@ find_prefix()
prefix=`expr $prefix + 1`
done
if [ -z "$file" ]
then echo "Cannot find $orig" >&2 ; exit 1;
then echo "Cannot find $orig" >&2
if [ $n -gt 4 ]
then exit 2;
else find_prefix "$1" $[n+1]
fi
fi
if [ " $orig" != " $file" ]
then
Expand Down

0 comments on commit 1c5bfa7

Please sign in to comment.