Re: git-status -- trying to understand all possible states
From: Junio C Hamano <hidden>
Date: 2016-06-15 23:00:37
Michael Toy [off-list ref] writes:
Of the 24 possibilities (not counting ignored) in git-status, there are 7 that I can't figure out how to generate.
As the post [*1*] that triggered e92e9cd3 (Documentation improvements for the description of short format., 2010-04-23), which is where the bulk of the format description comes from, says, this is "Patches welcome" ;-) Some are just covering possible permutations and it is not surprising if they would not appear in practice.
D M deleted from index
I doubt this is possible in practice; once you do not have the entry in the index, we do not even look at the working tree file, so it would be unusual to see M in the second column.
D D unmerged, both deleted A U unmerged, added by us U A unmerged, added by them
$ x="100644 $(git hash-object --stdin </dev/null)" &&
printf "$x 2\tbar\n$x 1\tfoo\n$x 3\tbaz" |
git update-index --index-info
$ git status --short -suno
AU bar
UA baz
DD foo
$ git ls-files -u
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 2 bar
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 3 baz
100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 1 foo
When you are using higher-level machinery to merge, "we added, they
left it missing" (i.e. bar that has only stage #2) is automatically
resolved to an addition by the trivial merge machinery. The "they
added, we left it missing" (i.e. baz with only stage #3) case is
identical. Also "both of us removed" (i.e. foo that has only stage
#1) is resolved to a deletion by the trivial merge machinery. Hence
you would not see these three unless you are developing Git using a
low-level plumbing machinery.
[Reference]
*1* http://thread.gmane.org/gmane.comp.version-control.git/144455/focus=144468