threads / discuss / 41248

PATCH 1/2] Update the flags for git show-branch

Subject: PATCH 1/2] Update the flags for git show-branch

## tl;dr

10 messages between Jan 23, 2016 and Feb 22, 2016.

replies: 9people: 3as markdown or json

Paul Wagland· Jan 23, 2016, 01:23 UTC · lore

[PATCH 0/2] Update BASH completions

While playing around git stash I noticed that some options were missing. I have updated these in the BASH completions file. Note that this is not a comprehensive review, but adds the options that I use in git-stash, and a nearby missing option.

Paul Wagland (2):
  Update the flags for git show-branch
  Fix up the arguments for git stash. This adds the branch to the branch
    subcommand, and adds the missing options to save and drop commands
 contrib/completion/git-completion.bash | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

-- 2.7.0

Paul Wagland· Jan 23, 2016, 01:25 UTC · re: Paul Wagland · lore
Signed-off-by: Paul Wagland <paul@kungfoocoder.org>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ab4da7f..63754bc 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2369,7 +2369,7 @@ _git_show_branch ()
 	case "$cur" in
 	--*)
 		__gitcomp "
-			--all --remotes --topo-order --current --more=
+			--all --remotes --topo-order --date-order --current --more=
 			--list --independent --merge-base --no-name
 			--color --no-color
 			--sha1-name --sparse --topics --reflog
--
2.7.0
Paul Wagland· Jan 23, 2016, 01:30 UTC · re: Paul Wagland · lore

[PATCH 2/2] Fix up the arguments for git stash.

Signed-off-by: Paul Wagland <paul@kungfoocoder.org>
---
 contrib/completion/git-completion.bash | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 63754bc..043d5bb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2382,7 +2382,7 @@ _git_show_branch ()
 
 _git_stash ()
 {
-	local save_opts='--keep-index --no-keep-index --quiet --patch'
+	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
 	local subcommands='save list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
@@ -2404,9 +2404,20 @@ _git_stash ()
 		apply,--*|pop,--*)
 			__gitcomp "--index --quiet"
 			;;
-		show,--*|drop,--*|branch,--*)
+		drop,--*)
+			__gitcomp "--quiet"
 			;;
-		show,*|apply,*|drop,*|pop,*|branch,*)
+		show,--*|branch,--*)
+			;;
+		branch,*)
+			if [ $cword -eq 3 ]; then
+			__gitcomp_nl "$(__git_refs)";
+			else
+				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+						| sed -n -e 's/:.*//p')"
+			fi
+			;;
+		show,*|apply,*|drop,*|pop,*)
 			__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 					| sed -n -e 's/:.*//p')"
 			;;
-- 
2.7.0
Junio C Hamano· Jan 25, 2016, 23:21 UTC · re: Paul Wagland · lore

Re: [PATCH 2/2] Fix up the arguments for git stash.

Paul Wagland <paul@kungfoocoder.org> writes:
> Signed-off-by: Paul Wagland <paul@kungfoocoder.org>
> ---

This needs a better explanation than just "Fix up" in the title. What is broken in the current behaviour and what is the more desired behaviour?

Thanks.
Show 39 quoted lines
>  contrib/completion/git-completion.bash | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 63754bc..043d5bb 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2382,7 +2382,7 @@ _git_show_branch ()
>  
>  _git_stash ()
>  {
> -	local save_opts='--keep-index --no-keep-index --quiet --patch'
> +	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
>  	local subcommands='save list show apply clear drop pop create branch'
>  	local subcommand="$(__git_find_on_cmdline "$subcommands")"
>  	if [ -z "$subcommand" ]; then
> @@ -2404,9 +2404,20 @@ _git_stash ()
>  		apply,--*|pop,--*)
>  			__gitcomp "--index --quiet"
>  			;;
> -		show,--*|drop,--*|branch,--*)
> +		drop,--*)
> +			__gitcomp "--quiet"
>  			;;
> -		show,*|apply,*|drop,*|pop,*|branch,*)
> +		show,--*|branch,--*)
> +			;;
> +		branch,*)
> +			if [ $cword -eq 3 ]; then
> +			__gitcomp_nl "$(__git_refs)";
> +			else
> +				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
> +						| sed -n -e 's/:.*//p')"
> +			fi
> +			;;
> +		show,*|apply,*|drop,*|pop,*)
>  			__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
>  					| sed -n -e 's/:.*//p')"
>  			;;
Paul Wagland· Jan 26, 2016, 06:21 UTC · re: Junio C Hamano · lore

