From 0a82f945a179e687d2837db1cab3c18784b27e29 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 23 Aug 2015 00:15:34 +0300 Subject: [PATCH] Explain sticky options (git grep -O) --- pep-git.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pep-git.txt b/pep-git.txt index 08880df..5a4ec80 100644 --- a/pep-git.txt +++ b/pep-git.txt @@ -751,7 +751,20 @@ works: ``git commit -av`` works perfectly, but there are situations when it doesn't. E.g., ``git log -p -5`` cannot be combined as ``git log -p5``. -TODO: sticky options; example: git grep -O. +Some options have arguments, some even have default arguments. In that +case the argument for such option must be spelled in sticky way: +``-Oarg``, never ``-O arg`` because for an option that has a default +argument the latter means "use default value for option ``-O`` and +pass ``arg`` further to the option parser". For example, ``git grep`` +has an option ``-O`` that passes found files to a program; default +program for ``-O`` is pager (ususally ``less``), but you can use your +editor:: + + $ git grep -Ovim # but not -O vim + +BTW, there is a difference between running ``git grep -O`` and ``git +grep -Oless`` - in the latter case ``git grep`` passes ``+/pattern`` +option to less. TODO: bash/zsh completion, bash/zsh prompt. https://git.kernel.org/cgit/git/git.git/tree/contrib/completion -- 2.39.5