From 1c5bfa7ce4de088e3b942463bb11cdc553a92b97 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 22 May 2006 09:34:17 +1000 Subject: [PATCH] Still more updates to 'p' --- p | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/p b/p index 06de4ab..4166000 100755 --- a/p +++ b/p @@ -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 } @@ -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#/}" ] @@ -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 -- 2.39.5