Re: [PATCH 2/2] Fix up the arguments for git stash.

Fair enough. I'll re-roll the patches with improved comments, and get these out to the list today. 

Cheers, Paul

Sent from my iPhone
Show 12 quoted lines
> On 26 Jan 2016, at 00:21, Junio C Hamano <gitster@pobox.com> wrote:
> 
> Paul Wagland <paul@kungfoocoder.org> writes:
> 
>> Signed-off-by: Paul Wagland <paul@kungfoocoder.org>
>> ---
> 
> This needs a better explanation than just "Fix up" in the title.
> What is broken in the current behaviour and what is the more desired
> behaviour?
> 
> Thanks.
Paul Wagland· Jan 26, 2016, 09:34 UTC · re: Paul Wagland · lore

[PATCH v2 0/2] Update BASH completions

While playing around git stash I noticed that some options were missing. I have updated these in the BASH completions file. Note that this is not a comprehensive review, but adds the options that I use in git-stash, and a nearby missing option.

This re-roll doesn't change the code, but updates the commit comments to make it clearer what each change is doing.

Paul Wagland (2):
  Update the flags for git show-branch
  Fix up the arguments for git stash. This adds the branch to the branch
    subcommand, and adds the missing options to save and drop commands
 contrib/completion/git-completion.bash | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

-- 2.7.0

Paul Wagland· Jan 26, 2016, 09:36 UTC · re: Paul Wagland · lore

[PATCH v2 1/2] completion: complete show-branch "--date-order"

Signed-off-by: Paul Wagland <paul@kungfoocoder.org>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index ab4da7f..63754bc 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2369,7 +2369,7 @@ _git_show_branch ()
 	case "$cur" in
 	--*)
 		__gitcomp "
-			--all --remotes --topo-order --current --more=
+			--all --remotes --topo-order --date-order --current --more=
 			--list --independent --merge-base --no-name
 			--color --no-color
 			--sha1-name --sparse --topics --reflog
-- 
2.7.0
Paul Wagland· Jan 26, 2016, 09:37 UTC · re: Paul Wagland · lore

[PATCH v2 2/4] completion: update completion arguments for stash

Add --all and --include-untracked to the git stash save completions. Add --quiet to the git stash drop completions. Update git stash branch so that the first argument expands out to the possible branch names, and the other arguments expand to the stash names.

Signed-off-by: Paul Wagland <paul@kungfoocoder.org>
---
 contrib/completion/git-completion.bash | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 63754bc..043d5bb 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2382,7 +2382,7 @@ _git_show_branch ()
 
 _git_stash ()
 {
-	local save_opts='--keep-index --no-keep-index --quiet --patch'
+	local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
 	local subcommands='save list show apply clear drop pop create branch'
 	local subcommand="$(__git_find_on_cmdline "$subcommands")"
 	if [ -z "$subcommand" ]; then
@@ -2404,9 +2404,20 @@ _git_stash ()
 		apply,--*|pop,--*)
 			__gitcomp "--index --quiet"
 			;;
-		show,--*|drop,--*|branch,--*)
+		drop,--*)
+			__gitcomp "--quiet"
 			;;
-		show,*|apply,*|drop,*|pop,*|branch,*)
+		show,--*|branch,--*)
+			;;
+		branch,*)
+		  if [ $cword -eq 3 ]; then
+  			__gitcomp_nl "$(__git_refs)";
+			else
+				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
+						| sed -n -e 's/:.*//p')"
+			fi
+			;;
+		show,*|apply,*|drop,*|pop,*)
 			__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 					| sed -n -e 's/:.*//p')"
 			;;
-- 
2.7.0
SZEDER Gábor· Feb 22, 2016, 13:02 UTC · re: Paul Wagland · lore

[PATCH] completion: fix mis-indentation in _git_stash()

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
---
 contrib/completion/git-completion.bash | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 45ec47f2b1b4..e3918c87e3ad 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2415,8 +2415,8 @@ _git_stash ()
 		show,--*|branch,--*)
 			;;
 		branch,*)
-		  if [ $cword -eq 3 ]; then
-			__gitcomp_nl "$(__git_refs)";
+			if [ $cword -eq 3 ]; then
+				__gitcomp_nl "$(__git_refs)";
 			else
 				__gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 						| sed -n -e 's/:.*//p')"
-- 
2.7.1.384.g61d9461

← back to recent threads