[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH v2] quilt refresh: Do not remove symlinks
From: |
Jason Wessel |
Subject: |
[Quilt-dev] [PATCH v2] quilt refresh: Do not remove symlinks |
Date: |
Mon, 12 Jan 2015 12:56:27 -0600 |
Change the core behavior of quilt to by default not remove symlinks to
the patch files. A backward compatibility option of
QUILT_RM_SYMLINKS=yes was introduced for the case where a developer
desires the symlinks are erased and replaced by files.
Historical notes:
This is an 6 year old patch that is still actively used for the
Yocto Project and others.
http://lists.nongnu.org/archive/html/quilt-dev/2008-01/msg00004.html
Revised again here:
http://comments.gmane.org/gmane.comp.handhelds.openembedded/34224
Signed-off-by: Jason Wessel <address@hidden>
---
quilt.quiltrc | 4 +++
quilt/refresh.in | 7 +++-
quilt/scripts/patchfns.in | 8 ++++-
test/symlink.test | 81 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 98 insertions(+), 2 deletions(-)
create mode 100644 test/symlink.test
diff --git a/quilt.quiltrc b/quilt.quiltrc
index 58f665e..316452a 100644
--- a/quilt.quiltrc
+++ b/quilt.quiltrc
@@ -35,3 +35,7 @@ QUILT_PATCHES_PREFIX=yes
# Use a specific editor for quilt (defaults to the value of $EDITOR before
# sourcing this configuration file, or vi if $EDITOR wasn't set).
#EDITOR=nedit
+
+#If your patch files are actually symlinks, this option set to yes
+#will break the symlinks should quilt update one of the files.
+#QUILT_RM_SYMLINKS=yes
diff --git a/quilt/refresh.in b/quilt/refresh.in
index 41d43a7..f39a877 100644
--- a/quilt/refresh.in
+++ b/quilt/refresh.in
@@ -324,7 +324,12 @@ if [ -e "$patch_file" ] && \
then
printf $"Patch %s is unchanged\n" "$(print_patch "$patch")"
elif ( [ -z "$QUILT_BACKUP" -o ! -e "$patch_file" ] || \
- mv "$patch_file" "$patch_file~" ) && \
+ if [ -L "$patch_file" -a "$QUILT_RM_SYMLINKS" != "yes" ] ; \
+ then \
+ cp "$patch_file" "$patch_file~"; \
+ else \
+ mv "$patch_file" "$patch_file~"; \
+ fi ) && \
cat_to_new_file "$patch_file" < $tmp_result
then
if [ -n "$opt_fork" ]
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index 3fa26bb..7c7a67f 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -785,7 +785,13 @@ cat_to_new_file()
{
local filename="$1"
- [ -e "$filename" ] && rm -f "$filename"
+ if [ -L "$filename" ]
+ then
+ [ "$QUILT_RM_SYMLINKS" = "yes" ] && rm -f "$filename"
+ elif [ -e "$filename" ]
+ then
+ rm -f "$filename"
+ fi
case "$filename" in
*.gz)
diff --git a/test/symlink.test b/test/symlink.test
new file mode 100644
index 0000000..dc83858
--- /dev/null
+++ b/test/symlink.test
@@ -0,0 +1,81 @@
+ $ mkdir patches
+
+# quilt should not remove symlinks to patch files
+ $ echo foo > foo
+ $ quilt new test.diff
+ > Patch patches/test.diff is now on top
+
+ $ quilt add foo
+ > File foo added to patch patches/test.diff
+
+ $ echo "foo changed" > foo
+ $ quilt refresh
+ > Refreshed patch patches/test.diff
+
+# Setup a symlink
+ $ mv patches/test.diff .
+ $ ln -s ../test.diff patches/test.diff
+ $ readlink patches/test.diff
+ > ../test.diff
+
+ $ echo "foo changed 2" > foo
+ $ quilt refresh
+ > Refreshed patch patches/test.diff
+
+ $ test -L patches/test.diff && echo FOUND_LINK
+ > FOUND_LINK
+
+ $ readlink patches/test.diff
+ > ../test.diff
+
+# Test the refresh --backup without a link
+ $ echo "foo changed 3" > foo
+ $ quilt refresh --backup
+ > Refreshed patch patches/test.diff
+
+ $ test -L patches/test.diff && echo FOUND_LINK
+ > FOUND_LINK
+
+ $ readlink patches/test.diff
+ > ../test.diff
+
+# Test the refresh --backup with a link
+ $ cp test.diff test.diff~
+ $ rm -f patches/test.diff~
+ $ ln -s ../test.diff~ patches/test.diff~
+ $ echo "foo changed 4" > foo
+ $ quilt refresh --backup
+ > Refreshed patch patches/test.diff
+
+ $ test -L patches/test.diff && echo FOUND_LINK
+ > FOUND_LINK
+
+ $ readlink patches/test.diff
+ > ../test.diff
+
+ $ readlink patches/test.diff~
+ > ../test.diff~
+
+# Now test that the symlinks are broken on a refresh with
+# QUILT_RM_SYMLINKS=yes
+
+ $ echo "foo changed 5" > foo
+ $ export QUILT_RM_SYMLINKS=yes
+ $ quilt refresh --backup
+ > Refreshed patch patches/test.diff
+
+ $ test -L patches/test.diff || echo NO_OLD_LINKS_HERE
+ > NO_OLD_LINKS_HERE
+
+ $ readlink patches/test.diff~
+ > ../test.diff
+
+ $ echo "foo changed 6" > foo
+ $ quilt refresh --backup
+ > Refreshed patch patches/test.diff
+
+ $ test -L patches/test.diff || echo NO_OLD_LINKS_HERE
+ > NO_OLD_LINKS_HERE
+
+ $ test -L patches/test.diff~ || echo NO_OLD_LINKS_HERE
+ > NO_OLD_LINKS_HERE
--
1.7.9.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Quilt-dev] [PATCH v2] quilt refresh: Do not remove symlinks,
Jason Wessel <=