[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH] pager support like git
From: |
Bert Wesarg |
Subject: |
[Quilt-dev] [PATCH] pager support like git |
Date: |
Wed, 18 Nov 2009 16:40:40 +0100 |
Include the pager support from the TopGit[1] script into Quilt.
[1]: http://repo.or.cz/w/topgit.git/blob/HEAD:/tg.sh#l295
Signed-off-by: Bert Wesarg <address@hidden>
---
quilt/annotate.in | 2 ++
quilt/applied.in | 2 ++
quilt/diff.in | 4 +++-
quilt/files.in | 2 ++
quilt/header.in | 2 ++
quilt/patches.in | 4 +++-
quilt/push.in | 2 +-
quilt/scripts/patchfns.in | 35 +++++++++++++++++++++++++++++++++++
quilt/series.in | 4 +++-
quilt/unapplied.in | 2 ++
10 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/quilt/annotate.in b/quilt/annotate.in
index 0ef21b5..0fb718a 100644
--- a/quilt/annotate.in
+++ b/quilt/annotate.in
@@ -161,6 +161,8 @@ trap "rm -f $template" EXIT
# Finally, the annotations listing is merged with the source file line
# by line.
+setup_pager
+
empty_file ${files[0]} > $template
for ((n = 0; n < address@hidden; n++))
do
diff --git a/quilt/applied.in b/quilt/applied.in
index 7ead8da..0cea4b8 100644
--- a/quilt/applied.in
+++ b/quilt/applied.in
@@ -59,6 +59,8 @@ fi
patch=$(find_applied_patch "$1") || exit 1
+setup_pager
+
for patch in $(applied_before "$patch") $patch
do
echo "$(print_patch $patch)"
diff --git a/quilt/diff.in b/quilt/diff.in
index 8435024..866d61c 100644
--- a/quilt/diff.in
+++ b/quilt/diff.in
@@ -196,7 +196,7 @@ do
opt_color=1 ;;
auto | tty)
opt_color=
- [ -t 1 ] && opt_color=1 ;;
+ [ -t 1 -o -n "${QUILT_PAGER_IN_USE-}" ] && opt_color=1
;;
never)
opt_color= ;;
*)
@@ -310,6 +310,8 @@ then
|| die 1
fi
+setup_pager
+
for file in "address@hidden"
do
if [ -n "$opt_snapshot" -a -e "$QUILT_PC/$snap_subdir/$file" ]
diff --git a/quilt/files.in b/quilt/files.in
index ba8b054..033abe0 100644
--- a/quilt/files.in
+++ b/quilt/files.in
@@ -159,6 +159,8 @@ list_files_in_patch()
done
}
+setup_pager
+
for patch in address@hidden
do
list_files_in_patch $patch
diff --git a/quilt/header.in b/quilt/header.in
index 70c48b2..fed6dda 100644
--- a/quilt/header.in
+++ b/quilt/header.in
@@ -125,6 +125,8 @@ if [ -z "$opt_replace" -a -z "$opt_append" -a -z
"$opt_edit" ]
then
[ -e "$patch_file" ] || exit 0
+ setup_pager
+
cat_file "$patch_file" \
| patch_header \
| maybe_strip_diffstat \
diff --git a/quilt/patches.in b/quilt/patches.in
index 31d7ef1..668db72 100644
--- a/quilt/patches.in
+++ b/quilt/patches.in
@@ -111,7 +111,7 @@ do
opt_color=1 ;;
auto | tty)
opt_color=
- [ -t 1 ] && opt_color=1 ;;
+ [ -t 1 -o -n "${QUILT_PAGER_IN_USE-}" ] && opt_color=1
;;
never)
opt_color= ;;
*)
@@ -147,6 +147,8 @@ fi
[ -n "$opt_color" ] && setup_colors
+setup_pager
+
scan_applied "$color_series_app" "$applied" "$opt_file" \
$(patches_before $top)
[ -n "$top" ] && \
diff --git a/quilt/push.in b/quilt/push.in
index 92e8d8b..c8f6b48 100644
--- a/quilt/push.in
+++ b/quilt/push.in
@@ -310,7 +310,7 @@ do
opt_color=1 ;;
auto | tty)
opt_color=
- [ -t 1 ] && opt_color=1 ;;
+ [ -t 1 -o -n "${QUILT_PAGER_IN_USE-}" ] && opt_color=1
;;
never)
opt_color= ;;
*)
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index 9723685..ad0b10b 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -968,6 +968,41 @@ quilt_command()
QUILT_COMMAND="" bash $BASH_OPTS -c "${SUBDIR:+cd $SUBDIR;} .
$QUILT_DIR/$command" "quilt $command" "$@"
}
+# isatty FD
+isatty()
+{
+ test -t $1
+}
+
+# setup_pager
+# Spawn pager process and redirect the rest of our output to it
+setup_pager()
+{
+ isatty 1 || return 0
+
+ # QUILT_PAGER = GIT_PAGER | PAGER | less
+ # NOTE: GIT_PAGER='' is significant
+ QUILT_PAGER=${GIT_PAGER-${PAGER-less}}
+
+ [ -z "$QUILT_PAGER" -o "$QUILT_PAGER" = "cat" ] && return 0
+
+
+ # now spawn pager
+ export LESS="${LESS:-FRSX}" # as in pager.c:pager_preexec()
+
+ _pager_fifo_dir="$(mktemp -t -d quilt-pager-fifo.XXXXXX)"
+ _pager_fifo="$_pager_fifo_dir/0"
+ mkfifo -m 600 "$_pager_fifo"
+
+ "$QUILT_PAGER" < "$_pager_fifo" &
+ exec > "$_pager_fifo" # dup2(pager_fifo.in, 1)
+
+ export QUILT_PAGER_IN_USE=1
+
+ # atexit(close(1); wait pager)
+ trap "exec >&-; rm \"$_pager_fifo\"; rmdir \"$_pager_fifo_dir\"; wait"
EXIT
+}
+
#
# If the working directory does not contain a $QUILT_PATCHES directory,
# quilt searches for its base directory up the directory tree. If no
diff --git a/quilt/series.in b/quilt/series.in
index c3e6d25..9482f63 100644
--- a/quilt/series.in
+++ b/quilt/series.in
@@ -66,7 +66,7 @@ do
opt_color=1 ;;
auto | tty)
opt_color=
- [ -t 1 ] && opt_color=1 ;;
+ [ -t 1 -o -n "${QUILT_PAGER_IN_USE-}" ] && opt_color=1
;;
never)
opt_color= ;;
*)
@@ -86,6 +86,8 @@ then
usage
fi
+setup_pager
+
if [ -n "$opt_verbose$opt_color" ]
then
[ -n "$opt_color" ] && setup_colors
diff --git a/quilt/unapplied.in b/quilt/unapplied.in
index 6d0703c..5678595 100644
--- a/quilt/unapplied.in
+++ b/quilt/unapplied.in
@@ -65,6 +65,8 @@ else
patch=$(find_unapplied_patch) || exit 1
fi
+setup_pager
+
(
echo "$patch"
patches_after "$patch"
--
tg: (4df4797..) bw/pager (depends on: master)
- [Quilt-dev] [PATCH] pager support like git,
Bert Wesarg <=