Skip to contentSkip to conversation

Confusing inconsistent option syntax

DISCUSSION Robert White 3 participants 3 messages Dec 2, 2018 – Dec 3, 2018

lore
Share & tools
lore
#0 lore raw

git log --pretty short gives the error message "ambiguous argument 'short'". To get the expected result, you need to use git log --pretty=short. However, git log --since yesterday and git log --since=yesterday both work as expected.

When is an = needed? What is the reason for these inconsistencies?

---
Robert White

#1 lore raw
Quoted 7 lines · Robert White

git log --pretty short gives the error message "ambiguous argument 'short'". To get the expected result, you need to use git log --pretty=short. However, git log --since yesterday and git log --since=yesterday both work as expected.

When is an = needed? What is the reason for these inconsistencies?

--pretty can take no arguments. --pretty alone is the same as --pretty=medium. --since always needs an argument.

Signature · 1 line
Duy
#2 lore raw
In reply to Robert White
Quoted 6 lines · Robert White

git log --pretty short gives the error message "ambiguous argument 'short'". To get the expected result, you need to use git log --pretty=short. However, git log --since yesterday and git log --since=yesterday both work as expected.

When is an = needed? What is the reason for these inconsistencies?

As Duy mentioned, this has to do with optional arguments for some flags. This is discussed in more detail in "git help cli". Notably (and as advised in that manpage), you should always use the "stuck" form (with the "=") in scripts, in case a flag grows an optional value later.

-Peff