@@ -90,18 +90,42 @@ def _add_hook_type_option(parser: argparse.ArgumentParser) -> None:
9090def _add_run_options (parser : argparse .ArgumentParser ) -> None :
9191 parser .add_argument ('hook' , nargs = '?' , help = 'A single hook-id to run' )
9292 parser .add_argument ('--verbose' , '-v' , action = 'store_true' , default = False )
93+ mutex_group = parser .add_mutually_exclusive_group (required = False )
94+ mutex_group .add_argument (
95+ '--all-files' , '-a' , action = 'store_true' , default = False ,
96+ help = 'Run on all the files in the repo.' ,
97+ )
98+ mutex_group .add_argument (
99+ '--files' , nargs = '*' , default = [],
100+ help = 'Specific filenames to run hooks on.' ,
101+ )
102+ parser .add_argument (
103+ '--show-diff-on-failure' , action = 'store_true' ,
104+ help = 'When hooks fail, run `git diff` directly afterward.' ,
105+ )
106+ parser .add_argument (
107+ '--hook-stage' , choices = C .STAGES , default = 'commit' ,
108+ help = 'The stage during which the hook is fired. One of %(choices)s' ,
109+ )
93110 parser .add_argument (
94- '--origin ' , '-o ' ,
111+ '--from-ref ' , '--source' , '-s ' ,
95112 help = (
96- "The origin branch's commit_id when using `git push`. "
97- 'The ref of the previous HEAD when using `git checkout`.'
113+ '(for usage with `--from-ref`) -- this option represents the '
114+ 'destination ref in a `from_ref...to_ref` diff expression. '
115+ 'For `pre-push` hooks, this represents the branch being pushed. '
116+ 'For `post-checkout` hooks, this represents the branch that is '
117+ 'now checked out.'
98118 ),
99119 )
100120 parser .add_argument (
101- '--source ' , '-s ' ,
121+ '--to-ref ' , '--origin' , '-o ' ,
102122 help = (
103- "The remote branch's commit_id when using `git push`. "
104- 'The ref of the new HEAD when using `git checkout`.'
123+ '(for usage with `--to-ref`) -- this option represents the '
124+ 'original ref in a `from_ref...to_ref` diff expression. '
125+ 'For `pre-push` hooks, this represents the branch you are pushing '
126+ 'to. '
127+ 'For `post-checkout` hooks, this represents the branch which was '
128+ 'previously checked out.'
105129 ),
106130 )
107131 parser .add_argument (
@@ -112,23 +136,6 @@ def _add_run_options(parser: argparse.ArgumentParser) -> None:
112136 '--remote-name' , help = 'Remote name used by `git push`.' ,
113137 )
114138 parser .add_argument ('--remote-url' , help = 'Remote url used by `git push`.' )
115- parser .add_argument (
116- '--hook-stage' , choices = C .STAGES , default = 'commit' ,
117- help = 'The stage during which the hook is fired. One of %(choices)s' ,
118- )
119- parser .add_argument (
120- '--show-diff-on-failure' , action = 'store_true' ,
121- help = 'When hooks fail, run `git diff` directly afterward.' ,
122- )
123- mutex_group = parser .add_mutually_exclusive_group (required = False )
124- mutex_group .add_argument (
125- '--all-files' , '-a' , action = 'store_true' , default = False ,
126- help = 'Run on all the files in the repo.' ,
127- )
128- mutex_group .add_argument (
129- '--files' , nargs = '*' , default = [],
130- help = 'Specific filenames to run hooks on.' ,
131- )
132139 parser .add_argument (
133140 '--checkout-type' ,
134141 help = (
0 commit comments