threads / discuss / 49935

Confusing inconsistent option syntax

Subject: Confusing inconsistent option syntax

## tl;dr

3 messages between Dec 2, 2018 and Dec 3, 2018.

replies: 2people: 3as markdown or json

Robert White· Dec 2, 2018, 10:07 UTC · lore

`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

Duy Nguyen· Dec 2, 2018, 10:18 UTC · re: Robert White · lore

Re: Confusing inconsistent option syntax

On Sun, Dec 2, 2018 at 11:13 AM Robert White <rjwhite2453@gmail.com> wrote:
Show 7 quoted lines
>
> `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.

-- 
Duy
Jeff King· Dec 3, 2018, 22:14 UTC · re: Robert White · lore

Re: Confusing inconsistent option syntax

On Sun, Dec 02, 2018 at 09:07:47PM +1100, Robert White wrote:
Show 6 quoted lines
> `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

← back to recent threads