git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGIT PATCH 5/6] Provide file completion for add/resolved/refresh based on status.

From
Yann Dirson <ydirson@altern.org>
Date
Aug 2, 2007, 20:18 UTC
Message-ID
<20070802201836.16614.49897.stgit@gandelf.nowhere.earth>
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 ;;
Previous: Yann DirsonNext: Yann Dirson
Message 6 of 8 in “Various contrib/ updates”
  1. 0/6 Various contrib/ updatesYann Dirson, Aug 2, 2007
  2. 1/6 Improve stg-fold-files-from doc.Yann Dirson, Aug 2, 2007
  3. 2/6 New contrib scripts: stg-dispatch and stg-show.Yann Dirson, Aug 2, 2007
  4. 3/6 Add -O flag to stg-fold-files-from.Yann Dirson, Aug 2, 2007
  5. 4/6 Add a no-act flag to stg-dispatch and stg-fold-file-from.Yann Dirson, Aug 2, 2007
  6. 5/6 Provide file completion for add/resolved/refresh based on status.Yann Dirson, Aug 2, 2007
  7. 6/6 Fixed completion function hardcoding .git/.Yann Dirson, Aug 2, 2007
  8. Catalin MarinasAug 20, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.