Reputation: 707
There is a pattern in the Unix CLI world where frequently-used options are given a single-letter shorthand, and these can usually be combined together, or stacked. A very common example of this can be found with the rm
command, which can remove directories recursively. These three commands are equivalent:
rm --recursive --force .
rm -r -f .
rm -rf .
Git has many sub-commands, each with many options. I've become used to Git allowing its shorthand options to be stacked for ease of use, like many other well-written CLI tools. For example:
git commit -am 'Create new commit message'
I've found that git stash
is at least one exception, where the shorthands for the useful options --keep-index
and --include-untracked
cannot be stacked into -ku
:
git stash -k -u # This works
git stash -ku # This doesn't
Is there a specific reason for this, other than that it hasn't been implemented? Are there other examples where Git options can't be stacked, and do these examples have specific reasons?
Upvotes: 2
Views: 48
Reputation: 489708
In all but very recent versions of Git, git stash
has been a shell script that (for whatever reason) didn't use Git's option parser. Starting in Git 2.22, there was a project to rewrite it in C. The C rewrite has a proper option parser. The rewrite, however, wasn't quite done until recently, and the old shell script version was still around.
As you reported in a comment, git stash -ku
does work in Git 2.27, but not in Git 2.25. Git 2.27 is the first version in which the old shell script version is truly gone; probably this is when the option parsing was finally switched over as well.
Upvotes: 3