summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2004-01-28 01:36:39 +0000
committerAndreas Gruenbacher <agruen@suse.de>2004-01-28 01:36:39 +0000
commit78aa77c7415f569ad964d8b5b03ddb048f90beee (patch)
treea8e3645f5bf1b705d7db5b9df4045f9efa54464c
parent74367691ed6938fb64ee66df6c9db99d6b1870f9 (diff)
downloadquilt-78aa77c7415f569ad964d8b5b03ddb048f90beee.tar.gz
- Add a few more test cases for subdirectory support.
- Fix a few bugs introduced while merging Chris's patch.
-rw-r--r--quilt.changes6
-rw-r--r--quilt/add.in10
-rw-r--r--quilt/diff.in5
-rw-r--r--test/one.test9
-rwxr-xr-xtest/run12
-rw-r--r--test/snapshot2.test61
-rw-r--r--test/two.test157
7 files changed, 248 insertions, 12 deletions
diff --git a/quilt.changes b/quilt.changes
index 61dbe3c..98d9d20 100644
--- a/quilt.changes
+++ b/quilt.changes
@@ -1,4 +1,10 @@
-------------------------------------------------------------------
+Wed Jan 28 02:32:51 CET 2004 - agruen@suse.de
+
+- Add a few more test cases for subdirectory support.
+- Fix a few bugs introduced while merging Chris's patch.
+
+-------------------------------------------------------------------
Wed Jan 28 01:13:16 CET 2004 - agruen@suse.de
- Patch from Chris Mason <mason@suse.de>: Add support for working
diff --git a/quilt/add.in b/quilt/add.in
index 55dba96..d93ee2a 100644
--- a/quilt/add.in
+++ b/quilt/add.in
@@ -105,17 +105,17 @@ do
continue
fi
- if [ -e $file ]
+ if [ -e $SUBDIR$file ]
then
- if [ "$(ls -dl $file | @AWK@ '{print $2}')" -gt 1 ]
+ if [ "$(ls -dl $SUBDIR$file | @AWK@ '{print $2}')" -gt 1 ]
then
# We have a file with several hard links.
# As the file may likely be modified by hand
# now, create a copy to make sure nothing
# happens to the original file.
- tmpfile=$(gen_tempfile $file) &&
- cp -fp $file $tmpfile &&
- mv -f $tmpfile $file
+ tmpfile=$(gen_tempfile $SUBDIR$file) &&
+ cp -fp $SUBDIR$file $tmpfile &&
+ mv -f $tmpfile $SUBDIR$file
rm -f $tmpfile
fi
fi
diff --git a/quilt/diff.in b/quilt/diff.in
index c3788e3..4c0465a 100644
--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -220,7 +220,7 @@ do
continue
fi
echo "$file" >&4
- done < <(files_in_patch $patch)
+ done
done
exec 4>&- # close $tmp_files
@@ -238,7 +238,8 @@ then
echo $"Cannot change into $QUILT_PC/$last_patch"
die 1
fi
- if ! cp -l --parents "${files[@]}" $workdir/
+ if [ ${#files[@]} -gt 0 ] \
+ && ! cp -l --parents "${files[@]}" $workdir/
then
echo $"Failed to copy files to temporary directory"
die 1
diff --git a/test/one.test b/test/one.test
index d72858f..4e7819a 100644
--- a/test/one.test
+++ b/test/one.test
@@ -54,6 +54,15 @@ of the installed quilt with `make check'.
> This is file one.
> +Another line has been added.
+ $ quilt diff -z dir/file1 | sed -e "s/\\t.*//"
+ > Index: d/dir/file1
+ > ===================================================================
+ > --- d.orig/dir/file1
+ > +++ d/dir/file1
+ > @@ -1 +1,2 @@
+ > This is file one.
+ > +Another line has been added.
+
$ quilt refresh
> Refreshed patch patch1
diff --git a/test/run b/test/run
index f60f9c6..026263a 100755
--- a/test/run
+++ b/test/run
@@ -13,11 +13,12 @@ use strict;
use FileHandle;
use Getopt::Std;
use POSIX qw(isatty setuid);
-use vars qw($opt_v);
+use vars qw($opt_l $opt_v);
no warnings qw(taint);
-getopts('v');
+$opt_l = ~0; # a really huge number
+getopts('l:v');
my ($OK, $FAILED) = ("ok", "failed");
if (isatty(fileno(STDOUT))) {
@@ -28,12 +29,12 @@ if (isatty(fileno(STDOUT))) {
sub exec_test($$);
my ($prog, $in, $out) = ([], [], []);
-my $line_number = 0;
my $prog_line;
my ($tests, $failed) = (0,0);
+my $lineno;
for (;;) {
- my $line = <>; $line_number++;
+ my $line = <>; $lineno++;
if (defined $line) {
# Substitute %VAR and %{VAR} with environment variables.
$line =~ s[%(?:(\w+)|\{(\w+)\})][$ENV{"$1$2"}]eg;
@@ -45,6 +46,7 @@ for (;;) {
push @$out, $line;
} else {
process_test($prog, $prog_line, $in, $out);
+ last if $prog_line >= $opt_l;
$prog = [];
$prog_line = 0;
@@ -52,7 +54,7 @@ for (;;) {
if ($line =~ s/^\s*\$ ?//) {
$line =~ s/\s+#.*//; # remove comments here...
$prog = [ map { s/\\(.)/$1/g; $_ } split /(?<!\\)\s+/, $line ];
- $prog_line = $line_number;
+ $prog_line = $lineno;
$in = [];
$out = [];
}
diff --git a/test/snapshot2.test b/test/snapshot2.test
new file mode 100644
index 0000000..89daa32
--- /dev/null
+++ b/test/snapshot2.test
@@ -0,0 +1,61 @@
+ $ mkdir -p d/patches d/d
+ $ cd d/d
+
+ $ quilt new snapshot
+ > Patch snapshot is now on top
+ $ quilt add f.txt
+ > File d/f.txt added to patch snapshot
+ $ cat > f.txt
+ < f.txt
+
+ $ quilt add g.txt
+ > File d/g.txt added to patch snapshot
+ $ cat > g.txt
+ < g.txt
+
+ $ quilt refresh
+ > Refreshed patch snapshot
+ $ quilt snapshot
+ $ quilt pop -q
+ > Removing snapshot
+ > No patches applied
+
+ $ quilt fork
+ > Fork of patches/snapshot created as patches/snapshot-2
+
+ $ quilt push -q
+ > Applying snapshot-2
+ > Now at patch snapshot-2
+
+ $ quilt remove g.txt
+ > File d/g.txt removed from patch snapshot-2
+
+ $ quilt add h.txt
+ > File d/h.txt added to patch snapshot-2
+
+ $ cat > h.txt
+ < h.txt
+
+ $ cat >> f.txt
+ < more changes
+
+ $ quilt refresh
+ > Refreshed patch snapshot-2
+
+ $ quilt diff --snapshot | grep -v "^\\(---\\|+++\\)"
+ > Index: d/d/f.txt
+ > ===================================================================
+ > @@ -1 +1,2 @@
+ > f.txt
+ > +more changes
+ > Index: d/d/g.txt
+ > ===================================================================
+ > @@ -1 +0,0 @@
+ > -g.txt
+ > Index: d/d/h.txt
+ > ===================================================================
+ > @@ -0,0 +1 @@
+ > +h.txt
+
+ $ cd ../..
+ $ rm -rf d
diff --git a/test/two.test b/test/two.test
new file mode 100644
index 0000000..4d48467
--- /dev/null
+++ b/test/two.test
@@ -0,0 +1,157 @@
+(To run, type `./run two.test' in this directory.)
+
+ $ mkdir -p d/patches d/d
+ $ cd d/d
+ $ mkdir dir
+ $ echo "This is file one." > dir/file1
+ $ quilt new patch1.diff
+ > Patch patch1 is now on top
+
+ $ quilt add dir/file1
+ > File d/dir/file1 added to patch patch1
+
+ $ quilt add file2
+ > File d/file2 added to patch patch1
+
+ $ quilt diff
+ $ quilt diff -z
+ $ quilt refresh
+ > Nothing in patch patch1
+
+ $ echo "This is file two." > file2
+ $ quilt diff | sed -e "s/\\t.*//"
+ > Index: d/d/file2
+ > ===================================================================
+ > --- d.orig/d/file2
+ > +++ d/d/file2
+ > @@ -0,0 +1 @@
+ > +This is file two.
+
+ $ quilt diff -z | sed -e "s/\\t.*//"
+ > Index: d/d/file2
+ > ===================================================================
+ > --- d.orig/d/file2
+ > +++ d/d/file2
+ > @@ -0,0 +1 @@
+ > +This is file two.
+
+ $ quilt refresh
+ > Refreshed patch patch1
+
+ $ quilt diff -z
+ $ echo "Another line has been added." >> dir/file1
+ $ quilt diff -z | sed -e "s/\\t.*//"
+ > Index: d/d/dir/file1
+ > ===================================================================
+ > --- d.orig/d/dir/file1
+ > +++ d/d/dir/file1
+ > @@ -1 +1,2 @@
+ > This is file one.
+ > +Another line has been added.
+
+ $ cd dir
+ $ quilt diff -z file1
+ > Index: d/d/dir/file1
+ > ===================================================================
+ > --- d.orig/d/dir/file1
+ > +++ d/d/dir/file1
+ > @@ -1 +1,2 @@
+ > This is file one.
+ > +Another line has been added.
+
+ $ cd ..
+
+ $ quilt refresh
+ > Refreshed patch patch1
+
+ $ quilt new patch2.diff
+ > Patch patch2 is now on top
+
+ $ quilt add dir/file3
+ > File d/dir/file3 added to patch patch2
+
+ $ echo "This is file three." > dir/file3
+ $ quilt refresh
+ > Refreshed patch patch2
+
+ $ quilt add -p patch1 dir/file3
+ > File d/dir/file3 modified by patch patch2
+
+ $ quilt pop -R
+ > Removing patch2
+ > Removing d/dir/file3
+ >
+ > Now at patch patch1
+
+ $ quilt add file4
+ > File d/file4 added to patch patch1
+
+ $ echo "This is file 4." > file4
+ $ quilt refresh
+ > Refreshed patch patch1
+
+ $ quilt push
+ > Applying patch2
+ > patching file d/dir/file3
+ >
+ > Now at patch patch2
+
+ $ quilt new subdir/patch3.diff
+ > Patch subdir/patch3 is now on top
+
+ $ quilt add file4
+ > File d/file4 added to patch subdir/patch3
+
+ $ rm file4
+ $ quilt diff | sed -e "s/\\t.*//"
+ > Index: d/d/file4
+ > ===================================================================
+ > --- d.orig/d/file4
+ > +++ d/d/file4
+ > @@ -1 +0,0 @@
+ > -This is file 4.
+
+ $ quilt add -p patch2 file4
+ > File d/file4 modified by patch subdir/patch3
+
+ $ quilt refresh
+ > Refreshed patch subdir/patch3
+
+ $ echo "Another line here, too." >> dir/file3
+ $ quilt refresh patch2
+ > Refreshed patch patch2
+
+ $ echo "Another line added." >> file2
+ $ quilt diff -z -P patch1 | sed -e "s/\\t.*//"
+ > Index: d/d/file2
+ > ===================================================================
+ > --- d.orig/d/file2
+ > +++ d/d/file2
+ > @@ -1 +1,2 @@
+ > This is file two.
+ > +Another line added.
+ > More recent patches modify files in patch1.
+
+ $ quilt refresh patch1
+ > More recent patches modify files in patch1. Enforce refresh with -f.
+
+ $ quilt refresh -f patch1
+ > Refreshed patch patch1
+
+ $ echo "Another line here, too." >> dir/file3
+ $ quilt pop -R
+ > Removing subdir/patch3
+ > Restoring d/file4
+ >
+ > Now at patch patch2
+
+ $ quilt refresh patch2
+ > Refreshed patch patch2
+
+ $ quilt pop -qaR
+ > Removing patch2
+ > Removing patch1
+ > No patches applied
+
+ $ cd ../..
+ $ rm -rf d