# git-status -- trying to understand all possible states

5 messages from 2014-04-01 to 2014-04-02. Participants: Michael Toy, Junio C Hamano, Jonathan Nieder, Matthieu Moy.
Thread: https://gitlist.dev/t/36336

## Michael Toy, 2014-04-01 20:07

Subject: git-status -- trying to understand all possible states
Message-ID: <4AF06B83-E928-4FE2-8094-F23CE3BA1EBC@toyland.org>
URL: https://gitlist.dev/e/4AF06B83-E928-4FE2-8094-F23CE3BA1EBC%40toyland.org

```
I also have this question posted to stack overflow ( http://stackoverflow.com/questions/22792906/how-do-i-produce-every-possible-git-status ), but perhaps this is a better place to ask this question.

In working on some code which provides an interface to existing git repositories the question I had was "what actions should I present to a user", which lead to the question, "what does a user need to do to generate that condition", which lead to developing this gist:

https://gist.github.com/the-michael-toy/9907309

... which is a ruby script which tries to produce a repository with a file in every possible "git-status" XY condition

Of the 24 possibilities (not counting ignored) in git-status, there are 7 that I can't figure out how to generate.

D           M    deleted from index
C        [ MD]   copied in index
D           D    unmerged, both deleted
A           U    unmerged, added by us
U           A    unmerged, added by them

any clues, including pointers to "just go read XXX" would be appreciated.

```

## Junio C Hamano, 2014-04-01 21:37

Subject: Re: git-status -- trying to understand all possible states
Message-ID: <xmqq4n2czq6n.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq4n2czq6n.fsf%40gitster.dls.corp.google.com
In-Reply-To: <4AF06B83-E928-4FE2-8094-F23CE3BA1EBC@toyland.org>

```
Michael Toy <michael@toyland.org> 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

```

## Jonathan Nieder, 2014-04-01 22:20

Subject: Re: git-status -- trying to understand all possible states
Message-ID: <20140401222002.GD6851@google.com>
URL: https://gitlist.dev/e/20140401222002.GD6851%40google.com
In-Reply-To: <4AF06B83-E928-4FE2-8094-F23CE3BA1EBC@toyland.org>

```
Michael Toy wrote:

> https://gist.github.com/the-michael-toy/9907309

Two nits:

 - Please use --porcelain (implied by -z in the absence of another
   format option) instead of --short.  --short is meant to be human
   readable and details of the output might change some day.

 - Depending on what you're trying to do, you might find the output
   from other commands such as "git ls-files -s" or "git diff-files"
   easier to work with.

Hope that helps,
Jonathan

```

## Michael Toy, 2014-04-01 23:01

Subject: Re: git-status -- trying to understand all possible states
Message-ID: <1DC6FC8F-3CF8-4DDF-8B34-9349E8289C47@toyland.org>
URL: https://gitlist.dev/e/1DC6FC8F-3CF8-4DDF-8B34-9349E8289C47%40toyland.org
In-Reply-To: <xmqq4n2czq6n.fsf@gitster.dls.corp.google.com>

```
On Apr 1, 2014, at 2:37 PM, Junio C Hamano <gitster@pobox.com> wrote:

>> D           M    deleted from index
> 
> I doubt this is possible in practice ...
> 
>> D           D    unmerged, both deleted
>> A           U    unmerged, added by us
>> U           A    unmerged, added by them
> 
>   ... you would not see these three unless you are developing Git using a
> low-level plumbing machinery.

Thanks, that is very helpful.

The "C[ MD]" are now the remaining mystery

```

## Matthieu Moy, 2014-04-02 08:31

Subject: Re: git-status -- trying to understand all possible states
Message-ID: <vpqd2h0gmj2.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqd2h0gmj2.fsf%40anie.imag.fr
In-Reply-To: <20140401222002.GD6851@google.com>

```
Jonathan Nieder <jrnieder@gmail.com> writes:

>  - Please use --porcelain (implied by -z in the absence of another
>    format option) instead of --short.  --short is meant to be human
>    readable and details of the output might change some day.

It already does: part of the output may be translated to non-english.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```
