Implement a new "quilt shell" command

Bug-Debian: https://bugs.debian.org/526141
Forwarded: submitted 2012-12-19

The command launches a shell in a duplicate environment. After exiting
the shell, any modifications made in this environment are applied to the
topmost patch.

Gbp-Pq: Name shell-subcommand
This commit is contained in:
Josselin Mouette 2022-12-06 14:41:58 +08:00 committed by luoyaoming
parent c560f7140b
commit eb6734a842
2 changed files with 68 additions and 1 deletions

View File

@ -30,7 +30,7 @@ _quilt_completion()
# quilt sub commands
cmds='add annotate applied delete diff edit files fold fork graph \
grep header import init mail new next patches pop previous push refresh \
remove rename revert series setup snapshot top unapplied upgrade'
remove rename revert series setup shell snapshot top unapplied upgrade'
# if no command were given, complete on commands
if [[ $COMP_CWORD -eq 1 ]] ; then

67
quilt/shell.in Normal file
View File

@ -0,0 +1,67 @@
#! @BASH@
# This script is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# See the COPYING and AUTHORS files for more details.
# Read in library functions
if [ "$(type -t patch_file_name)" != function ]
then
if ! [ -r $QUILT_DIR/scripts/patchfns ]
then
echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
exit 1
fi
. $QUILT_DIR/scripts/patchfns
fi
if [ "$1" = "-h" ]; then
printf $"Usage: quilt shell [command]\n"
printf $"
Launch a shell in a duplicate environment. After exiting the shell, any
modifications made in this environment are applied to the topmost patch.
If a command is specified, it is executed instead of launching the shell.
"
exit 0
fi
tmpdir=$(mktemp -d /tmp/quilt-XXXXXX)
cp -a . $tmpdir
(
cd $tmpdir/"$SUBDIR"
if [ $# -gt 0 ]; then
exec "$@"
else
$SHELL
fi
)
# Find new directories
( cd $tmpdir; find . -type d ! -path ./"$QUILT_PC"/\* ! -path ./"$QUILT_PATCHES"/\* ) | while read dir; do
if [ ! -d "$dir" ]; then
mkdir -p "$dir"
fi
done
# New and modified files
( cd $tmpdir; find . -type f ! -path ./"$QUILT_PC"/\* ! -path ./"$QUILT_PATCHES"/\* ) | while read file; do
if [ ! -f "$file" ] || ! diff -q "$file" $tmpdir/"$file" > /dev/null 2>&1; then
quilt_command add "$file"
cp -a $tmpdir/"$file" "$file"
fi
done
# Removed files
( find . -type f ! -path ./"$QUILT_PC"/\* ! -path ./"$QUILT_PATCHES"/\* ) | while read file; do
if [ ! -f $tmpdir/"$file" ]; then
quilt_command add "$file"
rm -f "$file"
fi
done
rm -rf $tmpdir