From 5263b27b3c86a8a5f2046540884ed6b85f0b9fbc Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Sun, 8 Mar 2009 15:41:12 +0100 Subject: series command: add --color option --- quilt.quiltrc | 1 + quilt/scripts/patchfns.in | 2 +- quilt/series.in | 36 +++++++++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/quilt.quiltrc b/quilt.quiltrc index bed300c..ce2a513 100644 --- a/quilt.quiltrc +++ b/quilt.quiltrc @@ -15,6 +15,7 @@ QUILT_PATCH_OPTS="--unified" QUILT_PUSH_ARGS="--color=auto" QUILT_DIFF_ARGS="--no-timestamps --color=auto" QUILT_REFRESH_ARGS="--no-timestamps --backup" +QUILT_SERIES_ARGS="--color=auto" # (Add "-p ab" to QUILT_DIFF_ARGS and QUILT_REFRESH_ARGS to get # -p1 style diffs with a/file and b/file filenams in headers diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in index 89a9697..5a1a8ac 100644 --- a/quilt/scripts/patchfns.in +++ b/quilt/scripts/patchfns.in @@ -953,7 +953,7 @@ print_patch() { setup_colors() { - local C=diff_hdr=32:diff_add=36:diff_mod=35:diff_rem=35:diff_hunk=33:diff_ctx=35:diff_cctx=33:patch_offs=33:patch_fuzz=35:patch_fail=31:patch_applied=32:clear=00 + local C=diff_hdr=32:diff_add=36:diff_mod=35:diff_rem=35:diff_hunk=33:diff_ctx=35:diff_cctx=33:patch_offs=33:patch_fuzz=35:patch_fail=31:patch_applied=32:series_app=32:series_top=32:series_una=:clear=00 [ -n "$QUILT_COLORS" ] && C="$C:$QUILT_COLORS" C=${C//=/=\'$'\e'[} diff --git a/quilt/series.in b/quilt/series.in index fa1d192..c3e6d25 100644 --- a/quilt/series.in +++ b/quilt/series.in @@ -35,17 +35,17 @@ Print the names of all patches in the series file. cat_patches() { - local prefix=$1 - shift + local color=$1 prefix=$2 + shift 2 local patch for patch in "$@" do - echo "$prefix$(print_patch "$patch")" + echo "$color$prefix$(print_patch "$patch")$color_clear" done } -options=`getopt -o vh -- "$@"` +options=`getopt -o vh --long color:: -- "$@"` if [ $? -ne 0 ] then @@ -60,6 +60,19 @@ do -v) opt_verbose=1 shift ;; + --color) + case "$2" in + "" | always) + opt_color=1 ;; + auto | tty) + opt_color= + [ -t 1 ] && opt_color=1 ;; + never) + opt_color= ;; + *) + usage ;; + esac + shift 2 ;; -h) usage -h ;; --) @@ -73,14 +86,19 @@ then usage fi -if [ -n "$opt_verbose" ] +if [ -n "$opt_verbose$opt_color" ] then + [ -n "$opt_color" ] && setup_colors + top=$(top_patch) - cat_patches "+ " $(patches_before $top) - [ -n "$top" ] && cat_patches "= " $top - cat_patches " " $(patches_after $top) + cat_patches "$color_series_app" \ + "${opt_verbose:++ }" $(patches_before $top) + [ -n "$top" ] && cat_patches "$color_series_top" \ + "${opt_verbose:+= }" $top + cat_patches "$color_series_una" \ + "${opt_verbose:+ }" $(patches_after $top) else - cat_patches "" $(cat_series) + cat_patches "" "" $(cat_series) fi ### Local Variables: ### mode: shell-script -- cgit