Hi all,

in the attached patch is my solution for this bug.

regards,
Daniel Lovasko

diff --git a/bash_completion b/bash_completion
index 19736cb..1241d15 100644
--- a/bash_completion
+++ b/bash_completion
@@ -86,6 +86,21 @@ _quilt_comfile()
         done
 }
 
+# Resolve paths to patches only inside QUILT_PATCHES directory
+# 
+# Problem with `quilt series` within completion is it's nature of output
+#  as it produces relative path to current working directory, instead of 
+#  relative path to QUILT_PATCHES directory.
+#
+# sed explanation: capture as many as possible of "../" and after that
+#  QUILT_PATCHES directory name (if not defined, use default "patches")
+#  and remove it all from each filename
+#
+_quilt_patchlist()
+{
+       quilt $1 | perl -pne 's:^(\.\./)*\Q'"${QUILT_PATCHES:-patches}"'\E/?::'
+}
+
 _quilt_completion()
 {
     local cur prev cmds command_matches
@@ -123,7 +138,7 @@ _quilt_completion()
        add)
           case $prev in
             -P)
-               COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- 
$cur ) )
+               COMPREPLY=( $( compgen -W "$(_quilt_patchlist applied 
2>/dev/null)" -- $cur ) )
                ;;
             *)
                _quilt_comfile
@@ -134,7 +149,7 @@ _quilt_completion()
        annotate)
           case $prev in
             -P)
-               COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- 
$cur ) )
+               COMPREPLY=( $( compgen -W "$(_quilt_patchlist applied 
2>/dev/null)" -- $cur ) )
                ;;
             *)
                _quilt_comfile
@@ -143,10 +158,10 @@ _quilt_completion()
           esac
           ;;
        applied) 
-          COMPREPLY=( $( compgen -W "-h $(quilt applied 2>/dev/null)" -- $cur 
) )
+          COMPREPLY=( $( compgen -W "-h $(_quilt_patchlist applied 
2>/dev/null)" -- $cur ) )
           ;;
        delete) 
-          COMPREPLY=( $( compgen -W "-n -r -h --backup $(quilt series)" -- 
$cur ) )
+          COMPREPLY=( $( compgen -W "-n -r -h --backup $(_quilt_patchlist 
series)" -- $cur ) )
           ;;
        diff) 
           case $prev in
@@ -154,7 +169,7 @@ _quilt_completion()
                COMPREPLY=( $( compgen -W "0 1" -- $cur ) )
                ;;
             -P|--combine)
-               COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- 
$cur ) )
+               COMPREPLY=( $( compgen -W "$(_quilt_patchlist applied 
2>/dev/null)" -- $cur ) )
                ;;
             --diff|-U|-C)
                ;;
@@ -171,10 +186,10 @@ _quilt_completion()
        files)
           case $prev in
             --combine)
-               COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- 
$cur ) )
+               COMPREPLY=( $( compgen -W "$(_quilt_patchlist applied 
2>/dev/null)" -- $cur ) )
                ;;
             *)
-               COMPREPLY=( $( compgen -W "-a -l -v -h --combine $(quilt 
applied 2>/dev/null)" -- $cur ) )
+               COMPREPLY=( $( compgen -W "-a -l -v -h --combine 
$(_quilt_patchlist applied 2>/dev/null)" -- $cur ) )
                ;;
           esac
           ;;
@@ -198,7 +213,7 @@ _quilt_completion()
                COMPREPLY=( $( compgen -W "files" -- $cur ) )
                ;;
             *)
-               COMPREPLY=( $( compgen -W "-T -h --all --reduce --lines 
--edge-labels $(quilt applied 2>/dev/null)" -- $cur ) )
+               COMPREPLY=( $( compgen -W "-T -h --all --reduce --lines 
--edge-labels $(_quilt_patchlist applied 2>/dev/null)" -- $cur ) )
                ;;
           esac
           ;;
@@ -207,7 +222,7 @@ _quilt_completion()
           COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-h" -- $cur ) )
           ;;
        header)
-          COMPREPLY=( $( compgen -W "-a -e -h -r --backup --strip-diffstat 
--strip-trailing-whitespace $(quilt series)" -- $cur ) )
+          COMPREPLY=( $( compgen -W "-a -e -h -r --backup --strip-diffstat 
--strip-trailing-whitespace $(_quilt_patchlist series)" -- $cur ) )
           ;;
        import)
           case $prev in
@@ -229,17 +244,17 @@ _quilt_completion()
           COMPREPLY=( $( compgen -W "-m --prefix --mbox --send --sender --from 
--subject --to --cc --bcc" -- $cur ) )
           ;;
        next|previous)
-          COMPREPLY=( $( compgen -W "$(quilt series)" -- $cur ) )
+          COMPREPLY=( $( compgen -W "$(_quilt_patchlist series)" -- $cur ) )
           ;;
        patches)
           _quilt_comfile 
           COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -W "-v -h" -- $cur ) )
           ;;
        pop)
-          COMPREPLY=( $( compgen -W "-a -f -R -q -v -h $(quilt applied 
2>/dev/null)" -- $cur ) )
+          COMPREPLY=( $( compgen -W "-a -f -R -q -v -h $(_quilt_patchlist 
applied 2>/dev/null)" -- $cur ) )
           ;;
        push)
-          COMPREPLY=( $( compgen -W "-a -f -q -v -h --leave-rejects 
--interactive --color $(quilt unapplied 2>/dev/null)" -- $cur ) )
+          COMPREPLY=( $( compgen -W "-a -f -q -v -h --leave-rejects 
--interactive --color $(_quilt_patchlist unapplied 2>/dev/null)" -- $cur ) )
           ;;
        refresh)
           case $prev in
@@ -249,14 +264,14 @@ _quilt_completion()
             -U|-C)
                ;;
             *)
-               COMPREPLY=( $( compgen -W "-p -u -U -c -C -f -h $(quilt applied 
2>/dev/null) --no-timestamps --no-index --diffstat --sort --backup 
--strip-trailing-whitespace" -- $cur ) )
+               COMPREPLY=( $( compgen -W "-p -u -U -c -C -f -h 
$(_quilt_patchlist applied 2>/dev/null) --no-timestamps --no-index --diffstat 
--sort --backup --strip-trailing-whitespace" -- $cur ) )
                ;;
           esac
           ;;
        remove|revert)
           case $prev in
             -P)
-               COMPREPLY=( $( compgen -W "$(quilt applied 2>/dev/null)" -- 
$cur ) )
+               COMPREPLY=( $( compgen -W "$(_quilt_patchlist applied 
2>/dev/null)" -- $cur ) )
                ;;
             *)
                _quilt_comfile 
@@ -267,7 +282,7 @@ _quilt_completion()
        rename)
           case $prev in
             -P)
-               COMPREPLY=( $( compgen -W "$(quilt series)" -- $cur ) )
+               COMPREPLY=( $( compgen -W "$(_quilt_patchlist series)" -- $cur 
) )
                ;;
             *)
                COMPREPLY=( $( compgen -W "-P -h" -- $cur ) )
@@ -292,7 +307,7 @@ _quilt_completion()
           COMPREPLY=( $( compgen -W "-d -h" -- $cur ) )
           ;;
        unapplied)
-          COMPREPLY=( $( compgen -W "-h $(quilt series)" -- $cur ) )
+          COMPREPLY=( $( compgen -W "-h $(_quilt_patchlist series)" -- $cur ) )
           ;;
        fork|new|top|upgrade)
           ;;
_______________________________________________
Quilt-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to