git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Additional plumbing commands

From
Jeff King <peff@peff.net>
Date
Jan 7, 2015, 08:04 UTC
Message-ID
<20150107080408.GA1301@peff.net>
In-Reply-To
<CAP8UFD1OZ1QjHRyNGVs0Vm52=Ue-ta1gBzNxLpX25NSCbtu9EQ@mail.gmail.com>
On Tue, Jan 06, 2015 at 06:37:34PM +0100, Christian Couder wrote:
Show 16 quoted lines
> On Tue, Jan 6, 2015 at 5:05 PM, Charles Rudolph
> <charles.w.rudolph@gmail.com> 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
Previous: Christian CouderNext: Junio C Hamano
Message 3 of 4 in “Additional plumbing commands”
  1. Charles RudolphJan 6, 2015
  2. Christian CouderJan 6, 2015
  3. Jeff KingJan 7, 2015
  4. Junio C HamanoJan 7, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.