# [StGit PATCH 1/2] Modify bash completion to support help, version, and copyright.

7 messages from 2009-01-20 to 2009-01-23. Participants: ted@tedpavlic.com, Ted Pavlic, Karl Hasselström.
Thread: https://gitlist.dev/t/17264

## ted@tedpavlic.com, 2009-01-20 00:46

Subject: [StGit PATCH 1/2] Modify bash completion to support help, version, and copyright.
Message-ID: <1232412373-10836-1-git-send-email-ted@tedpavlic.com>
URL: https://gitlist.dev/e/1232412373-10836-1-git-send-email-ted%40tedpavlic.com

```
From: Ted Pavlic <ted@tedpavlic.com>

"stg <tab>" lists all commands, including "help", "version", and
"copyright".

"stg he<tab>" completes "stg help "
"stg ver<tab>" completes "stg version "
"stg copy<tab>" completes "stg copyright "

"stg help <tab>" lists all commands /other than/ help, version, and
copyright.

"stg version <tab>" goes directly to shell completion.
"stg copyright <tab>" goes directly to shell completion.

Signed-off-by: Ted Pavlic <ted@tedpavlic.com>
---
 stgit/completion.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/stgit/completion.py b/stgit/completion.py
index affc8c6..b3fd282 100644
--- a/stgit/completion.py
+++ b/stgit/completion.py
@@ -111,13 +111,19 @@ def main_switch(commands):
         ('# Complete name of subcommand if the user has not finished'
          ' typing it yet.'),
         'if test $c -eq $COMP_CWORD -a -z "$command"; then', [
-            ('COMPREPLY=($(compgen -W "$_stg_commands" --'
+            ('COMPREPLY=($(compgen -W "help version copyright $_stg_commands" --'
              ' "${COMP_WORDS[COMP_CWORD]}"))'),
             'return'],
         'fi',
         '',
         '# Complete arguments to subcommands.',
         'case "$command" in', [
+            'help) ', [
+            ('COMPREPLY=($(compgen -W "$_stg_commands" --'
+             ' "${COMP_WORDS[COMP_CWORD]}"))'),
+            'return ;;'],
+            'version) return ;;',
+            'copyright) return ;;'], [
             '%s) _stg_%s ;;' % (cmd, cmd)
             for cmd in sorted(commands.iterkeys())],
         'esac')
-- 
1.6.1.87.g15624

```

## ted@tedpavlic.com, 2009-01-20 00:46

Subject: [StGit PATCH 2/2] Make bash completion fail to bashdefault before default completion.
Message-ID: <1232412373-10836-2-git-send-email-ted@tedpavlic.com>
URL: https://gitlist.dev/e/1232412373-10836-2-git-send-email-ted%40tedpavlic.com
In-Reply-To: <1232412373-10836-1-git-send-email-ted@tedpavlic.com>

```
From: Ted Pavlic <ted@tedpavlic.com>

If "-o bashdefault" isn't possible, use old "-o default" only.

(this patch inspired by similar mechanism in Mercurial bash completion
script)

Signed-off-by: Ted Pavlic <ted@tedpavlic.com>
---
 stgit/completion.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/stgit/completion.py b/stgit/completion.py
index b3fd282..56e81c2 100644
--- a/stgit/completion.py
+++ b/stgit/completion.py
@@ -129,7 +129,8 @@ def main_switch(commands):
         'esac')
 
 def install():
-    return ['complete -o default -F _stg stg']
+    return ['complete -o bashdefault -o default -F _stg stg 2>/dev/null \\', [
+            'complete -o default -F _stg stg' ] ]
 
 def write_completion(f):
     commands = stgit.commands.get_commands(allow_cached = False)
-- 
1.6.1.87.g15624

```

## Ted Pavlic, 2009-01-22 16:38

Subject: Re: [StGit PATCH 2/2] Make bash completion fail to bashdefault before default completion.
Message-ID: <4978A0F1.9080703@tedpavlic.com>
URL: https://gitlist.dev/e/4978A0F1.9080703%40tedpavlic.com
In-Reply-To: <1232412373-10836-2-git-send-email-ted@tedpavlic.com>

```
>   def install():
> -    return ['complete -o default -F _stg stg']
> +    return ['complete -o bashdefault -o default -F _stg stg 2>/dev/null \\', [
> +            'complete -o default -F _stg stg' ] ]

Oops -- that second "complete" should have two pipes in front of it...


-- 
Ted Pavlic <ted@tedpavlic.com>

   Please visit my ALS association page:
         http://web.alsa.org/goto/tedpavlic
   My family appreciates your support in the fight to defeat ALS.

```

## Ted Pavlic, 2009-01-22 16:44

Subject: [StGit PATCH 2/2] Make bash completion fail to bashdefault before default completion.
Message-ID: <1232642662-12851-1-git-send-email-ted@tedpavlic.com>
URL: https://gitlist.dev/e/1232642662-12851-1-git-send-email-ted%40tedpavlic.com
In-Reply-To: <4978A0F1.9080703@tedpavlic.com>

```
If "-o bashdefault" isn't possible, use old "-o default" only.

(this patch inspired by similar mechanism in Mercurial bash completion
script)

Signed-off-by: Ted Pavlic <ted@tedpavlic.com>
---

This patch corrects a bug in the previous one of the same name. In
particular, the second "complete" lacked the "||" in front of it needed
for proper operation. The first complete command should fail over to the
second if "bashdefault" isn't available.

 stgit/completion.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/stgit/completion.py b/stgit/completion.py
index b3fd282..38f0670 100644
--- a/stgit/completion.py
+++ b/stgit/completion.py
@@ -129,7 +129,8 @@ def main_switch(commands):
         'esac')
 
 def install():
-    return ['complete -o default -F _stg stg']
+    return ['complete -o bashdefault -o default -F _stg stg 2>/dev/null \\', [
+            '|| complete -o default -F _stg stg' ] ]
 
 def write_completion(f):
     commands = stgit.commands.get_commands(allow_cached = False)
-- 
1.6.1.213.g28da8

```

