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

[PATCH v2 1/2] bash completion: refactor common log, shortlog and gitk options

From
Thomas Rast <trast@student.ethz.ch>
Date
Feb 16, 2009, 16:34 UTC
Message-ID
<c1564dd75592c6e4c3ce97c6187eedbe03d03bc7.1234801852.git.trast@student.ethz.ch>
In-Reply-To
<adf1fd3d0902150156w67a16e6fp3c946446c5ae2bfd@mail.gmail.com>

Refactor options that are useful for more than one of them into a variable used by the relevant completions. This has the effect of adding the following options to git-log:

  --branches --tags --remotes --first-parent --dense --sparse
  --simplify-merges --simplify-by-decoration --first-parent
  --no-merges
The following to git-shortlog:
  --branches --tags --remotes --first-parent
And the following to gitk:
  --branches --tags --remotes --first-parent --no-merges --max-count=
  --max-age= --since= --after= --min-age= --until= --before= --dense
  --sparse --full-history --simplify-merges --simplify-by-decoration
  --left-right
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---
 contrib/completion/git-completion.bash |   49 ++++++++++++++++++++++----------
 1 files changed, 34 insertions(+), 15 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 412d2c0..a5b3bf3 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -975,6 +975,27 @@ _git_ls_tree ()
 	__git_complete_file
 }
 
+# Options that go well for log, shortlog and gitk
+__git_log_common_options="
+	--not --all
+	--branches --tags --remotes
+	--first-parent --no-merges
+	--max-count=
+	--max-age= --since= --after=
+	--min-age= --until= --before=
+"
+# Options that go well for log and gitk (not shortlog)
+__git_log_gitk_options="
+	--dense --sparse --full-history
+	--simplify-merges --simplify-by-decoration
+	--left-right
+"
+# Options that go well for log and shortlog (not gitk)
+__git_log_shortlog_options="
+	--author= --committer= --grep=
+	--all-match
+"
+
 __git_log_pretty_formats="oneline short medium full fuller email raw format:"
 
 _git_log ()
@@ -996,21 +1017,19 @@ _git_log ()
 		;;
 	--*)
 		__gitcomp "
-			--max-count= --max-age= --since= --after=
-			--min-age= --before= --until=
+			$__git_log_common_options
+			$__git_log_shortlog_options
+			$__git_log_gitk_options
 			--root --topo-order --date-order --reverse
-			--no-merges --follow
+			--follow
 			--abbrev-commit --abbrev=
 			--relative-date --date=
-			--author= --committer= --grep=
-			--all-match
 			--pretty=
-			--not --all
-			--left-right --cherry-pick
+			--cherry-pick
 			--graph
 			--decorate
 			--walk-reflogs
-			--parents --children --full-history
+			--parents --children
 			--merge
 			$__git_diff_common_options
 			--pickaxe-all --pickaxe-regex
@@ -1495,12 +1514,8 @@ _git_shortlog ()
 	case "$cur" in
 	--*)
 		__gitcomp "
-			--max-count= --max-age= --since= --after=
-			--min-age= --before= --until=
-			--no-merges
-			--author= --committer= --grep=
-			--all-match
-			--not --all
+			$__git_log_common_options
+			$__git_log_shortlog_options
 			--numbered --summary
 			"
 		return
@@ -1808,7 +1823,11 @@ _gitk ()
 	fi
 	case "$cur" in
 	--*)
-		__gitcomp "--not --all $merge"
+		__gitcomp "
+			$__git_log_common_options
+			$__git_log_gitk_options
+			$merge
+			"
 		return
 		;;
 	esac
-- 
1.6.2.rc0.328.g2c702
Previous: Thomas RastNext: Thomas Rast
Message 23 of 26 in “bash completion: offer more options for gitk”
  1. bash completion: offer more options for gitkThomas Rast, Feb 14, 2009
  2. Junio C HamanoFeb 15, 2009
  3. Santi BéjarFeb 15, 2009
  4. 0/2 bash completion: more options for gitk/log/shortlogThomas Rast, Feb 16, 2009
  5. Thomas RastFeb 16, 2009
  6. format-patch: thread as reply to cover letter even with in-reply-toThomas Rast, Feb 16, 2009
  7. Jay SoffianFeb 16, 2009
  8. Thomas RastFeb 16, 2009
  9. Jakub NarebskiFeb 16, 2009
  10. Thomas RastFeb 16, 2009
  11. 0/4 format-patch --cover-letter --in-reply-toThomas Rast, Feb 19, 2009
  12. 1/4 format-patch: threading test reactivationThomas Rast, Feb 19, 2009
  13. 2/4 format-patch: track several referencesThomas Rast, Feb 19, 2009
  14. Daniel BarkalowFeb 19, 2009
  15. 0/4 format-patch --cover-letter --in-reply-toThomas Rast, Feb 20, 2009
  16. 1/4 format-patch: threading test reactivationThomas Rast, Feb 20, 2009
  17. 2/4 format-patch: track several referencesThomas Rast, Feb 20, 2009
  18. 3/4 format-patch: thread as reply to cover letter even with in-reply-toThomas Rast, Feb 20, 2009
  19. 4/4 format-patch: support deep threadingThomas Rast, Feb 20, 2009
  20. Junio C HamanoFeb 22, 2009
  21. 3/4 format-patch: thread as reply to cover letter even with in-reply-toThomas Rast, Feb 19, 2009
  22. 4/4 format-patch: support deep threadingThomas Rast, Feb 19, 2009
  23. 1/2 bash completion: refactor common log, shortlog and gitk optionsThomas Rast, Feb 16, 2009
  24. 2/2 bash completion: only show 'log --merge' if mergingThomas Rast, Feb 16, 2009
  25. Shawn O. PearceFeb 18, 2009
  26. Junio C HamanoFeb 18, 2009

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.