diff options
author | Bert Wesarg <bert.wesarg@googlemail.com> | 2009-11-18 23:30:11 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2009-11-20 22:55:22 +0100 |
commit | cfaa6e0db5cd73f655dc6388311dff0da5d4bfcf (patch) | |
tree | 8fac3ab42ff0480902bcb6a8f3b47d3fe7aeaa09 | |
parent | 393c487db5e08d0176666c288303597cf8a2d65d (diff) | |
download | quilt-cfaa6e0db5cd73f655dc6388311dff0da5d4bfcf.tar.gz |
pager support like git
Include the pager support from the TopGit script into Quilt.
Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>
-rw-r--r-- | quilt/annotate.in | 2 | ||||
-rw-r--r-- | quilt/applied.in | 2 | ||||
-rw-r--r-- | quilt/diff.in | 2 | ||||
-rw-r--r-- | quilt/files.in | 2 | ||||
-rw-r--r-- | quilt/header.in | 2 | ||||
-rw-r--r-- | quilt/patches.in | 2 | ||||
-rw-r--r-- | quilt/scripts/patchfns.in | 32 | ||||
-rw-r--r-- | quilt/series.in | 2 | ||||
-rw-r--r-- | quilt/unapplied.in | 2 |
9 files changed, 48 insertions, 0 deletions
diff --git a/quilt/annotate.in b/quilt/annotate.in index 8bf50ef..0366f5a 100644 --- a/quilt/annotate.in +++ b/quilt/annotate.in @@ -161,6 +161,8 @@ add_exit_handler "rm -f $template" # Finally, the annotations listing is merged with the source file line # by line. +setup_pager + empty_file ${files[0]} > $template for ((n = 0; n < ${#patches[@]}; 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..86da3f5 100644 --- a/quilt/diff.in +++ b/quilt/diff.in @@ -310,6 +310,8 @@ then || die 1 fi +setup_pager + for file in "${files[@]}" 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 ${patches[@]} do list_files_in_patch $patch diff --git a/quilt/header.in b/quilt/header.in index f1a14e4..a3bbcbc 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..fe95300 100644 --- a/quilt/patches.in +++ b/quilt/patches.in @@ -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/scripts/patchfns.in b/quilt/scripts/patchfns.in index c2946bc..b0ed135 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -976,6 +976,38 @@ 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="$(gen_tempfile -d)" + _pager_fifo="$_pager_fifo_dir/0" + mkfifo -m 600 "$_pager_fifo" + + "$QUILT_PAGER" < "$_pager_fifo" & + exec > "$_pager_fifo" # dup2(pager_fifo.in, 1) + + # atexit(close(1); wait pager) + add_exit_handler "exec >&-; rm \"$_pager_fifo\"; rmdir \"$_pager_fifo_dir\"; wait" +} + # # 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..f2fee9e 100644 --- a/quilt/series.in +++ b/quilt/series.in @@ -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" |