* [PATCH v2 0/2] completion: sequencer commands
2015-05-29 23:13 ` Ramkumar Ramachandra
@ 2015-05-30 15:57 ` Thomas Braun
2015-05-30 16:01 ` [PATCH v2 2/2] completion: suggest sequencer commands for revert Thomas Braun
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Thomas Braun @ 2015-05-30 15:57 UTC (permalink / raw)
To: git; +Cc: Ramkumar Ramachandra, Junio C Hamano, John Keeping,
SZEDER Gábor
Ramkumar Ramachandra wrote:
> Junio C Hamano wrote:
> >
> > > contrib/completion/git-completion.bash | 5 +++++
> > > 1 file changed, 5 insertions(+)
> > >
> > > diff --git a/contrib/completion/git-completion.bash
> b/contrib/completion/git-completion.bash
> > > index bfc74e9..3c00acd 100644
> > > --- a/contrib/completion/git-completion.bash
> > > +++ b/contrib/completion/git-completion.bash
> > > @@ -2282,6 +2282,11 @@ _git_reset ()
> > >
> > > _git_revert ()
> > > {
> > > + local dir="$(__gitdir)"
> > > + if [ -f "$dir"/REVERT_HEAD ]; then
> > > + __gitcomp "--continue --quit --abort"
> > > + return
> > > + fi
> > > case "$cur" in
> > > --*)
> > > __gitcomp "--edit --mainline --no-edit --no-commit
> --signoff"
>
> This corresponds exactly to what we do for git-cherry-pick:
>
> local dir="$(__gitdir)"
> if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
> __gitcomp "--continue --quit --abort"
> return
> fi
>
> Perhaps _git_revert() and _git_cherry_pick() should call into the same
> function with different arguments.
Good idea.
I created a new function __git_complete_sequencer which is now used to complete
all commands with active sequencer.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 2/2] completion: suggest sequencer commands for revert
2015-05-29 23:13 ` Ramkumar Ramachandra
2015-05-30 15:57 ` [PATCH v2 0/2] completion: sequencer commands Thomas Braun
@ 2015-05-30 16:01 ` Thomas Braun
2015-05-30 16:01 ` [PATCH v2 1/2] completion: Add sequencer function Thomas Braun
2015-05-30 16:02 ` Thomas Braun
3 siblings, 0 replies; 10+ messages in thread
From: Thomas Braun @ 2015-05-30 16:01 UTC (permalink / raw)
To: git; +Cc: Ramkumar Ramachandra, Junio C Hamano, John Keeping,
SZEDER Gábor
Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
---
contrib/completion/git-completion.bash | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index f6e5bf6..486c61b 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -868,6 +868,12 @@ __git_complete_sequencer ()
return 0
fi
;;
+ revert)
+ if [ -f "$dir"/REVERT_HEAD ]; then
+ __gitcomp "--continue --quit --abort"
+ return 0
+ fi
+ ;;
rebase)
if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
__gitcomp "--continue --skip --abort"
@@ -2300,6 +2306,8 @@ _git_reset ()
_git_revert ()
{
+ __git_complete_sequencer "revert" && return
+
case "$cur" in
--*)
__gitcomp "--edit --mainline --no-edit --no-commit --signoff"
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] completion: Add sequencer function
2015-05-29 23:13 ` Ramkumar Ramachandra
2015-05-30 15:57 ` [PATCH v2 0/2] completion: sequencer commands Thomas Braun
2015-05-30 16:01 ` [PATCH v2 2/2] completion: suggest sequencer commands for revert Thomas Braun
@ 2015-05-30 16:01 ` Thomas Braun
2015-05-30 19:01 ` SZEDER Gábor
2015-05-30 16:02 ` Thomas Braun
3 siblings, 1 reply; 10+ messages in thread
From: Thomas Braun @ 2015-05-30 16:01 UTC (permalink / raw)
To: git; +Cc: Ramkumar Ramachandra, Junio C Hamano, John Keeping,
SZEDER Gábor
Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
---
contrib/completion/git-completion.bash | 48 +++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 15 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index bfc74e9..f6e5bf6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -851,15 +851,40 @@ __git_count_arguments ()
printf "%d" $c
}
+__git_complete_sequencer ()
+{
+ local dir="$(__gitdir)"
+
+ case "$1" in
+ am)
+ if [ -d "$dir"/rebase-apply ]; then
+ __gitcomp "--skip --continue --resolved --abort"
+ return 0
+ fi
+ ;;
+ cherry-pick)
+ if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
+ __gitcomp "--continue --quit --abort"
+ return 0
+ fi
+ ;;
+ rebase)
+ if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
+ __gitcomp "--continue --skip --abort"
+ return 0
+ fi
+ ;;
+ esac
+
+ return 1
+}
+
__git_whitespacelist="nowarn warn error error-all fix"
_git_am ()
{
- local dir="$(__gitdir)"
- if [ -d "$dir"/rebase-apply ]; then
- __gitcomp "--skip --continue --resolved --abort"
- return
- fi
+ __git_complete_sequencer "am" && return
+
case "$cur" in
--whitespace=*)
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
@@ -1044,11 +1069,8 @@ _git_cherry ()
_git_cherry_pick ()
{
- local dir="$(__gitdir)"
- if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
- __gitcomp "--continue --quit --abort"
- return
- fi
+ __git_complete_sequencer "cherry-pick" && return
+
case "$cur" in
--*)
__gitcomp "--edit --no-commit --signoff --strategy= --mainline"
@@ -1666,11 +1688,7 @@ _git_push ()
_git_rebase ()
{
- local dir="$(__gitdir)"
- if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort"
- return
- fi
+ __git_complete_sequencer "rebase" && return
__git_complete_strategy && return
case "$cur" in
--whitespace=*)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] completion: Add sequencer function
2015-05-30 16:01 ` [PATCH v2 1/2] completion: Add sequencer function Thomas Braun
@ 2015-05-30 19:01 ` SZEDER Gábor
2015-06-01 14:38 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: SZEDER Gábor @ 2015-05-30 19:01 UTC (permalink / raw)
To: Thomas Braun; +Cc: git, Ramkumar Ramachandra, Junio C Hamano, John Keeping
Quoting Thomas Braun <thomas.braun@virtuell-zuhause.de>:
> Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
> ---
> contrib/completion/git-completion.bash | 48
> +++++++++++++++++++++++-----------
> 1 file changed, 33 insertions(+), 15 deletions(-)
I don't see the benefits of this change. This patch adds more than
twice as many lines as it removes, and patch 2/2 adds 8 new lines
although it could get away with only 5 without this function. To
offer sequencer options we currently go through a single if statement,
with this patch we'd go through a case statement, an if statement and
finally an &&.
Gábor
> diff --git a/contrib/completion/git-completion.bash
> b/contrib/completion/git-completion.bash
> index bfc74e9..f6e5bf6 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -851,15 +851,40 @@ __git_count_arguments ()
> printf "%d" $c
> }
>
> +__git_complete_sequencer ()
> +{
> + local dir="$(__gitdir)"
> +
> + case "$1" in
> + am)
> + if [ -d "$dir"/rebase-apply ]; then
> + __gitcomp "--skip --continue --resolved --abort"
> + return 0
> + fi
> + ;;
> + cherry-pick)
> + if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
> + __gitcomp "--continue --quit --abort"
> + return 0
> + fi
> + ;;
> + rebase)
> + if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
> + __gitcomp "--continue --skip --abort"
> + return 0
> + fi
> + ;;
> + esac
> +
> + return 1
> +}
> +
> __git_whitespacelist="nowarn warn error error-all fix"
>
> _git_am ()
> {
> - local dir="$(__gitdir)"
> - if [ -d "$dir"/rebase-apply ]; then
> - __gitcomp "--skip --continue --resolved --abort"
> - return
> - fi
> + __git_complete_sequencer "am" && return
> +
> case "$cur" in
> --whitespace=*)
> __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
> @@ -1044,11 +1069,8 @@ _git_cherry ()
>
> _git_cherry_pick ()
> {
> - local dir="$(__gitdir)"
> - if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
> - __gitcomp "--continue --quit --abort"
> - return
> - fi
> + __git_complete_sequencer "cherry-pick" && return
> +
> case "$cur" in
> --*)
> __gitcomp "--edit --no-commit --signoff --strategy= --mainline"
> @@ -1666,11 +1688,7 @@ _git_push ()
>
> _git_rebase ()
> {
> - local dir="$(__gitdir)"
> - if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
> - __gitcomp "--continue --skip --abort"
> - return
> - fi
> + __git_complete_sequencer "rebase" && return
> __git_complete_strategy && return
> case "$cur" in
> --whitespace=*)
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] completion: Add sequencer function
2015-05-30 19:01 ` SZEDER Gábor
@ 2015-06-01 14:38 ` Junio C Hamano
2015-06-01 15:06 ` SZEDER Gábor
0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2015-06-01 14:38 UTC (permalink / raw)
To: SZEDER Gábor; +Cc: Thomas Braun, git, Ramkumar Ramachandra, John Keeping
SZEDER Gábor <szeder@ira.uka.de> writes:
> I don't see the benefits of this change. This patch adds more than
> twice as many lines as it removes, and patch 2/2 adds 8 new lines
> although it could get away with only 5 without this function. To
> offer sequencer options we currently go through a single if statement,
> with this patch we'd go through a case statement, an if statement and
> finally an &&.
>
> Gábor
Perhaps, especially given that I'd imagine we won't be adding 47 new
commands that drive the sequencer in the near future ;-)
I presume that you are OK with Thomas's original version, then?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 1/2] completion: Add sequencer function
2015-06-01 14:38 ` Junio C Hamano
@ 2015-06-01 15:06 ` SZEDER Gábor
0 siblings, 0 replies; 10+ messages in thread
From: SZEDER Gábor @ 2015-06-01 15:06 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Thomas Braun, git, Ramkumar Ramachandra, John Keeping
Quoting Junio C Hamano <gitster@pobox.com>:
> SZEDER Gábor <szeder@ira.uka.de> writes:
>
>> I don't see the benefits of this change. This patch adds more than
>> twice as many lines as it removes, and patch 2/2 adds 8 new lines
>> although it could get away with only 5 without this function. To
>> offer sequencer options we currently go through a single if statement,
>> with this patch we'd go through a case statement, an if statement and
>> finally an &&.
>>
>> Gábor
>
> Perhaps, especially given that I'd imagine we won't be adding 47 new
> commands that drive the sequencer in the near future ;-)
>
> I presume that you are OK with Thomas's original version, then?
Yes, definitely.
It's a shame all these sequencing commands have different sets of
sequencer options. Perhaps something to clean up for, say, v3.0 :)
Gábor
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/2] completion: Add sequencer function
2015-05-29 23:13 ` Ramkumar Ramachandra
` (2 preceding siblings ...)
2015-05-30 16:01 ` [PATCH v2 1/2] completion: Add sequencer function Thomas Braun
@ 2015-05-30 16:02 ` Thomas Braun
3 siblings, 0 replies; 10+ messages in thread
From: Thomas Braun @ 2015-05-30 16:02 UTC (permalink / raw)
To: git; +Cc: Ramkumar Ramachandra, Junio C Hamano, John Keeping,
SZEDER Gábor
Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de>
---
contrib/completion/git-completion.bash | 48 +++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 15 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index bfc74e9..f6e5bf6 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -851,15 +851,40 @@ __git_count_arguments ()
printf "%d" $c
}
+__git_complete_sequencer ()
+{
+ local dir="$(__gitdir)"
+
+ case "$1" in
+ am)
+ if [ -d "$dir"/rebase-apply ]; then
+ __gitcomp "--skip --continue --resolved --abort"
+ return 0
+ fi
+ ;;
+ cherry-pick)
+ if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
+ __gitcomp "--continue --quit --abort"
+ return 0
+ fi
+ ;;
+ rebase)
+ if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
+ __gitcomp "--continue --skip --abort"
+ return 0
+ fi
+ ;;
+ esac
+
+ return 1
+}
+
__git_whitespacelist="nowarn warn error error-all fix"
_git_am ()
{
- local dir="$(__gitdir)"
- if [ -d "$dir"/rebase-apply ]; then
- __gitcomp "--skip --continue --resolved --abort"
- return
- fi
+ __git_complete_sequencer "am" && return
+
case "$cur" in
--whitespace=*)
__gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
@@ -1044,11 +1069,8 @@ _git_cherry ()
_git_cherry_pick ()
{
- local dir="$(__gitdir)"
- if [ -f "$dir"/CHERRY_PICK_HEAD ]; then
- __gitcomp "--continue --quit --abort"
- return
- fi
+ __git_complete_sequencer "cherry-pick" && return
+
case "$cur" in
--*)
__gitcomp "--edit --no-commit --signoff --strategy= --mainline"
@@ -1666,11 +1688,7 @@ _git_push ()
_git_rebase ()
{
- local dir="$(__gitdir)"
- if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
- __gitcomp "--continue --skip --abort"
- return
- fi
+ __git_complete_sequencer "rebase" && return
__git_complete_strategy && return
case "$cur" in
--whitespace=*)
^ permalink raw reply related [flat|nested] 10+ messages in thread