git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yann Dirson <ydirson@altern.org>
To: Catalin Marinas <catalin.marinas@gmail.com>
Cc: git@vger.kernel.org
Subject: [StGIT PATCH 5/6] Provide file completion for add/resolved/refresh based on status.
Date: Thu, 02 Aug 2007 22:18:36 +0200	[thread overview]
Message-ID: <20070802201836.16614.49897.stgit@gandelf.nowhere.earth> (raw)
In-Reply-To: <20070802200704.16614.57993.stgit@gandelf.nowhere.earth>

Signed-off-by: Yann Dirson <ydirson@altern.org>
---

 contrib/stgit-completion.bash |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/contrib/stgit-completion.bash b/contrib/stgit-completion.bash
index a843db4..2d0d5f2 100644
--- a/contrib/stgit-completion.bash
+++ b/contrib/stgit-completion.bash
@@ -111,6 +111,30 @@ _all_branches ()
     [ "$g" ] && (cd .git/patches/ && echo *)
 }
 
+_conflicting_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && stg status --conflict
+}
+
+_dirty_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && stg status --modified --new --deleted
+}
+
+_unknown_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && stg status --unknown
+}
+
+_known_files ()
+{
+    local g=$(_gitdir)
+    [ "$g" ] && git ls-files
+}
+
 # List the command options
 _cmd_options ()
 {
@@ -162,6 +186,11 @@ _complete_options ()
     COMPREPLY=($(compgen -W "$options" -- "${COMP_WORDS[COMP_CWORD]}"))
 }
 
+_complete_files ()
+{
+    COMPREPLY=($(compgen -W "$(_cmd_options $1) $2" -- "${COMP_WORDS[COMP_CWORD]}"))
+}
+
 _stg_common ()
 {
     _complete_options "$(_cmd_options $1)"
@@ -223,12 +252,16 @@ _stg ()
         log)    _stg_patches $command _all_patches ;;
         mail)   _stg_patches $command _all_patches ;;
         pick)   _stg_patches $command _unapplied_patches ;;
-        refresh)_stg_patches_options $command _applied_patches "-p --patch" ;;
+#	refresh)_stg_patches_options $command _applied_patches "-p --patch" ;;
+        refresh) _complete_files $command "$(_dirty_files)" ;;
         rename) _stg_patches $command _all_patches ;;
         show)   _stg_patches $command _all_patches ;;
         sync)   _stg_patches $command _applied_patches ;;
         # working-copy commands
         diff)   _stg_patches_options $command _applied_patches "-r --range" ;;
+	resolved) _complete_files $command "$(_conflicting_files)" ;;
+	add)	_complete_files $command "$(_unknown_files)" ;;
+#	rm)	_complete_files $command "$(_known_files)" ;;
 	# commands that usually raher accept branches
 	branch) _complete_branch $command _all_branches ;;
 	rebase) _complete_branch $command _all_branches ;;

  parent reply	other threads:[~2007-08-02 20:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-02 20:18 [StGIT PATCH 0/6] Various contrib/ updates Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 1/6] Improve stg-fold-files-from doc Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 2/6] New contrib scripts: stg-dispatch and stg-show Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 3/6] Add -O flag to stg-fold-files-from Yann Dirson
2007-08-02 20:18 ` [StGIT PATCH 4/6] Add a no-act flag to stg-dispatch and stg-fold-file-from Yann Dirson
2007-08-02 20:18 ` Yann Dirson [this message]
2007-08-02 20:18 ` [StGIT PATCH 6/6] Fixed completion function hardcoding .git/ Yann Dirson
2007-08-20 17:24 ` [StGIT PATCH 0/6] Various contrib/ updates Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070802201836.16614.49897.stgit@gandelf.nowhere.earth \
    --to=ydirson@altern.org \
    --cc=catalin.marinas@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).