@@ -159,36 +159,37 @@ export async function runGitCli(
159159// actually accepts are listed: the whole point is to tell a caller what
160160// works here, rather than what real git would take.
161161const COMMAND_USAGE : Record < string , string > = {
162- add : "git add [-A] <path>..." ,
163- branch : "git branch [-d|-D <name> ] [--show-current] [<name>]" ,
162+ add : "git add [-A|--all] [-f|--force ] <path>..." ,
163+ branch : "git branch [-d|-D|--delete] [-f|--force ] [--show-current] [<name>]" ,
164164 "cat-file" : "git cat-file (-p|-t|-s) <oid>[:<path>]" ,
165- checkout : "git checkout [-b <name> ] [-f] <ref> [--] [<path>...]" ,
166- clean : "git clean [-f] [-d] [-n] [<path>...]" ,
165+ checkout : "git checkout [-b] [-f|--force ] <ref> [--] [<path>...]" ,
166+ clean : "git clean [-f|--force ] [-d] [-n|--dry-run ] [<path>...]" ,
167167 clone :
168- "git clone [--depth <n>] [--branch <ref>] [--single-branch|--no-single-branch] <url> [<dir>]" ,
169- commit : "git commit -m <message> [-a]" ,
170- config : "git config [--get] <key> [<value>]" ,
171- diff : "git diff [--stat] [--name-only] [<ref>] [--] [<path>...]" ,
172- fetch : "git fetch [<remote>] [<ref>]" ,
173- "hash-object" : "git hash-object [-w] [-t <type>] <path>" ,
174- init : "git init [<dir>]" ,
175- log : "git log [-n <count>] [-<count>] [--oneline] [<ref>]" ,
176- "ls-files" : "git ls-files [<ref>]" ,
168+ "git clone [--depth <n>] [-b|--branch <ref>] [--single-branch|--no-single-branch] [--tags|--no-tags] <url> [<dir>]" ,
169+ commit : 'git commit -m|--message <message> [-a|--all] [--amend] [--author "Name <email>"]' ,
170+ config : "git config [--get|--get-all|--add|--unset] <key> [<value>]" ,
171+ diff : "git diff [--stat] [--name-only] [--name-status] [<ref>] [--] [<path>...]" ,
172+ fetch :
173+ "git fetch [--depth <n>] [--single-branch|--no-single-branch] [--tags|--no-tags] [--prune] [<remote>] [<ref>]" ,
174+ "hash-object" : "git hash-object --stdin [-w]" ,
175+ init : "git init [-b|--initial-branch <name>] [--bare] [<dir>]" ,
176+ log : "git log [-n <count>] [-<count>] [--oneline] [--format|--pretty=<spec>] [<ref>]" ,
177+ "ls-files" : "git ls-files [--ref <ref>]" ,
177178 "ls-tree" : "git ls-tree <ref> [<path>]" ,
178- merge : "git merge [--ff-only] [--no-ff] <ref>" ,
179- pull : "git pull [<remote>] [<ref>]" ,
180- push : "git push [-f|--force] [--delete] [<remote>] [<refspec>]" ,
181- remote : "git remote [-v] [ add <name> <url>] [remove <name>]" ,
182- reset : "git reset [--hard|--soft|--mixed ] [<ref>] [--] [<path>...]" ,
183- "rev-parse" : "git rev-parse <rev>" ,
184- rm : "git rm [--cached] [-r] <path>..." ,
179+ merge : "git merge [--ff-only] [--no-ff] [-m|--message <message>] <ref>" ,
180+ pull : "git pull [--ff-only] [--no-ff] [ <remote>] [<ref>]" ,
181+ push : "git push [-f|--force] [-d|- -delete] [<remote>] [<refspec>]" ,
182+ remote : "git remote [add <name> <url>] [remove <name>]" ,
183+ reset : "git reset [--hard] [<ref>] [--] [<path>...]" ,
184+ "rev-parse" : "git rev-parse [--abbrev-ref] [--show-toplevel] <rev>" ,
185+ rm : "git rm [--cached] <path>..." ,
185186 show : "git show [<ref>]" ,
186187 stash : "git stash [push|pop|apply|list|drop]" ,
187- status : "git status [-s|--short| --porcelain]" ,
188- switch : "git switch [-c <name> ] <ref>" ,
189- "symbolic-ref" : "git symbolic-ref <name> [<ref>]" ,
190- tag : "git tag [-d <name> ] [<name> [<ref>]]" ,
191- "update-ref" : "git update-ref <ref> <oid>" ,
188+ status : "git status [-s|--short] [ --porcelain[=<version>] ]" ,
189+ switch : "git switch [-c] <ref>" ,
190+ "symbolic-ref" : "git symbolic-ref [--short] [-q|--quiet] <name> [<ref>]" ,
191+ tag : "git tag [-d|--delete] [-f|--force ] [<name> [<ref>]]" ,
192+ "update-ref" : "git update-ref [--force] <ref> <oid>" ,
192193 help : "git help [<command>]" ,
193194 version : "git version" ,
194195} ;
@@ -814,19 +815,25 @@ async function runLog(
814815 shorthandDepth = m [ 1 ] ;
815816 continue ;
816817 }
818+ // --pretty is the same option as --format in real git. Normalize it
819+ // to the one key so the parser's last-write behavior decides which
820+ // wins: a caller appending an override to a command it did not build
821+ // gets the last one written, whichever spelling either of them used.
822+ if ( arg === "--pretty" || arg . startsWith ( "--pretty=" ) ) {
823+ rewritten . push ( `--format${ arg . slice ( "--pretty" . length ) } ` ) ;
824+ continue ;
825+ }
817826 rewritten . push ( arg ) ;
818827 }
819828 const parsed = parseFlags ( rewritten , {
820829 n : { kind : "value" } ,
821830 oneline : { kind : "bool" } ,
822831 format : { kind : "value" } ,
823- pretty : { kind : "value" } ,
824832 } ) ;
825833 if ( "error" in parsed ) {
826834 return { stdout : "" , stderr : `git log: ${ parsed . error } \n` , exitCode : 129 } ;
827835 }
828- // --pretty and --format are the same option in real git.
829- const formatSpec = ( parsed . flags . format ?? parsed . flags . pretty ) as string | undefined ;
836+ const formatSpec = parsed . flags . format as string | undefined ;
830837 if ( formatSpec !== undefined && parsed . flags . oneline === true ) {
831838 return {
832839 stdout : "" ,
0 commit comments