Subject: Re: Additional plumbing commands

From: Jeff King <[email-masked]>
Date: Wed, 7 Jan 2015 03:04:09 -0500

On Tue, Jan 06, 2015 at 06:37:34PM +0100, Christian Couder wrote:

> On Tue, Jan 6, 2015 at 5:05 PM, Charles Rudolph
> <[email-masked]> wrote:
> > I am writing some higher level git commands for
> > https://github.com/Originate/git-town and would like some additional
> > plumbing commands that can tell me
> >
> > 1. is there a merge in progress?
> > 2. is there a rebase in progress?
> > 3. is there a cherry-pick in progress?
> > 4. are there unmerged paths?
> >
> > Currently the only way I know how to do this is with "git status" and
> > looking for specific text.
> 
> You may have a look at how "contrib/completion/git-prompt.sh" does it.
> [...]

The prompt code is rather long and knows a lot about the internal state
of $GIT_DIR. I do not think it would be a bad thing for git-status to
expose a machine-readable version of the state it discovers, and then at
least we can keep the logic in one place.

Charles, if you are interested in adding that, the wt_status_state code
in wt-status.c is the right place to start looking.

Though I think in many cases that discovering which state we are in is
only half the story that a caller wants. Knowing what each state _means_
and what operations are meaningful to perform is much trickier (e.g., if
we are in a rebase, you probably do not want to start a new rebase. But
is it wrong to cherry-pick?).

It would be nice if we could find a way to generalize in-progress
operations and what they mean for starting new operations, but that is
a much harder problem (if it is even possible at all).

-Peff