From 2f4af9f6ff44fbdb1d4f271f8c7818782c88f6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 05:32:03 +0200 Subject: [PATCH 01/23] tab completion for branch and log parameters implemented --- GitTabExpansion.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index 224c94da8..91f83b141 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -5,6 +5,11 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ AllCommands = $false } +$params = @{ + branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' + log = 'follow no-decorate decorate source use-mailmap full-diff log-size L max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' +} + $subcommands = @{ bisect = 'start bad good skip reset visualize replay log run' notes = 'edit show' @@ -153,6 +158,13 @@ function script:expandGitAlias($cmd, $rest) { } } +function script:expandParams($cmd, $filter) { + $params[$cmd] -split ' ' | + where { $_ -like "$filter*" } | + sort | + foreach { -join ("--", $_) } +} + function GitTabExpansion($lastBlock) { if($lastBlock -match "^$(Get-AliasPattern git) (?\S+)(? .*)$") { @@ -277,6 +289,11 @@ function GitTabExpansion($lastBlock) { "^(?:checkout|cherry|cherry-pick|diff|difftool|log|merge|rebase|reflog\s+show|reset|revert|show).* (?\S*)$" { gitBranches $matches['ref'] $true } + + # Handles git -- + "^(?(?:branch|log)).* --(?\S*)$" { + expandParams $matches['cmd'] $matches['parameters'] + } } } From 1ad85e294738fee2ca7d39b173dd22503a8a2e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 06:51:10 +0200 Subject: [PATCH 02/23] tab completion for add and status parameters implemented --- GitTabExpansion.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index 91f83b141..f5feb817f 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -6,8 +6,10 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ } $params = @{ + add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' log = 'follow no-decorate decorate source use-mailmap full-diff log-size L max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' + status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' } $subcommands = @{ @@ -291,7 +293,7 @@ function GitTabExpansion($lastBlock) { } # Handles git -- - "^(?(?:branch|log)).* --(?\S*)$" { + "^(?(?:add|branch|log|status)).* --(?\S*)$" { expandParams $matches['cmd'] $matches['parameters'] } } From 021afc4d28110aa9d8495c3021d0375570c567d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 07:16:32 +0200 Subject: [PATCH 03/23] tab completion for diff and merge parameters implemented --- GitTabExpansion.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index f5feb817f..097383021 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -8,8 +8,11 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ $params = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' + diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' log = 'follow no-decorate decorate source use-mailmap full-diff log-size L max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' + merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' + rm = 'force dry-run cached ignore-unmatch quiet' } $subcommands = @{ @@ -293,7 +296,7 @@ function GitTabExpansion($lastBlock) { } # Handles git -- - "^(?(?:add|branch|log|status)).* --(?\S*)$" { + "^(?(?:add|branch|diff|log|merge|rm|status)).* --(?\S*)$" { expandParams $matches['cmd'] $matches['parameters'] } } From 53ddd272a5aae331c808310582c3985405962a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 10:16:43 +0200 Subject: [PATCH 04/23] parameter values completion added for add, branch, diff, log, merge, status, rm --- GitTabExpansion.ps1 | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index 097383021..99bfb775c 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -9,12 +9,39 @@ $params = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' - log = 'follow no-decorate decorate source use-mailmap full-diff log-size L max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' + log = 'follow no-decorate decorate source use-mailmap full-diff log-size L max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk= do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' rm = 'force dry-run cached ignore-unmatch quiet' } +$paramvalues = @{ + branch = @{ + color = 'always never auto' + abbrev = '7 8 9 10' } + diff = @{ + unified = '0 1 2 3 4 5' + 'diff-algorithm' = 'default patience minimal histogram myers' + color = 'always never auto' + 'word-diff' = 'color plain porcelain none' + abbrev = '7 8 9 10' + 'diff-filter' = 'A C D M R T U X B *' + 'inter-hunk-context' = '0 1 2 3 4 5' + 'ignore-submodules' = 'none untracked dirty all' } + log = @{ + decorate = 'short full no' + 'no-walk' = 'sorted unsorted' + pretty = 'oneline short medium full fuller email raw' + format = 'oneline short medium full fuller email raw' + encoding = 'UTF-8' + date = 'relative local default iso rfc short raw' } + merge = @{ + log = '1 2 3 4 5 6 7 8 9' } + status = @{ + 'untracked-files' = 'no normal all' + 'ignore-submodules' = 'none untracked dirty all' } +} + $subcommands = @{ bisect = 'start bad good skip reset visualize replay log run' notes = 'edit show' @@ -170,6 +197,13 @@ function script:expandParams($cmd, $filter) { foreach { -join ("--", $_) } } +function script:expandParamValues($cmd, $param, $filter) { + $paramvalues[$cmd][$param] -split ' ' | + where { $_ -like "$filter*" } | + sort | + foreach { -join ("--", $param, "=", $_) } +} + function GitTabExpansion($lastBlock) { if($lastBlock -match "^$(Get-AliasPattern git) (?\S+)(? .*)$") { @@ -295,9 +329,14 @@ function GitTabExpansion($lastBlock) { gitBranches $matches['ref'] $true } + # Handles git --= + "^(?(?:add|branch|diff|log|merge|rm|status)).* --(?[^=]+)=(?\S*)$" { + expandParamValues $matches['cmd'] $matches['param'] $matches['value'] + } + # Handles git -- - "^(?(?:add|branch|diff|log|merge|rm|status)).* --(?\S*)$" { - expandParams $matches['cmd'] $matches['parameters'] + "^(?(?:add|branch|diff|log|merge|rm|status)).* --(?\S*)$" { + expandParams $matches['cmd'] $matches['param'] } } } From 3c97e147d157aa2832071c68d50e67da1e31d6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 11:21:12 +0200 Subject: [PATCH 05/23] added support for short parameters for add, branch, diff, log, merge, status, rm --- GitTabExpansion.ps1 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index 99bfb775c..335bbbec9 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -5,11 +5,21 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ AllCommands = $false } +$shortparams = @{ + add = 'n v f i p e u A N' + branch = 'd D l f m M r a v vv q t u' + diff = 'p u s U z B M C D l S G O R a b w W' + log = 'L n i E F g c c m r t' + merge = 'e n s X q v S m' + status = 's b u z' + rm = 'f n r q' +} + $params = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' - log = 'follow no-decorate decorate source use-mailmap full-diff log-size L max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk= do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' + log = 'follow no-decorate decorate source use-mailmap full-diff log-size max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk= do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' rm = 'force dry-run cached ignore-unmatch quiet' @@ -197,6 +207,13 @@ function script:expandParams($cmd, $filter) { foreach { -join ("--", $_) } } +function script:expandShortParams($cmd, $filter) { + $shortparams[$cmd] -split ' ' | + where { $_ -like "$filter*" } | + sort | + foreach { -join ("-", $_) } +} + function script:expandParamValues($cmd, $param, $filter) { $paramvalues[$cmd][$param] -split ' ' | where { $_ -like "$filter*" } | @@ -338,6 +355,11 @@ function GitTabExpansion($lastBlock) { "^(?(?:add|branch|diff|log|merge|rm|status)).* --(?\S*)$" { expandParams $matches['cmd'] $matches['param'] } + + # Handles git - + "^(?(?:add|branch|diff|log|merge|rm|status)).* -(?\S*)$" { + expandShortParams $matches['cmd'] $matches['shortparam'] + } } } From 98b0b9fdd8c87b6fe60951ba8e15837208e02a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 11:32:49 +0200 Subject: [PATCH 06/23] added tab completion for commit cmd --- GitTabExpansion.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index 335bbbec9..d94f3bb27 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -8,6 +8,7 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ $shortparams = @{ add = 'n v f i p e u A N' branch = 'd D l f m M r a v vv q t u' + commit = 'a p C c z F m t s n e i o u v q S' diff = 'p u s U z B M C D l S G O R a b w W' log = 'L n i E F g c c m r t' merge = 'e n s X q v S m' @@ -18,6 +19,7 @@ $shortparams = @{ $params = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' + commit = 'all patch reuse-message reedit-message fixup squash reset-author short branch porcelain long null file author date message template signoff no-verify allow-empty allow-empty-message cleanup= edit no-edit ammend no-post-rewrite include only untracked-files verbose quiet dry-run status no-status gpg-sign no-gpg-sign' diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' log = 'follow no-decorate decorate source use-mailmap full-diff log-size max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk= do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' @@ -29,6 +31,8 @@ $paramvalues = @{ branch = @{ color = 'always never auto' abbrev = '7 8 9 10' } + commit = @{ + 'cleanup' = 'strip whitespace verbatim scissors default' } diff = @{ unified = '0 1 2 3 4 5' 'diff-algorithm' = 'default patience minimal histogram myers' @@ -347,17 +351,17 @@ function GitTabExpansion($lastBlock) { } # Handles git --= - "^(?(?:add|branch|diff|log|merge|rm|status)).* --(?[^=]+)=(?\S*)$" { + "^(?(?:add|branch|commit|diff|log|merge|rm|status)).* --(?[^=]+)=(?\S*)$" { expandParamValues $matches['cmd'] $matches['param'] $matches['value'] } # Handles git -- - "^(?(?:add|branch|diff|log|merge|rm|status)).* --(?\S*)$" { + "^(?(?:add|branch|commit|diff|log|merge|rm|status)).* --(?\S*)$" { expandParams $matches['cmd'] $matches['param'] } # Handles git - - "^(?(?:add|branch|diff|log|merge|rm|status)).* -(?\S*)$" { + "^(?(?:add|branch|commit|diff|log|merge|rm|status)).* -(?\S*)$" { expandShortParams $matches['cmd'] $matches['shortparam'] } } From 8a6a99dc8f0a745d952aee1cbe81081d50fd27dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 16:55:21 +0200 Subject: [PATCH 07/23] added tab completion for checkout, fetch, pull, push cmds --- GitTabExpansion.ps1 | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index d94f3bb27..0e43ac81c 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -8,10 +8,14 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ $shortparams = @{ add = 'n v f i p e u A N' branch = 'd D l f m M r a v vv q t u' + checkout = 'q f b B t l m p' commit = 'a p C c z F m t s n e i o u v q S' diff = 'p u s U z B M C D l S G O R a b w W' + fetch = 'a f k p n t u q v' log = 'L n i E F g c c m r t' merge = 'e n s X q v S m' + pull = 'q v e n s X r a f k u' + push = 'n f u q v' status = 's b u z' rm = 'f n r q' } @@ -19,10 +23,14 @@ $shortparams = @{ $params = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' + checkout = 'quiet force ours theirs track no-track detach orphan ignore-skip-worktree-bits merge conflict= patch' commit = 'all patch reuse-message reedit-message fixup squash reset-author short branch porcelain long null file author date message template signoff no-verify allow-empty allow-empty-message cleanup= edit no-edit ammend no-post-rewrite include only untracked-files verbose quiet dry-run status no-status gpg-sign no-gpg-sign' diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' + fetch = 'all append depth= unshallow update-shallow dry-run force keep multiple prune no-tags tags recurse-submodules= no-recurse-submodules submodule-prefix= recurse-submodules-default= update-head-ok upload-pack quiet verbose progress' log = 'follow no-decorate decorate source use-mailmap full-diff log-size max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk= do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' + pull = 'quiet verbose recurse-submodules= no-recurse-submodules= commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy= strategy-option= verify-signatures no-verify-signatures summary no-summary rebase= no-rebase all append depth= unshallow update-shallow force keep no-tags update-head-ok upload-pack progress' + push = 'all prune mirror dry-run porcelain delete tags follow-tags receive-pack= exec= force-with-lease= no-force-with-lease force repo= set-upstream thin no-thin quiet verbose progress recurse-submodules= verify no-verify' status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' rm = 'force dry-run cached ignore-unmatch quiet' } @@ -31,6 +39,8 @@ $paramvalues = @{ branch = @{ color = 'always never auto' abbrev = '7 8 9 10' } + checkout = @{ + conflict = 'merge diff3' } commit = @{ 'cleanup' = 'strip whitespace verbatim scissors default' } diff = @{ @@ -42,6 +52,9 @@ $paramvalues = @{ 'diff-filter' = 'A C D M R T U X B *' 'inter-hunk-context' = '0 1 2 3 4 5' 'ignore-submodules' = 'none untracked dirty all' } + fetch = @{ + 'recurse-submodules' = 'yes on-demand no' + 'recurse-submodules-default' = 'yes on-demand' } log = @{ decorate = 'short full no' 'no-walk' = 'sorted unsorted' @@ -51,6 +64,12 @@ $paramvalues = @{ date = 'relative local default iso rfc short raw' } merge = @{ log = '1 2 3 4 5 6 7 8 9' } + pull = @{ + 'recurse-submodules' = 'yes on-demand no' + 'no-recurse-submodules' = 'yes on-demand no' + rebase = 'false true preserve' } + push = @{ + 'recurse-submodules' = 'check on-demand' } status = @{ 'untracked-files' = 'no normal all' 'ignore-submodules' = 'none untracked dirty all' } @@ -351,17 +370,17 @@ function GitTabExpansion($lastBlock) { } # Handles git --= - "^(?(?:add|branch|commit|diff|log|merge|rm|status)).* --(?[^=]+)=(?\S*)$" { + "^(?(?:add|branch|checkout|commit|diff|fetch|log|merge|pull|push|rm|status)).* --(?[^=]+)=(?\S*)$" { expandParamValues $matches['cmd'] $matches['param'] $matches['value'] } # Handles git -- - "^(?(?:add|branch|commit|diff|log|merge|rm|status)).* --(?\S*)$" { + "^(?(?:add|branch|checkout|commit|diff|fetch|log|merge|pull|push|rm|status)).* --(?\S*)$" { expandParams $matches['cmd'] $matches['param'] } # Handles git - - "^(?(?:add|branch|commit|diff|log|merge|rm|status)).* -(?\S*)$" { + "^(?(?:add|branch|checkout|commit|diff|fetch|log|merge|pull|push|rm|status)).* -(?\S*)$" { expandShortParams $matches['cmd'] $matches['shortparam'] } } From 57c9159a19bbe373f7e726ad1010962c5608f8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sun, 12 Apr 2015 23:15:36 +0200 Subject: [PATCH 08/23] added tab completion for rebase --- GitTabExpansion.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index 0e43ac81c..1524a580b 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -16,6 +16,7 @@ $shortparams = @{ merge = 'e n s X q v S m' pull = 'q v e n s X r a f k u' push = 'n f u q v' + rebase = 'm s X S q v n C f i p x' status = 's b u z' rm = 'f n r q' } @@ -31,6 +32,7 @@ $params = @{ merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' pull = 'quiet verbose recurse-submodules= no-recurse-submodules= commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy= strategy-option= verify-signatures no-verify-signatures summary no-summary rebase= no-rebase all append depth= unshallow update-shallow force keep no-tags update-head-ok upload-pack progress' push = 'all prune mirror dry-run porcelain delete tags follow-tags receive-pack= exec= force-with-lease= no-force-with-lease force repo= set-upstream thin no-thin quiet verbose progress recurse-submodules= verify no-verify' + rebase = 'onto continue abort keep-empty skip edit-todo merge strategy= strategy-option= gpg-sign quiet verbose stat no-stat no-verify verify force-rebase fork-point no-fork-point ignore-whitespace whitespace= committer-date-is-author-date ignore-date interactive preserve-merges exec root autosquash no-autosquash autostash no-autostash no-ff' status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' rm = 'force dry-run cached ignore-unmatch quiet' } @@ -63,13 +65,17 @@ $paramvalues = @{ encoding = 'UTF-8' date = 'relative local default iso rfc short raw' } merge = @{ + strategy = 'resolve recursive octopus ours subtree' log = '1 2 3 4 5 6 7 8 9' } pull = @{ + strategy = 'resolve recursive octopus ours subtree' 'recurse-submodules' = 'yes on-demand no' 'no-recurse-submodules' = 'yes on-demand no' rebase = 'false true preserve' } push = @{ 'recurse-submodules' = 'check on-demand' } + rebase = @{ + strategy = 'resolve recursive octopus ours subtree' } status = @{ 'untracked-files' = 'no normal all' 'ignore-submodules' = 'none untracked dirty all' } From f990b3b1acf2601b18ac59faab0d8c4063bc6914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 16 Apr 2015 01:12:39 +0200 Subject: [PATCH 09/23] added tab completion for all other cmds except bisect, svn --- GitTabExpansion.ps1 | 83 ++----------------------- ParamsExpansions.ps1 | 140 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 145 insertions(+), 78 deletions(-) create mode 100644 ParamsExpansions.ps1 diff --git a/GitTabExpansion.ps1 b/GitTabExpansion.ps1 index 1524a580b..79181b238 100644 --- a/GitTabExpansion.ps1 +++ b/GitTabExpansion.ps1 @@ -5,81 +5,8 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ AllCommands = $false } -$shortparams = @{ - add = 'n v f i p e u A N' - branch = 'd D l f m M r a v vv q t u' - checkout = 'q f b B t l m p' - commit = 'a p C c z F m t s n e i o u v q S' - diff = 'p u s U z B M C D l S G O R a b w W' - fetch = 'a f k p n t u q v' - log = 'L n i E F g c c m r t' - merge = 'e n s X q v S m' - pull = 'q v e n s X r a f k u' - push = 'n f u q v' - rebase = 'm s X S q v n C f i p x' - status = 's b u z' - rm = 'f n r q' -} - -$params = @{ - add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' - branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' - checkout = 'quiet force ours theirs track no-track detach orphan ignore-skip-worktree-bits merge conflict= patch' - commit = 'all patch reuse-message reedit-message fixup squash reset-author short branch porcelain long null file author date message template signoff no-verify allow-empty allow-empty-message cleanup= edit no-edit ammend no-post-rewrite include only untracked-files verbose quiet dry-run status no-status gpg-sign no-gpg-sign' - diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' - fetch = 'all append depth= unshallow update-shallow dry-run force keep multiple prune no-tags tags recurse-submodules= no-recurse-submodules submodule-prefix= recurse-submodules-default= update-head-ok upload-pack quiet verbose progress' - log = 'follow no-decorate decorate source use-mailmap full-diff log-size max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk= do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' - merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' - pull = 'quiet verbose recurse-submodules= no-recurse-submodules= commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy= strategy-option= verify-signatures no-verify-signatures summary no-summary rebase= no-rebase all append depth= unshallow update-shallow force keep no-tags update-head-ok upload-pack progress' - push = 'all prune mirror dry-run porcelain delete tags follow-tags receive-pack= exec= force-with-lease= no-force-with-lease force repo= set-upstream thin no-thin quiet verbose progress recurse-submodules= verify no-verify' - rebase = 'onto continue abort keep-empty skip edit-todo merge strategy= strategy-option= gpg-sign quiet verbose stat no-stat no-verify verify force-rebase fork-point no-fork-point ignore-whitespace whitespace= committer-date-is-author-date ignore-date interactive preserve-merges exec root autosquash no-autosquash autostash no-autostash no-ff' - status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' - rm = 'force dry-run cached ignore-unmatch quiet' -} - -$paramvalues = @{ - branch = @{ - color = 'always never auto' - abbrev = '7 8 9 10' } - checkout = @{ - conflict = 'merge diff3' } - commit = @{ - 'cleanup' = 'strip whitespace verbatim scissors default' } - diff = @{ - unified = '0 1 2 3 4 5' - 'diff-algorithm' = 'default patience minimal histogram myers' - color = 'always never auto' - 'word-diff' = 'color plain porcelain none' - abbrev = '7 8 9 10' - 'diff-filter' = 'A C D M R T U X B *' - 'inter-hunk-context' = '0 1 2 3 4 5' - 'ignore-submodules' = 'none untracked dirty all' } - fetch = @{ - 'recurse-submodules' = 'yes on-demand no' - 'recurse-submodules-default' = 'yes on-demand' } - log = @{ - decorate = 'short full no' - 'no-walk' = 'sorted unsorted' - pretty = 'oneline short medium full fuller email raw' - format = 'oneline short medium full fuller email raw' - encoding = 'UTF-8' - date = 'relative local default iso rfc short raw' } - merge = @{ - strategy = 'resolve recursive octopus ours subtree' - log = '1 2 3 4 5 6 7 8 9' } - pull = @{ - strategy = 'resolve recursive octopus ours subtree' - 'recurse-submodules' = 'yes on-demand no' - 'no-recurse-submodules' = 'yes on-demand no' - rebase = 'false true preserve' } - push = @{ - 'recurse-submodules' = 'check on-demand' } - rebase = @{ - strategy = 'resolve recursive octopus ours subtree' } - status = @{ - 'untracked-files' = 'no normal all' - 'ignore-submodules' = 'none untracked dirty all' } -} +# load parameter expansion data +. .\ParamsExpansions.ps1 $subcommands = @{ bisect = 'start bad good skip reset visualize replay log run' @@ -376,17 +303,17 @@ function GitTabExpansion($lastBlock) { } # Handles git --= - "^(?(?:add|branch|checkout|commit|diff|fetch|log|merge|pull|push|rm|status)).* --(?[^=]+)=(?\S*)$" { + "^(?$($someCommands -join '|')).* --(?[^=]+)=(?\S*)$" { expandParamValues $matches['cmd'] $matches['param'] $matches['value'] } # Handles git -- - "^(?(?:add|branch|checkout|commit|diff|fetch|log|merge|pull|push|rm|status)).* --(?\S*)$" { + "^(?$($someCommands -join '|')).* --(?\S*)$" { expandParams $matches['cmd'] $matches['param'] } # Handles git - - "^(?(?:add|branch|checkout|commit|diff|fetch|log|merge|pull|push|rm|status)).* -(?\S*)$" { + "^(?$($someCommands -join '|')).* -(?\S*)$" { expandShortParams $matches['cmd'] $matches['shortparam'] } } diff --git a/ParamsExpansions.ps1 b/ParamsExpansions.ps1 new file mode 100644 index 000000000..9dcd7e858 --- /dev/null +++ b/ParamsExpansions.ps1 @@ -0,0 +1,140 @@ +$shortparams = @{ + add = 'n v f i p e u A N' + blame = 'b L l t S p M C h c f n s e w' + branch = 'd D l f m M r a v vv q t u' + checkout = 'q f b B t l m p' + cherry = 'v' + 'cherry-pick' = 'e x r m n s S X' + clean = 'd f i n q e x X' + clone = 'l s q v n o b u c' + commit = 'a p C c z F m t s n e i o u v q S' + config = 'f l z e' + diff = 'p u s U z B M C D l S G O R a b w W' + difftool = 'd y t x g' + fetch = 'a f k p n t u q v' + grep = 'a i I w v h H E G P F n l L O z c p C A B W f e q' + help = 'a g i m w' + init = 'q' + log = 'L n i E F g c c m r t' + merge = 'e n s X q v S m' + mergetool = 't y' + mv = 'f k n v' + notes = 'f m F C c n s q v' + prune = 'n v' + pull = 'q v e n s X r a f k u' + push = 'n f u q v' + rebase = 'm s X S q v n C f i p x' + remote = 'v' + reset = 'q p ' + revert = 'e m n S s X' + rm = 'f n r q' + shortlog = 'n s e w' + stash = 'p k u a q' + status = 's b u z' + submodule = 'q b f n N' + tag = 'a s u f d v n l m F' + whatchanged = 'p' +} + +$params = @{ + add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' + blame = 'root show-stats reverse porcelain line-porcelain incremental encoding= contents date score-debug show-name show-number show-email abbrev' + branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' + checkout = 'quiet force ours theirs track no-track detach orphan ignore-skip-worktree-bits merge conflict= patch' + 'cherry-pick' = 'edit mainline no-commit signoff gpg-sign ff allow-empty allow-empty-message keep-redundant-commits strategy= strategy-option= ´continue quit abort' + clean = 'force interactive dry-run quiet exclude=' + clone = 'local no-hardlinks shared reference quiet verbose progress no-checkout bare mirror origin branch upload-pack template= config depth single-branch no-single-branch recursive recurse-submodules separate-git-dir=' + commit = 'all patch reuse-message reedit-message fixup squash reset-author short branch porcelain long null file author date message template signoff no-verify allow-empty allow-empty-message cleanup= edit no-edit ammend no-post-rewrite include only untracked-files verbose quiet dry-run status no-status gpg-sign no-gpg-sign' + config = 'replace-all add get get-all get-regexp get-urlmatch global system local file blob remove-section rename-section unset unset-all list bool int bool-or-int path null get-colorbool get-color edit includes no-includes' + describe = 'dirty all tags contains abbrev candidates= exact-match debug long match always first-parent' + diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' + difftool = 'dir-diff no-prompt prompt tool= tool-help no-symlinks symlinks extcmd= gui' + fetch = 'all append depth= unshallow update-shallow dry-run force keep multiple prune no-tags tags recurse-submodules= no-recurse-submodules submodule-prefix= recurse-submodules-default= update-head-ok upload-pack quiet verbose progress' + gc = 'aggressive auto prune= no-prune quiet force' + grep = 'cached no-index untracked no-exclude-standard exclude-standard text textconv no-textconv ignore-case max-depth word-regexp invert-match full-name extended-regexp basic-regexp perl-regexp fixed-strings line-number files-with-matches open-file-in-pager null count color no-color break heading show-function context after-context before-context function-context and or not all-match quiet' + help = 'all guides info man web' + init = 'quiet bare template= separate-git-dir= shared=' + log = 'follow no-decorate decorate source use-mailmap full-diff log-size max-count skip since after until before author committer grep-reflog grep all-match regexp-ignore-case basic-regexp extended-regexp fixed-strings perl-regexp remove-empty merges no-merges min-parents max-parents no-min-parents no-max-parents first-parent not all branches tags remote glob= exclude= ignore-missing bisect stdin cherry-mark cherry-pick left-only right-only cherry walk-reflogs merge boundary simplify-by-decoration full-history dense sparse simplify-merges ancestry-path date-order author-date-order topo-order reverse objects objects-edge unpacked no-walk= do-walk pretty format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes standard-notes no-standard-notes show-signature relative-date date= parents children left-right graph show-linear-break ' + merge = 'commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy strategy-option verify-signatures no-verify-signatures summary no-summary quiet verbose progress no-progress gpg-sign rerere-autoupdate no-rerere-autoupdate abort' + mergetool = 'tool= tool-help no-prompt prompt' + mv = 'force dry-run verbose' + notes = 'force message file reuse-message reedit-message ref ignore-missing stdin dry-run strategy= commit abort quiet verbose' + prune = 'dry-run verbose expire' + pull = 'quiet verbose recurse-submodules= no-recurse-submodules= commit no-commit edit no-edit ff no-ff ff-only log no-log stat no-stat squash no-squash strategy= strategy-option= verify-signatures no-verify-signatures summary no-summary rebase= no-rebase all append depth= unshallow update-shallow force keep no-tags update-head-ok upload-pack progress' + push = 'all prune mirror dry-run porcelain delete tags follow-tags receive-pack= exec= force-with-lease= no-force-with-lease force repo= set-upstream thin no-thin quiet verbose progress recurse-submodules= verify no-verify' + rebase = 'onto continue abort keep-empty skip edit-todo merge strategy= strategy-option= gpg-sign quiet verbose stat no-stat no-verify verify force-rebase fork-point no-fork-point ignore-whitespace whitespace= committer-date-is-author-date ignore-date interactive preserve-merges exec root autosquash no-autosquash autostash no-autostash no-ff' + reflog = 'stale-fix expire= expire-unreachable= all updateref rewrite verbose' + remote = 'verbose' + reset = 'patch quiet soft mixed hard merge keep' + revert = 'edit mainline no-edit no-commit gpg-sign signoff strategy= strategy-option continue quit abort' + rm = 'force dry-run cached ignore-unmatch quiet' + shortlog = 'numbered summary email format=' + show = 'pretty= format= abbrev-commit no-abbrev-commit oneline encoding= notes no-notes show-notes no-standard-notes standard-notes show-signature' + stash = 'patch no-keep-index keep-index include-untracked all quiet index' + status = 'short branch porcelain long untracked-files ignore-submodules ignored column no-column' + submodule = 'quiet branch force cached files summary-limit remote no-fetch checkout merge rebase init name reference recursive depth' + tag = 'annotate sign local-user force delete verify list sort column no-column contains points-at message file cleanup' + whatchanged = 'since' +} + +$paramvalues = @{ + blame = @{ + encoding = 'utf-8 none' } + branch = @{ + color = 'always never auto' + abbrev = '7 8 9 10' } + checkout = @{ + conflict = 'merge diff3' } + 'cherry-pick' = @{ + strategy = 'resolve recursive octopus ours subtree' } + commit = @{ + 'cleanup' = 'strip whitespace verbatim scissors default' } + diff = @{ + unified = '0 1 2 3 4 5' + 'diff-algorithm' = 'default patience minimal histogram myers' + color = 'always never auto' + 'word-diff' = 'color plain porcelain none' + abbrev = '7 8 9 10' + 'diff-filter' = 'A C D M R T U X B *' + 'inter-hunk-context' = '0 1 2 3 4 5' + 'ignore-submodules' = 'none untracked dirty all' } + difftool = @{ + tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' } + fetch = @{ + 'recurse-submodules' = 'yes on-demand no' + 'recurse-submodules-default' = 'yes on-demand' } + init = @{ + shared = 'false true umask group all world everybody o' } + log = @{ + decorate = 'short full no' + 'no-walk' = 'sorted unsorted' + pretty = 'oneline short medium full fuller email raw' + format = 'oneline short medium full fuller email raw' + encoding = 'UTF-8' + date = 'relative local default iso rfc short raw' } + merge = @{ + strategy = 'resolve recursive octopus ours subtree' + log = '1 2 3 4 5 6 7 8 9' } + mergetool = @{ + tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' } + notes = @{ + strategy = 'manual ours theirs union cat_sort_uniq' } + pull = @{ + strategy = 'resolve recursive octopus ours subtree' + 'recurse-submodules' = 'yes on-demand no' + 'no-recurse-submodules' = 'yes on-demand no' + rebase = 'false true preserve' } + push = @{ + 'recurse-submodules' = 'check on-demand' } + rebase = @{ + strategy = 'resolve recursive octopus ours subtree' } + revert = @{ + strategy = 'resolve recursive octopus ours subtree' } + show = @{ + pretty = 'oneline short medium full fuller email raw' + format = 'oneline short medium full fuller email raw' + encoding = 'utf-8' } + status = @{ + 'untracked-files' = 'no normal all' + 'ignore-submodules' = 'none untracked dirty all' } +} From f40922afcec01fd92c02877f861f9b9b0185cf96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 2 Feb 2017 21:49:29 +0100 Subject: [PATCH 10/23] added tab completion for bisect --- ParamsExpansions.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ParamsExpansions.ps1 b/ParamsExpansions.ps1 index 9dcd7e858..64c4b00f9 100644 --- a/ParamsExpansions.ps1 +++ b/ParamsExpansions.ps1 @@ -1,5 +1,6 @@ $shortparams = @{ add = 'n v f i p e u A N' + bisect = '' blame = 'b L l t S p M C h c f n s e w' branch = 'd D l f m M r a v vv q t u' checkout = 'q f b B t l m p' @@ -25,7 +26,7 @@ $shortparams = @{ push = 'n f u q v' rebase = 'm s X S q v n C f i p x' remote = 'v' - reset = 'q p ' + reset = 'q p' revert = 'e m n S s X' rm = 'f n r q' shortlog = 'n s e w' @@ -38,7 +39,8 @@ $shortparams = @{ $params = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' - blame = 'root show-stats reverse porcelain line-porcelain incremental encoding= contents date score-debug show-name show-number show-email abbrev' + bisect = 'no-checkout term-old term-new' + blame = 'root show-stats reverse porcelain line-porcelain incremental encoding= contents date score-debug show-name show-number show-email abbrev' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' checkout = 'quiet force ours theirs track no-track detach orphan ignore-skip-worktree-bits merge conflict= patch' 'cherry-pick' = 'edit mainline no-commit signoff gpg-sign ff allow-empty allow-empty-message keep-redundant-commits strategy= strategy-option= ´continue quit abort' From c76f1f6ea4fa2768d76f5a6cca0350c3f5cf8e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 2 Feb 2017 22:11:44 +0100 Subject: [PATCH 11/23] moved file due to new filesystem layout --- ParamsExpansions.ps1 => src/ParamsExpansions.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ParamsExpansions.ps1 => src/ParamsExpansions.ps1 (100%) diff --git a/ParamsExpansions.ps1 b/src/ParamsExpansions.ps1 similarity index 100% rename from ParamsExpansions.ps1 rename to src/ParamsExpansions.ps1 From fc39c001b3875cc778277fe9c167f3e212523667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 2 Feb 2017 22:34:08 +0100 Subject: [PATCH 12/23] moved source params expansion statement into posh-git.psm1 --- src/GitTabExpansion.ps1 | 3 --- src/posh-git.psm1 | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 9122cf8c6..2e651025f 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -5,9 +5,6 @@ $Global:GitTabSettings = New-Object PSObject -Property @{ AllCommands = $false } -# load parameter expansion data -. .\ParamsExpansions.ps1 - $subcommands = @{ bisect = 'start bad good skip reset visualize replay log run' notes = 'edit show' diff --git a/src/posh-git.psm1 b/src/posh-git.psm1 index 62cf96d5a..cee11a26f 100644 --- a/src/posh-git.psm1 +++ b/src/posh-git.psm1 @@ -17,6 +17,7 @@ if ($psv.Major -lt 3 -and !$NoVersionWarn) { . $PSScriptRoot\GitUtils.ps1 . $PSScriptRoot\GitPrompt.ps1 . $PSScriptRoot\GitTabExpansion.ps1 +. $PSScriptRoot\ParamsExpansions.ps1 . $PSScriptRoot\TortoiseGit.ps1 if (!$Env:HOME) { $Env:HOME = "$Env:HOMEDRIVE$Env:HOMEPATH" } From 4361b1b91aa258e86807578c12f00ecc768ffb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 2 Feb 2017 23:13:06 +0100 Subject: [PATCH 13/23] replaced aliases with full cmdlet names --- src/GitTabExpansion.ps1 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 2e651025f..56223e415 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -182,23 +182,23 @@ function script:expandGitAlias($cmd, $rest) { function script:expandParams($cmd, $filter) { $params[$cmd] -split ' ' | - where { $_ -like "$filter*" } | - sort | - foreach { -join ("--", $_) } + Where-Object { $_ -like "$filter*" } | + Sort-Object | + ForEach-Object { -join ("--", $_) } } function script:expandShortParams($cmd, $filter) { $shortparams[$cmd] -split ' ' | - where { $_ -like "$filter*" } | - sort | - foreach { -join ("-", $_) } + Where-Object { $_ -like "$filter*" } | + Sort-Object | + ForEach-Object { -join ("-", $_) } } function script:expandParamValues($cmd, $param, $filter) { $paramvalues[$cmd][$param] -split ' ' | - where { $_ -like "$filter*" } | - sort | - foreach { -join ("--", $param, "=", $_) } + Where-Object { $_ -like "$filter*" } | + Sort-Object | + ForEach-Object { -join ("--", $param, "=", $_) } } function GitTabExpansion($lastBlock) { From bf2bda90c487c497e89dd3d0701bed39e908b96a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 2 Feb 2017 23:18:40 +0100 Subject: [PATCH 14/23] whitespaces / eol / eof fixes --- src/ParamsExpansions.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ParamsExpansions.ps1 b/src/ParamsExpansions.ps1 index 64c4b00f9..ab85304cc 100644 --- a/src/ParamsExpansions.ps1 +++ b/src/ParamsExpansions.ps1 @@ -1,9 +1,9 @@ $shortparams = @{ add = 'n v f i p e u A N' - bisect = '' + bisect = '' blame = 'b L l t S p M C h c f n s e w' branch = 'd D l f m M r a v vv q t u' - checkout = 'q f b B t l m p' + checkout = 'q f b B t l m p' cherry = 'v' 'cherry-pick' = 'e x r m n s S X' clean = 'd f i n q e x X' @@ -103,7 +103,7 @@ $paramvalues = @{ difftool = @{ tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' } fetch = @{ - 'recurse-submodules' = 'yes on-demand no' + 'recurse-submodules' = 'yes on-demand no' 'recurse-submodules-default' = 'yes on-demand' } init = @{ shared = 'false true umask group all world everybody o' } From 0302fd5f37674cfe320df5b41407151bb85cfa50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 2 Feb 2017 23:20:36 +0100 Subject: [PATCH 15/23] eol at eof added --- src/ParamsExpansions.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ParamsExpansions.ps1 b/src/ParamsExpansions.ps1 index ab85304cc..2072ee535 100644 --- a/src/ParamsExpansions.ps1 +++ b/src/ParamsExpansions.ps1 @@ -140,3 +140,4 @@ $paramvalues = @{ 'untracked-files' = 'no normal all' 'ignore-submodules' = 'none untracked dirty all' } } + From fe0608ec87b245e38d256d7223a5a4f5c1497884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Thu, 2 Feb 2017 23:30:35 +0100 Subject: [PATCH 16/23] renamed file for consistency reasons --- src/{ParamsExpansions.ps1 => GitParamsExpansion.ps1} | 0 src/posh-git.psm1 | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{ParamsExpansions.ps1 => GitParamsExpansion.ps1} (100%) diff --git a/src/ParamsExpansions.ps1 b/src/GitParamsExpansion.ps1 similarity index 100% rename from src/ParamsExpansions.ps1 rename to src/GitParamsExpansion.ps1 diff --git a/src/posh-git.psm1 b/src/posh-git.psm1 index cee11a26f..a8fe8b82c 100644 --- a/src/posh-git.psm1 +++ b/src/posh-git.psm1 @@ -17,7 +17,7 @@ if ($psv.Major -lt 3 -and !$NoVersionWarn) { . $PSScriptRoot\GitUtils.ps1 . $PSScriptRoot\GitPrompt.ps1 . $PSScriptRoot\GitTabExpansion.ps1 -. $PSScriptRoot\ParamsExpansions.ps1 +. $PSScriptRoot\GitParamsExpansion.ps1 . $PSScriptRoot\TortoiseGit.ps1 if (!$Env:HOME) { $Env:HOME = "$Env:HOMEDRIVE$Env:HOMEPATH" } From dffdbd37bb3432166d417f681fcd1a1437544e25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Fri, 3 Feb 2017 00:16:11 +0100 Subject: [PATCH 17/23] renamed file for consistency reasons --- src/{GitParamsExpansion.ps1 => GitParamTabExpansion.ps1} | 0 src/posh-git.psm1 | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{GitParamsExpansion.ps1 => GitParamTabExpansion.ps1} (100%) diff --git a/src/GitParamsExpansion.ps1 b/src/GitParamTabExpansion.ps1 similarity index 100% rename from src/GitParamsExpansion.ps1 rename to src/GitParamTabExpansion.ps1 diff --git a/src/posh-git.psm1 b/src/posh-git.psm1 index a8fe8b82c..c7c6086bb 100644 --- a/src/posh-git.psm1 +++ b/src/posh-git.psm1 @@ -17,7 +17,7 @@ if ($psv.Major -lt 3 -and !$NoVersionWarn) { . $PSScriptRoot\GitUtils.ps1 . $PSScriptRoot\GitPrompt.ps1 . $PSScriptRoot\GitTabExpansion.ps1 -. $PSScriptRoot\GitParamsExpansion.ps1 +. $PSScriptRoot\GitParamTabExpansion.ps1 . $PSScriptRoot\TortoiseGit.ps1 if (!$Env:HOME) { $Env:HOME = "$Env:HOMEDRIVE$Env:HOMEPATH" } From 8eff9cc30aaa0683061a18f45b5945ae0d1ec4de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Fri, 3 Feb 2017 00:20:10 +0100 Subject: [PATCH 18/23] added parameter tab expansion tests --- test/ParamsTabExpansion.Tests.ps1 | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/ParamsTabExpansion.Tests.ps1 diff --git a/test/ParamsTabExpansion.Tests.ps1 b/test/ParamsTabExpansion.Tests.ps1 new file mode 100644 index 000000000..a65b70133 --- /dev/null +++ b/test/ParamsTabExpansion.Tests.ps1 @@ -0,0 +1,45 @@ +. $PSScriptRoot\Shared.ps1 + +Describe 'ParamsTabExpansion Tests' { + Context 'Push Parameters TabExpansion Tests' { + It 'Tab completes all long push parameters' { + $result = & $module GitTabExpansionInternal 'git push --' + $result -contains 'all' | Should Be $true + $result -contains 'delete' | Should Be $true + $result -contains 'dry-run' | Should Be $true + $result -contains 'exec=' | Should Be $true + $result -contains 'follow-tags' | Should Be $true + $result -contains 'force' | Should Be $true + $result -contains 'force-with-lease=' | Should Be $true + $result -contains 'mirror' | Should Be $true + $result -contains 'no-force-with-lease' | Should Be $true + $result -contains 'no-thin' | Should Be $true + $result -contains 'no-verify' | Should Be $true + $result -contains 'porcelain' | Should Be $true + $result -contains 'progress' | Should Be $true + $result -contains 'prune' | Should Be $true + $result -contains 'quiet' | Should Be $true + $result -contains 'receive-pack=' | Should Be $true + $result -contains 'recurse-submodules=' | Should Be $true + $result -contains 'repo=' | Should Be $true + $result -contains 'set-upstream' | Should Be $true + $result -contains 'tags' | Should Be $true + $result -contains 'thin' | Should Be $true + $result -contains 'verbose' | Should Be $true + $result -contains 'verify' | Should Be $true + } + It 'Tab completes all short push parameters' { + $result = & $module GitTabExpansionInternal 'git push -' + $result -contains 'f' | Should Be $true + $result -contains 'n' | Should Be $true + $result -contains 'q' | Should Be $true + $result -contains 'u' | Should Be $true + $result -contains 'v' | Should Be $true + } + It 'Tab completes push parameters values' { + $result = & $module GitTabExpansionInternal 'git push --recurse-submodules=' + $result -contains 'check' | Should Be $true + $result -contains 'on-demand' | Should Be $true + } + } +} From f11d033216fc0a9e7be422a3ad2b2b7d8d6f372b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Fri, 3 Feb 2017 00:38:53 +0100 Subject: [PATCH 19/23] corrected test result expectations --- test/ParamsTabExpansion.Tests.ps1 | 60 +++++++++++++++---------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/test/ParamsTabExpansion.Tests.ps1 b/test/ParamsTabExpansion.Tests.ps1 index a65b70133..7723cbb0a 100644 --- a/test/ParamsTabExpansion.Tests.ps1 +++ b/test/ParamsTabExpansion.Tests.ps1 @@ -4,42 +4,42 @@ Describe 'ParamsTabExpansion Tests' { Context 'Push Parameters TabExpansion Tests' { It 'Tab completes all long push parameters' { $result = & $module GitTabExpansionInternal 'git push --' - $result -contains 'all' | Should Be $true - $result -contains 'delete' | Should Be $true - $result -contains 'dry-run' | Should Be $true - $result -contains 'exec=' | Should Be $true - $result -contains 'follow-tags' | Should Be $true - $result -contains 'force' | Should Be $true - $result -contains 'force-with-lease=' | Should Be $true - $result -contains 'mirror' | Should Be $true - $result -contains 'no-force-with-lease' | Should Be $true - $result -contains 'no-thin' | Should Be $true - $result -contains 'no-verify' | Should Be $true - $result -contains 'porcelain' | Should Be $true - $result -contains 'progress' | Should Be $true - $result -contains 'prune' | Should Be $true - $result -contains 'quiet' | Should Be $true - $result -contains 'receive-pack=' | Should Be $true - $result -contains 'recurse-submodules=' | Should Be $true - $result -contains 'repo=' | Should Be $true - $result -contains 'set-upstream' | Should Be $true - $result -contains 'tags' | Should Be $true - $result -contains 'thin' | Should Be $true - $result -contains 'verbose' | Should Be $true - $result -contains 'verify' | Should Be $true + $result -contains '--all' | Should Be $true + $result -contains '--delete' | Should Be $true + $result -contains '--dry-run' | Should Be $true + $result -contains '--exec=' | Should Be $true + $result -contains '--follow-tags' | Should Be $true + $result -contains '--force' | Should Be $true + $result -contains '--force-with-lease=' | Should Be $true + $result -contains '--mirror' | Should Be $true + $result -contains '--no-force-with-lease' | Should Be $true + $result -contains '--no-thin' | Should Be $true + $result -contains '--no-verify' | Should Be $true + $result -contains '--porcelain' | Should Be $true + $result -contains '--progress' | Should Be $true + $result -contains '--prune' | Should Be $true + $result -contains '--quiet' | Should Be $true + $result -contains '--receive-pack=' | Should Be $true + $result -contains '--recurse-submodules=' | Should Be $true + $result -contains '--repo=' | Should Be $true + $result -contains '--set-upstream' | Should Be $true + $result -contains '--tags' | Should Be $true + $result -contains '--thin' | Should Be $true + $result -contains '--verbose' | Should Be $true + $result -contains '--verify' | Should Be $true } It 'Tab completes all short push parameters' { $result = & $module GitTabExpansionInternal 'git push -' - $result -contains 'f' | Should Be $true - $result -contains 'n' | Should Be $true - $result -contains 'q' | Should Be $true - $result -contains 'u' | Should Be $true - $result -contains 'v' | Should Be $true + $result -contains '-f' | Should Be $true + $result -contains '-n' | Should Be $true + $result -contains '-q' | Should Be $true + $result -contains '-u' | Should Be $true + $result -contains '-v' | Should Be $true } It 'Tab completes push parameters values' { $result = & $module GitTabExpansionInternal 'git push --recurse-submodules=' - $result -contains 'check' | Should Be $true - $result -contains 'on-demand' | Should Be $true + $result -contains '--recurse-submodules=check' | Should Be $true + $result -contains '--recurse-submodules=on-demand' | Should Be $true } } } From a96f23c3ac07b086e0337ca70b3d141ea4930d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Fri, 3 Feb 2017 01:55:52 +0100 Subject: [PATCH 20/23] renamed file for consistency reasons --- ...ramsTabExpansion.Tests.ps1 => GitParamTabExpansion.Tests.ps1} | 1 + 1 file changed, 1 insertion(+) rename test/{ParamsTabExpansion.Tests.ps1 => GitParamTabExpansion.Tests.ps1} (98%) diff --git a/test/ParamsTabExpansion.Tests.ps1 b/test/GitParamTabExpansion.Tests.ps1 similarity index 98% rename from test/ParamsTabExpansion.Tests.ps1 rename to test/GitParamTabExpansion.Tests.ps1 index 7723cbb0a..eb10e34b0 100644 --- a/test/ParamsTabExpansion.Tests.ps1 +++ b/test/GitParamTabExpansion.Tests.ps1 @@ -43,3 +43,4 @@ Describe 'ParamsTabExpansion Tests' { } } } + From 302f50e40626f2eab2615407192dcf66fb024617 Mon Sep 17 00:00:00 2001 From: Keith Hill Date: Sat, 4 Feb 2017 11:56:07 -0700 Subject: [PATCH 21/23] Clean up PR issues that @dahlbyk raised. Also added cached param to diff. That param should be there, right? I mean, I use git diff --cached quite a bit. --- src/GitParamTabExpansion.ps1 | 71 ++++++++++++++++++++++++------------ src/GitTabExpansion.ps1 | 32 ++++++++-------- 2 files changed, 64 insertions(+), 39 deletions(-) diff --git a/src/GitParamTabExpansion.ps1 b/src/GitParamTabExpansion.ps1 index 2072ee535..a1c9a0b6e 100644 --- a/src/GitParamTabExpansion.ps1 +++ b/src/GitParamTabExpansion.ps1 @@ -1,4 +1,6 @@ -$shortparams = @{ +# Variable is used in GitTabExpansion.ps1 +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +$shortGitParams = @{ add = 'n v f i p e u A N' bisect = '' blame = 'b L l t S p M C h c f n s e w' @@ -37,10 +39,12 @@ $shortparams = @{ whatchanged = 'p' } -$params = @{ +# Variable is used in GitTabExpansion.ps1 +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +$longGitParams = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' bisect = 'no-checkout term-old term-new' - blame = 'root show-stats reverse porcelain line-porcelain incremental encoding= contents date score-debug show-name show-number show-email abbrev' + blame = 'root show-stats reverse porcelain line-porcelain incremental encoding= contents date score-debug show-name show-number show-email abbrev' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' checkout = 'quiet force ours theirs track no-track detach orphan ignore-skip-worktree-bits merge conflict= patch' 'cherry-pick' = 'edit mainline no-commit signoff gpg-sign ff allow-empty allow-empty-message keep-redundant-commits strategy= strategy-option= ´continue quit abort' @@ -49,7 +53,7 @@ $params = @{ commit = 'all patch reuse-message reedit-message fixup squash reset-author short branch porcelain long null file author date message template signoff no-verify allow-empty allow-empty-message cleanup= edit no-edit ammend no-post-rewrite include only untracked-files verbose quiet dry-run status no-status gpg-sign no-gpg-sign' config = 'replace-all add get get-all get-regexp get-urlmatch global system local file blob remove-section rename-section unset unset-all list bool int bool-or-int path null get-colorbool get-color edit includes no-includes' describe = 'dirty all tags contains abbrev candidates= exact-match debug long match always first-parent' - diff = 'patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' + diff = 'cached patch no-patch unified= raw patch-with-raw minimal patience histogram diff-algorithm= stat numstat shortstat dirstat summary patch-with-stat name-only name-status submodule color no-color word-diff word-diff-regex color-words no-renames check full-index binary apprev break-rewrites find-renames find-copies find-copies-harder irreversible-delete diff-filter= pickaxe-all pickaxe-regex relative text ignore-space-at-eol ignore-space-change ignore-all-space ignore-blank-lines inter-hunk-context= function-context exit-code quiet ext-diff no-ext-diff textconv no-textconv ignore-submodules src-prefix dst-prefix no-prefix' difftool = 'dir-diff no-prompt prompt tool= tool-help no-symlinks symlinks extcmd= gui' fetch = 'all append depth= unshallow update-shallow dry-run force keep multiple prune no-tags tags recurse-submodules= no-recurse-submodules submodule-prefix= recurse-submodules-default= update-head-ok upload-pack quiet verbose progress' gc = 'aggressive auto prune= no-prune quiet force' @@ -79,18 +83,25 @@ $params = @{ whatchanged = 'since' } -$paramvalues = @{ +# Variable is used in GitTabExpansion.ps1 +[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments', '')] +$gitParamValues = @{ blame = @{ - encoding = 'utf-8 none' } + encoding = 'utf-8 none' + } branch = @{ color = 'always never auto' - abbrev = '7 8 9 10' } + abbrev = '7 8 9 10' + } checkout = @{ - conflict = 'merge diff3' } + conflict = 'merge diff3' + } 'cherry-pick' = @{ - strategy = 'resolve recursive octopus ours subtree' } + strategy = 'resolve recursive octopus ours subtree' + } commit = @{ - 'cleanup' = 'strip whitespace verbatim scissors default' } + 'cleanup' = 'strip whitespace verbatim scissors default' + } diff = @{ unified = '0 1 2 3 4 5' 'diff-algorithm' = 'default patience minimal histogram myers' @@ -99,45 +110,57 @@ $paramvalues = @{ abbrev = '7 8 9 10' 'diff-filter' = 'A C D M R T U X B *' 'inter-hunk-context' = '0 1 2 3 4 5' - 'ignore-submodules' = 'none untracked dirty all' } + 'ignore-submodules' = 'none untracked dirty all' + } difftool = @{ - tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' } + tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' + } fetch = @{ 'recurse-submodules' = 'yes on-demand no' - 'recurse-submodules-default' = 'yes on-demand' } + 'recurse-submodules-default' = 'yes on-demand' + } init = @{ - shared = 'false true umask group all world everybody o' } + shared = 'false true umask group all world everybody o' + } log = @{ decorate = 'short full no' 'no-walk' = 'sorted unsorted' pretty = 'oneline short medium full fuller email raw' format = 'oneline short medium full fuller email raw' encoding = 'UTF-8' - date = 'relative local default iso rfc short raw' } + date = 'relative local default iso rfc short raw' + } merge = @{ strategy = 'resolve recursive octopus ours subtree' - log = '1 2 3 4 5 6 7 8 9' } + log = '1 2 3 4 5 6 7 8 9' + } mergetool = @{ - tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' } + tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' + } notes = @{ - strategy = 'manual ours theirs union cat_sort_uniq' } + strategy = 'manual ours theirs union cat_sort_uniq' + } pull = @{ strategy = 'resolve recursive octopus ours subtree' 'recurse-submodules' = 'yes on-demand no' 'no-recurse-submodules' = 'yes on-demand no' rebase = 'false true preserve' } push = @{ - 'recurse-submodules' = 'check on-demand' } + 'recurse-submodules' = 'check on-demand' + } rebase = @{ - strategy = 'resolve recursive octopus ours subtree' } + strategy = 'resolve recursive octopus ours subtree' + } revert = @{ - strategy = 'resolve recursive octopus ours subtree' } + strategy = 'resolve recursive octopus ours subtree' + } show = @{ pretty = 'oneline short medium full fuller email raw' format = 'oneline short medium full fuller email raw' - encoding = 'utf-8' } + encoding = 'utf-8' + } status = @{ 'untracked-files' = 'no normal all' - 'ignore-submodules' = 'none untracked dirty all' } + 'ignore-submodules' = 'none untracked dirty all' + } } - diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 56223e415..d01d50956 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -46,6 +46,8 @@ catch { Write-Debug "Search for 'flow' in 'git help' output failed with error: $_" } +$someCommandsJoined = $someCommands -join '|' + function script:gitCommands($filter, $includeAliases) { $cmdList = @() if (-not $global:GitTabSettings.AllCommands) { @@ -100,7 +102,7 @@ function script:gitTags($filter, $prefix = '') { } function script:gitFeatures($filter, $command){ - $featurePrefix = git config --local --get "gitflow.prefix.$command" + $featurePrefix = git config --local --get "gitflow.prefix.$command" $branches = @(git branch --no-color | ForEach-Object { if ($_ -match "^\*?\s*$featurePrefix(?.*)") { $matches['ref'] } }) $branches | Where-Object { $_ -ne '(no branch)' -and $_ -like "$filter*" } | @@ -180,22 +182,22 @@ function script:expandGitAlias($cmd, $rest) { } } -function script:expandParams($cmd, $filter) { - $params[$cmd] -split ' ' | +function script:expandLongParams($cmd, $filter) { + $longGitParams[$cmd] -split ' ' | Where-Object { $_ -like "$filter*" } | Sort-Object | ForEach-Object { -join ("--", $_) } } function script:expandShortParams($cmd, $filter) { - $shortparams[$cmd] -split ' ' | + $shortGitParams[$cmd] -split ' ' | Where-Object { $_ -like "$filter*" } | Sort-Object | ForEach-Object { -join ("-", $_) } } function script:expandParamValues($cmd, $param, $filter) { - $paramvalues[$cmd][$param] -split ' ' | + $gitParamValues[$cmd][$param] -split ' ' | Where-Object { $_ -like "$filter*" } | Sort-Object | ForEach-Object { -join ("--", $param, "=", $_) } @@ -207,7 +209,7 @@ function GitTabExpansion($lastBlock) { } function GitTabExpansionInternal($lastBlock) { - $gitParams = '(?\s+-(?:[aA-zZ0-9]+|-[aA-zZ0-9][aA-zZ0-9-]*)(?:=\S+)?)*' + $ignoreGitParams = '(?\s+-(?:[aA-zZ0-9]+|-[aA-zZ0-9][aA-zZ0-9-]*)(?:=\S+)?)*' if ($lastBlock -match "^$(Get-AliasPattern git) (?\S+)(? .*)$") { $lastBlock = expandGitAlias $Matches['cmd'] $Matches['args'] @@ -236,9 +238,9 @@ function GitTabExpansionInternal($lastBlock) { gitCmdOperations $gitflowsubcommands $matches['cmd'] $matches['op'] } - # Handles git flow + # Handles git flow "^flow (?\S*)\s+(?\S*)\s+(?\S*)$" { - gitFeatures $matches['name'] $matches['command'] + gitFeatures $matches['name'] $matches['command'] } # Handles git remote (rename|rm|set-head|set-branches|set-url|show|prune) @@ -279,14 +281,14 @@ function GitTabExpansionInternal($lastBlock) { # Handles git push remote : # Handles git push remote +: - "^push${gitParams}\s+(?[^\s-]\S*).*\s+(?\+?)(?[^\s\:]*\:)(?\S*)$" { + "^push${ignoreGitParams}\s+(?[^\s-]\S*).*\s+(?\+?)(?[^\s\:]*\:)(?\S*)$" { gitRemoteBranches $matches['remote'] $matches['ref'] $matches['branch'] -prefix $matches['force'] } # Handles git push remote # Handles git push remote + # Handles git pull remote - "^(?:push|pull)${gitParams}\s+(?[^\s-]\S*).*\s+(?\+?)(?[^\s\:]*)$" { + "^(?:push|pull)${ignoreGitParams}\s+(?[^\s-]\S*).*\s+(?\+?)(?[^\s\:]*)$" { gitBranches $matches['ref'] -prefix $matches['force'] gitTags $matches['ref'] -prefix $matches['force'] } @@ -294,7 +296,7 @@ function GitTabExpansionInternal($lastBlock) { # Handles git pull # Handles git push # Handles git fetch - "^(?:push|pull|fetch)${gitParams}\s+(?\S*)$" { + "^(?:push|pull|fetch)${ignoreGitParams}\s+(?\S*)$" { gitRemotes $matches['remote'] } @@ -353,17 +355,17 @@ function GitTabExpansionInternal($lastBlock) { } # Handles git --= - "^(?$($someCommands -join '|')).* --(?[^=]+)=(?\S*)$" { + "^(?$someCommandsJoined).* --(?[^=]+)=(?\S*)$" { expandParamValues $matches['cmd'] $matches['param'] $matches['value'] } # Handles git -- - "^(?$($someCommands -join '|')).* --(?\S*)$" { - expandParams $matches['cmd'] $matches['param'] + "^(?$someCommandsJoined).* --(?\S*)$" { + expandLongParams $matches['cmd'] $matches['param'] } # Handles git - - "^(?$($someCommands -join '|')).* -(?\S*)$" { + "^(?$someCommandsJoined).* -(?\S*)$" { expandShortParams $matches['cmd'] $matches['shortparam'] } } From 48a10622f6c40ec3c6849cef1344b111a8e52b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Sat, 4 Feb 2017 22:49:05 +0100 Subject: [PATCH 22/23] closing braces are on a new line now --- src/GitParamTabExpansion.ps1 | 59 ++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/src/GitParamTabExpansion.ps1 b/src/GitParamTabExpansion.ps1 index 2072ee535..292b5de98 100644 --- a/src/GitParamTabExpansion.ps1 +++ b/src/GitParamTabExpansion.ps1 @@ -40,7 +40,7 @@ $shortparams = @{ $params = @{ add = 'dry-run verbose force interactive patch edit update all no-ignore-removal no-all ignore-removal intent-to-add refresh ignore-errors ignore-missing' bisect = 'no-checkout term-old term-new' - blame = 'root show-stats reverse porcelain line-porcelain incremental encoding= contents date score-debug show-name show-number show-email abbrev' + blame = 'root show-stats reverse porcelain line-porcelain incremental encoding= contents date score-debug show-name show-number show-email abbrev' branch = 'color no-color list abbrev= no-abbrev column no-column merged no-merged contains set-upstream track no-track set-upstream-to= unset-upstream edit-description delete create-reflog force move all verbose quiet' checkout = 'quiet force ours theirs track no-track detach orphan ignore-skip-worktree-bits merge conflict= patch' 'cherry-pick' = 'edit mainline no-commit signoff gpg-sign ff allow-empty allow-empty-message keep-redundant-commits strategy= strategy-option= ´continue quit abort' @@ -81,16 +81,21 @@ $params = @{ $paramvalues = @{ blame = @{ - encoding = 'utf-8 none' } + encoding = 'utf-8 none' + } branch = @{ color = 'always never auto' - abbrev = '7 8 9 10' } + abbrev = '7 8 9 10' + } checkout = @{ - conflict = 'merge diff3' } + conflict = 'merge diff3' + } 'cherry-pick' = @{ - strategy = 'resolve recursive octopus ours subtree' } + strategy = 'resolve recursive octopus ours subtree' + } commit = @{ - 'cleanup' = 'strip whitespace verbatim scissors default' } + 'cleanup' = 'strip whitespace verbatim scissors default' + } diff = @{ unified = '0 1 2 3 4 5' 'diff-algorithm' = 'default patience minimal histogram myers' @@ -99,45 +104,59 @@ $paramvalues = @{ abbrev = '7 8 9 10' 'diff-filter' = 'A C D M R T U X B *' 'inter-hunk-context' = '0 1 2 3 4 5' - 'ignore-submodules' = 'none untracked dirty all' } + 'ignore-submodules' = 'none untracked dirty all' + } difftool = @{ - tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' } + tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' + } fetch = @{ 'recurse-submodules' = 'yes on-demand no' - 'recurse-submodules-default' = 'yes on-demand' } + 'recurse-submodules-default' = 'yes on-demand' + } init = @{ - shared = 'false true umask group all world everybody o' } + shared = 'false true umask group all world everybody o' + } log = @{ decorate = 'short full no' 'no-walk' = 'sorted unsorted' pretty = 'oneline short medium full fuller email raw' format = 'oneline short medium full fuller email raw' encoding = 'UTF-8' - date = 'relative local default iso rfc short raw' } + date = 'relative local default iso rfc short raw' + } merge = @{ strategy = 'resolve recursive octopus ours subtree' - log = '1 2 3 4 5 6 7 8 9' } + log = '1 2 3 4 5 6 7 8 9' + } mergetool = @{ - tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' } + tool = 'vimdiff vimdiff2 araxis bc3 codecompare deltawalker diffmerge diffuse ecmerge emerge gvimdiff gvimdiff2 kdiff3 kompare meld opendiff p4merge tkdiff xxdiff' + } notes = @{ - strategy = 'manual ours theirs union cat_sort_uniq' } + strategy = 'manual ours theirs union cat_sort_uniq' + } pull = @{ strategy = 'resolve recursive octopus ours subtree' 'recurse-submodules' = 'yes on-demand no' 'no-recurse-submodules' = 'yes on-demand no' - rebase = 'false true preserve' } + rebase = 'false true preserve' + } push = @{ - 'recurse-submodules' = 'check on-demand' } + 'recurse-submodules' = 'check on-demand' + } rebase = @{ - strategy = 'resolve recursive octopus ours subtree' } + strategy = 'resolve recursive octopus ours subtree' + } revert = @{ - strategy = 'resolve recursive octopus ours subtree' } + strategy = 'resolve recursive octopus ours subtree' + } show = @{ pretty = 'oneline short medium full fuller email raw' format = 'oneline short medium full fuller email raw' - encoding = 'utf-8' } + encoding = 'utf-8' + } status = @{ 'untracked-files' = 'no normal all' - 'ignore-submodules' = 'none untracked dirty all' } + 'ignore-submodules' = 'none untracked dirty all' + } } From 51a78d0ee078d7a3f6bd6f180822c21449eb7ac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ralf=20M=C3=BCller?= Date: Mon, 6 Feb 2017 09:02:03 +0100 Subject: [PATCH 23/23] command lists are now precomputed --- src/GitTabExpansion.ps1 | 11 ++++++++--- src/posh-git.psm1 | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/GitTabExpansion.ps1 b/src/GitTabExpansion.ps1 index 56223e415..6e7622744 100644 --- a/src/GitTabExpansion.ps1 +++ b/src/GitTabExpansion.ps1 @@ -37,6 +37,11 @@ $script:someCommands = @('add','am','annotate','archive','bisect','blame','branc 'format-patch','gc','grep','gui','help','init','instaweb','log','merge','mergetool','mv', 'notes','prune','pull','push','rebase','reflog','remote','rerere','reset','revert','rm', 'shortlog','show','stash','status','submodule','svn','tag','whatchanged', 'worktree') + +$script:gitCommandsWithParams = $params.Keys -join '|' +$script:gitCommandsWithShortParams = $shortparams.Keys -join '|' +$script:gitCommandsWithParamValues = $paramvalues.Keys -join '|' + try { if ($null -ne (git help -a 2>&1 | Select-String flow)) { $script:someCommands += 'flow' @@ -353,17 +358,17 @@ function GitTabExpansionInternal($lastBlock) { } # Handles git --= - "^(?$($someCommands -join '|')).* --(?[^=]+)=(?\S*)$" { + "^(?$($gitCommandsWithParamValues)).* --(?[^=]+)=(?\S*)$" { expandParamValues $matches['cmd'] $matches['param'] $matches['value'] } # Handles git -- - "^(?$($someCommands -join '|')).* --(?\S*)$" { + "^(?$($gitCommandsWithParams)).* --(?\S*)$" { expandParams $matches['cmd'] $matches['param'] } # Handles git - - "^(?$($someCommands -join '|')).* -(?\S*)$" { + "^(?$($gitCommandsWithShortParams)).* -(?\S*)$" { expandShortParams $matches['cmd'] $matches['shortparam'] } } diff --git a/src/posh-git.psm1 b/src/posh-git.psm1 index c7c6086bb..3d907fba4 100644 --- a/src/posh-git.psm1 +++ b/src/posh-git.psm1 @@ -16,8 +16,8 @@ if ($psv.Major -lt 3 -and !$NoVersionWarn) { . $PSScriptRoot\Utils.ps1 . $PSScriptRoot\GitUtils.ps1 . $PSScriptRoot\GitPrompt.ps1 -. $PSScriptRoot\GitTabExpansion.ps1 . $PSScriptRoot\GitParamTabExpansion.ps1 +. $PSScriptRoot\GitTabExpansion.ps1 . $PSScriptRoot\TortoiseGit.ps1 if (!$Env:HOME) { $Env:HOME = "$Env:HOMEDRIVE$Env:HOMEPATH" }