1

I know the escape character is (`), the backtick, but even if I try to use it toe escape the < characters I get error...

git log ORIG_HEAD --no-merges --date=short --pretty="format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>" > test.txt
< was unexpected at this time.

How can I go about formatting my git log as above?

1 Answer 1

3

If on PowerShell v3 try this:

$out = git log ORIG_HEAD --% --no-merges --date=short --pretty="format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>"
$out > test.txt

The --% puts PowerShell into a different parsing mode more suitable for native executables. See this blog post for more details.

If you're not using PowerShell v3, I suggest you use echoargs from the PowerShell Community Extensions to see the arguments as git.exe receives them from PowerShell e.g.:

PS> echoargs log ORIG_HEAD --no-merges --date=short --pretty="format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>"
Arg 0 is <log>
Arg 1 is <ORIG_HEAD>
Arg 2 is <--no-merges>
Arg 3 is <--date=short>
Arg 4 is <--pretty=format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>>

Command line:
"C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx\Apps\EchoArgs.exe"  log ORIG_HEAD --no-merges --date=short --pretty=format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>

If you can see how PowerShell is passing the arguments to the exe you have a fighting chance to figure out how to massage the arguments which usually involves using extra quotes.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry, This is powershell 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.