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

[PATCH 1/5] git-completion.bash: separate some commands onto their own line

From
Denton Liu <liu.denton@gmail.com>
Date
Apr 20, 2021, 09:19 UTC
Message-ID
<65c485ea0c1726c96d292d7d7385def8d2f19f25.1618910364.git.liu.denton@gmail.com>
In-Reply-To
<cover.1618910364.git.liu.denton@gmail.com>

In e94fb44042 (git-completion.bash: pass $__git_subcommand_idx from __git_main(), 2021-03-24), a line was introduced which contained multiple statements. This is difficult to read so break it into multiple lines.

While we're at it, follow this convention for the rest of the __git_main() and break up lines that contain multiple statements.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 contrib/completion/git-completion.bash | 37 +++++++++++++++++++-------
 1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c926ca26c6..1dedb14b47 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3400,17 +3400,35 @@ __git_main ()
 	while [ $c -lt $cword ]; do
 		i="${words[c]}"
 		case "$i" in
-		--git-dir=*) __git_dir="${i#--git-dir=}" ;;
-		--git-dir)   ((c++)) ; __git_dir="${words[c]}" ;;
-		--bare)      __git_dir="." ;;
-		--help) command="help"; break ;;
-		-c|--work-tree|--namespace) ((c++)) ;;
-		-C)	__git_C_args[C_args_count++]=-C
+		--git-dir=*)
+			__git_dir="${i#--git-dir=}"
+			;;
+		--git-dir)
+			((c++))
+			__git_dir="${words[c]}"
+			;;
+		--bare)
+			__git_dir="."
+			;;
+		--help)
+			command="help"
+			break
+			;;
+		-c|--work-tree|--namespace)
+			((c++))
+			;;
+		-C)
+			__git_C_args[C_args_count++]=-C
 			((c++))
 			__git_C_args[C_args_count++]="${words[c]}"
 			;;
-		-*) ;;
-		*) command="$i"; __git_subcommand_idx="$c"; break ;;
+		-*)
+			;;
+		*)
+			command="$i"
+			__git_subcommand_idx="$c"
+			break
+			;;
 		esac
 		((c++))
 	done
@@ -3432,7 +3450,8 @@ __git_main ()
 			;;
 		esac
 		case "$cur" in
-		--*)   __gitcomp "
+		--*)
+			__gitcomp "
 			--paginate
 			--no-pager
 			--git-dir=
-- 
2.31.1.424.g95a8dafae5
Previous: Denton LiuNext: Denton Liu
Message 2 of 18 in “git-completion.bash: fixes on top of 'dl/complete-stash'”
  1. 0/5 git-completion.bash: fixes on top of 'dl/complete-stash'Denton Liu, Apr 20, 2021
  2. 1/5 git-completion.bash: separate some commands onto their own lineDenton Liu, Apr 20, 2021
  3. 2/5 git-completion.bash: rename to $__git_cmd_idxDenton Liu, Apr 20, 2021
  4. Junio C HamanoApr 20, 2021
  5. SZEDER GáborApr 20, 2021
  6. Junio C HamanoApr 20, 2021
  7. 3/5 git-completion.bash: use $__git_cmd_idx in more placesDenton Liu, Apr 20, 2021
  8. 4/5 git-completion.bash: consolidate cases in _git_stash()Denton Liu, Apr 20, 2021
  9. Ævar Arnfjörð BjarmasonApr 20, 2021
  10. Denton LiuApr 21, 2021
  11. 5/5 git-completion.bash: consolidate no-subcommand case for _git_stash()Denton Liu, Apr 20, 2021
  12. Junio C HamanoApr 20, 2021
  13. Denton LiuApr 21, 2021
  14. 0/4 git-completion.bash: fixes on top of 'dl/complete-stash'Denton Liu, Apr 22, 2021
  15. 1/4 git-completion.bash: separate some commands onto their own lineDenton Liu, Apr 22, 2021
  16. 2/4 git-completion.bash: rename to $__git_cmd_idxDenton Liu, Apr 22, 2021
  17. 4/4 git-completion.bash: consolidate cases in _git_stash()Denton Liu, Apr 22, 2021
  18. 3/4 git-completion.bash: use $__git_cmd_idx in more placesDenton Liu, Apr 22, 2021

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.