All of lore.kernel.org
 help / color / mirror / Atom feed
* git-status -- trying to understand all possible states
@ 2014-04-01 20:07 Michael Toy
  2014-04-01 21:37 ` Junio C Hamano
  2014-04-01 22:20 ` Jonathan Nieder
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Toy @ 2014-04-01 20:07 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-status -- trying to understand all possible states
  2014-04-01 20:07 git-status -- trying to understand all possible states Michael Toy
@ 2014-04-01 21:37 ` Junio C Hamano
  2014-04-01 23:01   ` Michael Toy
  2014-04-01 22:20 ` Jonathan Nieder
  1 sibling, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2014-04-01 21:37 UTC (permalink / raw)
  To: Michael Toy; +Cc: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-status -- trying to understand all possible states
  2014-04-01 20:07 git-status -- trying to understand all possible states Michael Toy
  2014-04-01 21:37 ` Junio C Hamano
@ 2014-04-01 22:20 ` Jonathan Nieder
  2014-04-02  8:31   ` Matthieu Moy
  1 sibling, 1 reply; 5+ messages in thread
From: Jonathan Nieder @ 2014-04-01 22:20 UTC (permalink / raw)
  To: Michael Toy; +Cc: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-status -- trying to understand all possible states
  2014-04-01 21:37 ` Junio C Hamano
@ 2014-04-01 23:01   ` Michael Toy
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Toy @ 2014-04-01 23:01 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-status -- trying to understand all possible states
  2014-04-01 22:20 ` Jonathan Nieder
@ 2014-04-02  8:31   ` Matthieu Moy
  0 siblings, 0 replies; 5+ messages in thread
From: Matthieu Moy @ 2014-04-02  8:31 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Michael Toy, git

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-03  9:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-01 20:07 git-status -- trying to understand all possible states Michael Toy
2014-04-01 21:37 ` Junio C Hamano
2014-04-01 23:01   ` Michael Toy
2014-04-01 22:20 ` Jonathan Nieder
2014-04-02  8:31   ` Matthieu Moy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.