## Karl Hasselström, 2009-01-22 23:29

Subject: kha/{stable,safe,experimental} updated
Message-ID: <20090122232928.GA23456@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20090122232928.GA23456%40diana.vm.bytemark.co.uk
In-Reply-To: <1232412373-10836-2-git-send-email-ted@tedpavlic.com>

```
Ted, Both of your patches look good, and work when I try them.
(Excellent commit messages, by the way.) I've applied them and pushed
them out.

Catalin, I have stuff for you in both kha/stable and kha/safe.


                                 -+-


The following changes since commit 7cb253c05b509510177a1df4d5813861641968f6:
  Karl Hasselström (1):
        Fix typo

are available in the git repository at:

  git://repo.or.cz/stgit/kha.git stable

Karl Hasselström (1):
      Return None instead of crashing on undefined integer config items

Pete Wyckoff (1):
      stgit.namelength is an integer

 stgit/config.py |    4 +++-
 stgit/utils.py  |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)


                                 -+-


The following changes since commit d3b31eeac6c6fba9352188755164f556faf56e59:
  Catalin Marinas (1):
        Fix the patch argument parsing for the "show" command

are available in the git repository at:

  git://repo.or.cz/stgit/kha.git safe

Gustav Hållberg (7):
      stgit.el: Consistently use symbols rather than strings for patch names
      stgit.el: Make single file diff buffer read-only
      stgit.el: Include stat summary in patch diff
      stgit.el: Add message when there are no patches in the series
      stgit.el: Indicate empty patches
      stgit.el: Minor beautification
      stgit.el: Add optional count argument to stgit-commit

Karl Hasselström (2):
      Return None instead of crashing on undefined integer config items
      Merge branch 'stable'

Pete Wyckoff (1):
      stgit.namelength is an integer

Ted Pavlic (2):
      Modify bash completion to support help, version, and copyright.
      Make bash completion fail to bashdefault before default completion.

 contrib/stgit.el    |  245 ++++++++++++++++++++++++++++-----------------------
 stgit/completion.py |   11 ++-
 stgit/config.py     |    4 +-
 stgit/utils.py      |    2 +-
 4 files changed, 146 insertions(+), 116 deletions(-)


                                 -+-


The following changes since commit e80d43bd9c8baf2bc9913c6c153914403f210872:
  Ted Pavlic (1):
        Make bash completion fail to bashdefault before default completion.

are available in the git repository at:

  git://repo.or.cz/stgit/kha.git experimental

Gustav Hållberg (1):
      stgit.el: (EXPERIMENTAL) Show files modified in work tree

Karl Hasselström (2):
      Read several objects at once with git cat-file --batch
      Diff several trees at once with git diff-tree --stdin

 INSTALL          |    5 +-
 contrib/stgit.el |  272 ++++++++++++++++++++++++++++++++++--------------------
 stgit/lib/git.py |   79 +++++++++++++++-
 stgit/run.py     |   19 ++++
 4 files changed, 266 insertions(+), 109 deletions(-)


-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Ted Pavlic, 2009-01-23 00:26

Subject: [kha/safe PATCH] completion bugfix: Place double pipes in front of alternate command.
Message-ID: <1232670372-20000-1-git-send-email-ted@tedpavlic.com>
URL: https://gitlist.dev/e/1232670372-20000-1-git-send-email-ted%40tedpavlic.com
In-Reply-To: <20090122232928.GA23456@diana.vm.bytemark.co.uk>

```
Signed-off-by: Ted Pavlic <ted@tedpavlic.com>
---

This is a patch against 

    git://repo.or.cz/stgit/kha.git stable

Unfortunately, the previous "[StGit PATCH 2/2]" had a small bug in it. A
bugfix was posted, but it didn't get picked up in kha/safe. This commit
should be applied against kha/safe to fix the problem.

Alternatively, the patch provided in

    <1232642662-12851-1-git-send-email-ted@tedpavlic.com>

is the proper patch to stgit/master.

Sorry for the extra bother.

 stgit/completion.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stgit/completion.py b/stgit/completion.py
index 56e81c2..38f0670 100644
--- a/stgit/completion.py
+++ b/stgit/completion.py
@@ -130,7 +130,7 @@ def main_switch(commands):
 
 def install():
     return ['complete -o bashdefault -o default -F _stg stg 2>/dev/null \\', [
-            'complete -o default -F _stg stg' ] ]
+            '|| complete -o default -F _stg stg' ] ]
 
 def write_completion(f):
     commands = stgit.commands.get_commands(allow_cached = False)
-- 
1.6.1.213.g28da8

```

## Karl Hasselström, 2009-01-23 01:35

Subject: Re: [kha/safe PATCH] completion bugfix: Place double pipes in front of alternate command.
Message-ID: <20090123013504.GA24829@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20090123013504.GA24829%40diana.vm.bytemark.co.uk
In-Reply-To: <1232670372-20000-1-git-send-email-ted@tedpavlic.com>

```
On 2009-01-22 19:26:12 -0500, Ted Pavlic wrote:

> -            'complete -o default -F _stg stg' ] ]
> +            '|| complete -o default -F _stg stg' ] ]

Thanks, I've edited the patch and pushed it out again.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```
