summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2004-01-28 00:20:56 +0000
committerAndreas Gruenbacher <agruen@suse.de>2004-01-28 00:20:56 +0000
commitddce6706ba78d3cbba784b34cfcbef5a5361ccce (patch)
tree8ab1bd94b06c6e42f0fc1b97e2cb3a9966c2e884
parentc8f14351198fc69541f17aae56937b79c8d9a29c (diff)
downloadquilt-ddce6706ba78d3cbba784b34cfcbef5a5361ccce.tar.gz
- Add support for working in subdirectories of the base directory
that contains patches/ and .pc/. In the unlikely case that quilt shall operate in the sub-directory itself, it is sufficient to create a patches/ directory there. - Add a small testcase for subdirectory support.
-rw-r--r--quilt.changes9
-rw-r--r--quilt/add.in14
-rw-r--r--quilt/diff.in16
-rw-r--r--quilt/import.in4
-rw-r--r--quilt/new.in4
-rw-r--r--quilt/patches.in6
-rw-r--r--quilt/refresh.in4
-rw-r--r--quilt/remove.in16
-rw-r--r--quilt/snapshot.in14
-rwxr-xr-xscripts/apatch.in27
-rw-r--r--scripts/patchfns.in51
-rwxr-xr-xscripts/rpatch.in21
-rw-r--r--test/subdir.test73
13 files changed, 191 insertions, 68 deletions
diff --git a/quilt.changes b/quilt.changes
index 5aa915c..7ddb41c 100644
--- a/quilt.changes
+++ b/quilt.changes
@@ -1,4 +1,13 @@
-------------------------------------------------------------------
+Wed Jan 28 01:13:16 CET 2004 - agruen@suse.de
+
+- Add support for working in subdirectories of the base directory
+ that contains patches/ and .pc/. In the unlikely case that
+ quilt shall operate in the sub-directory itself, it is
+ sufficient to create a patches/ directory there.
+- Add a small testcase for subdirectory support.
+
+-------------------------------------------------------------------
Sat Jan 24 23:58:01 CET 2004 - agruen@suse.de
- Add QUILT_NO_DIFF_TIMESTAMPS option in .quiltrc.
diff --git a/quilt/add.in b/quilt/add.in
index a2640d2..55dba96 100644
--- a/quilt/add.in
+++ b/quilt/add.in
@@ -84,23 +84,23 @@ fi
status=0
for file in $*
do
- if file_in_patch $file $patch
+ if file_in_patch $SUBDIR$file $patch
then
- echo $"File $file is already in patch $patch"
+ echo $"File $SUBDIR$file is already in patch $patch"
status=2
continue
fi
- next_patch=$(next_patch_for_file $patch $file)
+ next_patch=$(next_patch_for_file $patch $SUBDIR$file)
if [ -n "$next_patch" ]
then
- echo $"File $file modified by patch $next_patch"
+ echo $"File $SUBDIR$file modified by patch $next_patch"
status=1
continue
fi
- if ! @LIB@/backup-files -s -B .pc/$patch/ $file
+ if ! @LIB@/backup-files -s -B $QUILT_PC/$patch/ $SUBDIR$file
then
- echo $"Failed to back up file $file" >&2
+ echo $"Failed to back up file $SUBDIR$file" >&2
status=1
continue
fi
@@ -120,7 +120,7 @@ do
fi
fi
- echo $"File $file added to patch $patch"
+ echo $"File $SUBDIR$file added to patch $patch"
done
exit $status
### Local Variables:
diff --git a/quilt/diff.in b/quilt/diff.in
index f9cb2d6..c3788e3 100644
--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -137,7 +137,7 @@ do
esac
done
-opt_files=( "$@" )
+opt_files=( $(for file in "$@"; do echo "$SUBDIR$file" ; done) )
if [ $[0$opt_combine + 0$opt_snapshot + 0$opt_relative] -gt 1 ]
then
@@ -182,9 +182,9 @@ then
# have changed).
while read file
do
- echo "${file#.pc/$snap_subdir/}" >&4
+ echo "${file#$QUILT_PC/$snap_subdir/}" >&4
done \
- < <(find .pc/$snap_subdir -type f)
+ < <(find $QUILT_PC/$snap_subdir -type f)
# Also look at all patches that are currently applied.
opt_combine=1
first_patch="$(applied_patches | head -n 1)"
@@ -233,9 +233,9 @@ then
workdir=$(gen_tempfile -d $PWD/quilt)
pwd=$PWD
- if ! cd .pc/$last_patch
+ if ! cd $QUILT_PC/$last_patch
then
- echo $"Cannot change into .pc/$last_patch"
+ echo $"Cannot change into $QUILT_PC/$last_patch"
die 1
fi
if ! cp -l --parents "${files[@]}" $workdir/
@@ -268,7 +268,7 @@ then
# relative diff for a subset of files in the patch
# will fail.
- if [ ! -e $pwd/.pc/$last_patch~refresh -a \
+ if [ ! -e $pwd/$QUILT_PC/$last_patch~refresh -a \
${#opt_files[@]} -eq 0 ]
then
echo $"Failed to patch temporary files"
@@ -285,9 +285,9 @@ fi
for file in "${files[@]}"
do
- if [ -n "$opt_snapshot" -a -e ".pc/$snap_subdir/$file" ]
+ if [ -n "$opt_snapshot" -a -e "$QUILT_PC/$snap_subdir/$file" ]
then
- old_file=".pc/$snap_subdir/$file"
+ old_file="$QUILT_PC/$snap_subdir/$file"
elif [ -n "$opt_relative" ]
then
old_file="$workdir/$file"
diff --git a/quilt/import.in b/quilt/import.in
index 9964dce..3ae54d1 100644
--- a/quilt/import.in
+++ b/quilt/import.in
@@ -58,7 +58,7 @@ do
-n)
opt_patch=$(echo "$2" |
@SED@ -e 's/^'"$(quote_bre $QUILT_PATCHES)"'\///' \
- -e 's/^\.pc\///')
+ -e 's/^\$QUILT_PC\///')
shift 2 ;;
-p)
opt_strip=$2
@@ -186,7 +186,7 @@ else
fi
fi
-rm -rf .pc/$patch
+rm -rf $QUILT_PC/$patch
if ! patch_in_series $patch &&
! insert_in_series $opt_patch "$patch_args"
diff --git a/quilt/new.in b/quilt/new.in
index 2266e19..5ec86d6 100644
--- a/quilt/new.in
+++ b/quilt/new.in
@@ -68,8 +68,8 @@ then
exit 1
fi
-rm -rf ".pc/$patch"
-mkdir -p ".pc/$patch"
+rm -rf "$QUILT_PC/$patch"
+mkdir -p "$QUILT_PC/$patch"
if ! insert_in_series $patch_file || \
! add_to_db $patch
diff --git a/quilt/patches.in b/quilt/patches.in
index ad05cc4..5a77075 100644
--- a/quilt/patches.in
+++ b/quilt/patches.in
@@ -41,13 +41,13 @@ Note that this heuristic is much slower than scanning applied patches.)
scan_applied()
{
- local prefix=$1 file=$2
+ local prefix=$1 file=$SUBDIR$2
shift 2
local patch
for patch in "$@"
do
- if [ -f ".pc/$patch/$file" ]
+ if [ -f "$QUILT_PC/$patch/$file" ]
then
[ -n "$opt_filenames" ] && \
patch=$(patch_file_name $patch)
@@ -58,7 +58,7 @@ scan_applied()
scan_unapplied()
{
- local prefix=$1 file=$2
+ local prefix=$1 file=$SUBDIR$2
shift 2
local file_bre="$(quote_bre $file)" patch
diff --git a/quilt/refresh.in b/quilt/refresh.in
index a22fadb..99de471 100644
--- a/quilt/refresh.in
+++ b/quilt/refresh.in
@@ -193,9 +193,9 @@ then
die 1
fi
-touch .pc/$patch/.timestamp
+touch $QUILT_PC/$patch/.timestamp
-rm -f .pc/$patch~refresh
+rm -f $QUILT_PC/$patch~refresh
echo $"Refreshed patch $patch"
if ! change_db_strip_level -p$opt_strip_level $patch
then
diff --git a/quilt/remove.in b/quilt/remove.in
index 6e5511e..976a9fd 100644
--- a/quilt/remove.in
+++ b/quilt/remove.in
@@ -83,31 +83,31 @@ fi
status=0
for file in $*
-do
- if ! file_in_patch $file $patch
+do
+ if ! file_in_patch $SUBDIR$file $patch
then
- echo $"File $file is not in patch $patch"
+ echo $"File $SUBDIR$file is not in patch $patch"
status=1
continue
fi
- next_patch=$(next_patch_for_file $patch $file)
+ next_patch=$(next_patch_for_file $patch $SUBDIR$file)
if [ -n "$next_patch" ]
then
- echo $"File $file modified by patch $next_patch"
+ echo $"File $SUBDIR$file modified by patch $next_patch"
status=1
continue
fi
# Restore file from backup
- if ! @LIB@/backup-files -s -B .pc/$patch/ -r $file
+ if ! @LIB@/backup-files -s -B $QUILT_PC/$patch/ -r $SUBDIR$file
then
- echo $"Failed to remove file $file from patch $patch"
+ echo $"Failed to remove file $SUBDIR$file from patch $patch"
status=1
continue
fi
- echo $"File $file removed from patch $patch"
+ echo $"File $SUBDIR$file removed from patch $patch"
done
exit $status
### Local Variables:
diff --git a/quilt/snapshot.in b/quilt/snapshot.in
index 453f265..dc5ba60 100644
--- a/quilt/snapshot.in
+++ b/quilt/snapshot.in
@@ -66,8 +66,8 @@ fi
snap_subdir=.snap
# Clean up from previous snapshot
-rm -rf .pc/$snap_subdir
-mkdir -p .pc/$snap_subdir
+rm -rf $QUILT_PC/$snap_subdir
+mkdir -p $QUILT_PC/$snap_subdir
if [ -n "$opt_remove" ]
then
@@ -79,14 +79,14 @@ for patch in $(applied_patches | tac)
do
for file in $(files_in_patch $patch)
do
- if ! [ -e ".pc/$snap_subdir/$file" ]
+ if ! [ -e "$QUILT_PC/$snap_subdir/$file" ]
then
- mkdir -p ".pc/$snap_subdir/$(dirname $file)"
+ mkdir -p "$QUILT_PC/$snap_subdir/$(dirname $file)"
if [ -e "$file" ]
then
- ln "$file" ".pc/$snap_subdir/$file"
+ ln "$file" "$QUILT_PC/$snap_subdir/$file"
else
- touch ".pc/$snap_subdir/$file"
+ touch "$QUILT_PC/$snap_subdir/$file"
fi
fi
done
@@ -96,7 +96,7 @@ done
# (which represent files that the patch creates). Those may have
# been created in the meantime, but patch would refuse to touch
# them: We must remove them here.
-find .pc/$snap_subdir -type f -size 0 -exec rm -f '{}' ';'
+find $QUILT_PC/$snap_subdir -type f -size 0 -exec rm -f '{}' ';'
### Local Variables:
### mode: shell-script
diff --git a/scripts/apatch.in b/scripts/apatch.in
index bba756f..2ec69bc 100755
--- a/scripts/apatch.in
+++ b/scripts/apatch.in
@@ -44,15 +44,18 @@ apply_patch()
if [ "x${patch_file:(-3)}" = "x.gz" ]
then
gzip -cd $patch_file \
- | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) --backup --prefix=".pc/$patch/" \
+ | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
+ --backup --prefix="$QUILT_PC/$patch/" \
-E $silent $force_apply 2>&1
elif [ "x${patch_file:(-4)}" = "x.bz2" ]
then
bzip2 -cd $patch_file \
- | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) --backup --prefix=".pc/$patch/" \
+ | @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
+ --backup --prefix="$QUILT_PC/$patch/" \
-E $silent $force_apply 2>&1
else
- @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) --backup --prefix=".pc/$patch/" \
+ @PATCH@ $QUILT_PATCH_OPTS $(patch_args $patch) \
+ --backup --prefix="$QUILT_PC/$patch/" \
-E $silent $force_apply -i $patch_file 2>&1
fi
}
@@ -63,7 +66,8 @@ rollback_patch()
# FIXME backup_files should scan the directory hierarchy itself.
files_in_patch $patch > $pc_file
- @LIB@/backup-files $silent_unless_verbose -f $pc_file -B .pc/$patch/ -r
+ @LIB@/backup-files $silent_unless_verbose \
+ -f $pc_file -B $QUILT_PC/$patch/ -r
if [ -z "$opt_leave_rejects" ]
then
@SED@ -e 's/$/\.rej/' $pc_file | xargs rm -f
@@ -88,7 +92,8 @@ apatch()
then
# The reject files are removed in rollback_patch.
echo "$output" \
- | sed -e 's/-- saving rejects to file \(.\+\)\.rej/-- rejects in file \1/'
+ | sed -e \
+'s/-- saving rejects to file \(.\+\)\.rej/-- rejects in file \1/'
elif [ -n "$output" ]
then
echo "$output"
@@ -99,17 +104,17 @@ apatch()
add_to_db $patch
if [ $status -eq 0 ]
then
- rm -f .pc/$patch~refresh
+ rm -f $QUILT_PC/$patch~refresh
else
- touch .pc/$patch~refresh
+ touch $QUILT_PC/$patch~refresh
fi
- if [ -e ".pc/$patch" ]
+ if [ -e "$QUILT_PC/$patch" ]
then
- touch .pc/$patch/.timestamp
+ touch $QUILT_PC/$patch/.timestamp
fi
- if [ "$(shopt -s nullglob ; echo .pc/$patch/*)" = "" ]
+ if [ "$(shopt -s nullglob ; echo $QUILT_PC/$patch/*)" = "" ]
then
echo $"Patch $patch appears to be empty, applied"
elif [ $status -ne 0 ]
@@ -173,7 +178,7 @@ fi
patch=$(stripit $1)
top=$(top_patch)
-if [ -n "$top" -a -e .pc/$top~refresh ]
+if [ -n "$top" -a -e $QUILT_PC/$top~refresh ]
then
echo $"The topmost patch $top needs to be refreshed first."
exit 1
diff --git a/scripts/patchfns.in b/scripts/patchfns.in
index a715033..17275f6 100644
--- a/scripts/patchfns.in
+++ b/scripts/patchfns.in
@@ -9,17 +9,51 @@
export TEXTDOMAIN=quilt
-
if [ -e $HOME/.quiltrc ]
then
. $HOME/.quiltrc
fi
: ${QUILT_PATCHES:=patches}
+: ${QUILT_PC:=.pc}
-if [ -e .pc/series ]
+#
+# If the working directory does not contain a $QUILT_PATCHES directory,
+# quilt searches for its base directory up the directory tree. If no
+# $QUILT_PATCHES directory exists, the quilt operations that create
+# patches will create $QUILT_PATCHES in the current working directory.
+#
+# When quilt is invoked from a directory below the base directory, it
+# changes into the base directory, and sets $SUBDIR to the relative
+# path from the base directory to the directory in which it was
+# invoked. (e.g., if quilt is invoked in /usr/src/linux/drivers/net
+# and the base direcory is /usr/src/linux, $SUBDIR is set to
+# drivers/net/.
+
+unset SUBDIR
+if ! [ -d "$QUILT_PATCHES" ]
then
- SERIES=.pc/series
+ basedir=$PWD
+ while [ -n "$basedir" ]
+ do
+ basedir=${basedir%/*}
+ if [ -d "$basedir/$QUILT_PATCHES" ]
+ then
+ SUBDIR="${PWD#$basedir/}/"
+ if ! cd $basedir
+ then
+ echo "Cannot change into parent directory $basedir" >&2
+ exit 1
+ fi
+ break
+ fi
+ done
+ unset basedir
+fi
+
+if [ -e $QUILT_PC/series ]
+then
+ SERIES=$QUILT_PC/series
elif [ -e series ]
then
SERIES=series
@@ -27,7 +61,8 @@ else
SERIES=$QUILT_PATCHES/series
fi
-DB=".pc/applied-patches"
+DB="$QUILT_PC/applied-patches"
+
# Quote a string for use in a basic regular expression.
quote_bre()
@@ -239,7 +274,7 @@ backup_file_name()
local patch=$1
while [ $# -gt 1 ]
do
- echo ".pc/$patch/$2"
+ echo "$QUILT_PC/$patch/$2"
shift
done
}
@@ -391,13 +426,13 @@ stripit()
file_in_patch()
{
local file=$1 patch=$2
- [ -f ".pc/$patch/$file" ]
+ [ -f "$QUILT_PC/$patch/$file" ]
}
files_in_patch()
{
local patch="$1"
- local path=".pc/$patch"
+ local path="$QUILT_PC/$patch"
if [ -d "$path" ]
then
for file in $(find "$path" -type f \
@@ -585,7 +620,7 @@ first_modified_by()
fi
for patch in ${patches[@]}
do
- if [ -f ".pc/$patch/$file" ]
+ if [ -f "$QUILT_PC/$patch/$file" ]
then
echo $patch
return 0
diff --git a/scripts/rpatch.in b/scripts/rpatch.in
index eeb1363..e4dfefb 100755
--- a/scripts/rpatch.in
+++ b/scripts/rpatch.in
@@ -28,13 +28,14 @@ files_may_have_changed()
local patch=$1 file
local patch_file=$(patch_file_name $patch)
- if [ $? -ne 0 -o ! -e "$patch_file" -o ! -e ".pc/$patch/.timestamp" \
- -o ".pc/$patch/.timestamp" -ot "$patch_file" ]
+ if [ $? -ne 0 -o ! -e "$patch_file" \
+ -o ! -e "$QUILT_PC/$patch/.timestamp" \
+ -o "$QUILT_PC/$patch/.timestamp" -ot "$patch_file" ]
then
return 0
fi
- local apply_ts=$(date -r ".pc/$patch/.timestamp" '+%s') ts
+ local apply_ts=$(date -r "$QUILT_PC/$patch/.timestamp" '+%s') ts
for file in $(files_in_patch $patch)
do
ts=$(date -r $file '+%s' 2> /dev/null)
@@ -53,10 +54,10 @@ check_for_pending_changes()
local patch_args=$(patch_args $patch)
local workdir=$(gen_tempfile -d quilt) status=0
- if [ -d .pc/$patch ]
+ if [ -d $QUILT_PC/$patch ]
then
if ! rmdir $workdir || # note that this is racey...
- ! cp -rl .pc/$patch $workdir/
+ ! cp -rl $QUILT_PC/$patch $workdir/
then
echo $"Failed to copy files to temporary directory"
rm -rf $workdir
@@ -84,7 +85,7 @@ check_for_pending_changes()
# files won't succeed, either. So, ignore the error
# in that particular case.
- if ! [ -e .pc/$patch ]
+ if ! [ -e $QUILT_PC/$patch ]
then
echo $"Failed to patch temporary files"
rm -rf $workdir
@@ -133,11 +134,11 @@ rpatch()
if [ $status -eq 0 ]
then
echo $"Removing $patch"
- rm -f ".pc/$patch/.timestamp"
- @LIB@/backup-files $silent -f $pc_file -B .pc/$patch/ -r
+ rm -f "$QUILT_PC/$patch/.timestamp"
+ @LIB@/backup-files $silent -f $pc_file -B $QUILT_PC/$patch/ -r
status=$?
remove_from_db $patch
- rm -f .pc/$patch~refresh
+ rm -f $QUILT_PC/$patch~refresh
fi
rm -f $pc_file
trap - SIGINT
@@ -187,7 +188,7 @@ patch=$(stripit $1)
[ -z "$opt_verbose" ] && silent_unless_verbose=-s
top=$(top_patch)
-if [ -n "$top" -a -e .pc/$top~refresh -a -z "$opt_force" ]
+if [ -n "$top" -a -e $QUILT_PC/$top~refresh -a -z "$opt_force" ]
then
echo $"The topmost patch $top needs to be refreshed first."
exit 1
diff --git a/test/subdir.test b/test/subdir.test
new file mode 100644
index 0000000..2763b8f
--- /dev/null
+++ b/test/subdir.test
@@ -0,0 +1,73 @@
+ $ mkdir d
+ $ cd d
+
+ $ mkdir subdir
+ $ cat > subdir/file
+ < old file
+
+ $ quilt new test
+ > Patch test is now on top
+
+ $ quilt add subdir/file
+ > File subdir/file added to patch test
+
+ $ cat > subdir/file
+ < new contents
+
+ This creates the patches/ directory:
+
+ $ quilt refresh
+ > Refreshed patch test
+
+ $ cd subdir
+ $ quilt add file2
+ > File subdir/file2 added to patch test
+
+ $ cat > file2
+ < another file
+
+ $ cat > file3
+ < yet another file
+
+ $ quilt add file3
+ > File subdir/file3 added to patch test
+
+ $ rm file3
+ $ quilt files
+ > subdir/file
+ > subdir/file2
+ > subdir/file3
+
+ $ quilt diff | sed -e "s/\\t.*//"
+ > Index: d/subdir/file
+ > ===================================================================
+ > --- d.orig/subdir/file
+ > +++ d/subdir/file
+ > @@ -1 +1 @@
+ > -old file
+ > +new contents
+ > Index: d/subdir/file2
+ > ===================================================================
+ > --- d.orig/subdir/file2
+ > +++ d/subdir/file2
+ > @@ -0,0 +1 @@
+ > +another file
+ > Index: d/subdir/file3
+ > ===================================================================
+ > --- d.orig/subdir/file3
+ > +++ d/subdir/file3
+ > @@ -1 +0,0 @@
+ > -yet another file
+
+ $ quilt refresh
+ > Refreshed patch test
+
+ $ quilt remove file2
+ > File subdir/file2 removed from patch test
+
+ $ quilt files
+ > subdir/file
+ > subdir/file3
+
+ $ cd ../..
+ $ rm -rf d