git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Phil Hord <hordp@cisco.com>
Cc: git@vger.kernel.org, phil.hord@gmail.com,
	Junio C Hamano <gitster@pobox.com>,
	konglu@minatec.inpg.fr,
	Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
	Kong Lucien <Lucien.Kong@ensimag.imag.fr>,
	Duperray Valentin <Valentin.Duperray@ensimag.imag.fr>,
	Jonas Franck <Franck.Jonas@ensimag.imag.fr>,
	Nguy Thomas <Thomas.Nguy@ensimag.imag.fr>,
	Nguyen Huynh Khoi Nguyen 
	<Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr>
Subject: Re: [PATCHv2] git-status: show short sequencer state
Date: Thu, 25 Oct 2012 05:29:19 -0400	[thread overview]
Message-ID: <20121025092919.GG8390@sigill.intra.peff.net> (raw)
In-Reply-To: <1351022574-27869-2-git-send-email-hordp@cisco.com>

On Tue, Oct 23, 2012 at 04:02:54PM -0400, Phil Hord wrote:

> Teach git-status to report the sequencer state in short form
> using a new --sequencer (-S) switch.  Output zero or more
> simple state token strings indicating the deduced state of the
> git sequencer.
> 
> Introduce a common function to determine the current sequencer
> state so the regular status function and this short version can
> share common code.
> 
> Add a substate to wt_status_state to track more detailed
> information about a state, such as "conflicted" or "resolved".
> Move the am_empty_patch flage out of wt_status_state and into

This patch ended up quite long. It might be a little easier to review
if it were broken into refactoring steps (I have not looked at it too
closely yet, but it seems like the three paragraphs above could each be
their own commit).

> State token strings which may be emitted and their meanings:
>     merge              a git-merge is in progress
>     am                 a git-am is in progress
>     rebase             a git-rebase is in progress
>     rebase-interactive a git-rebase--interactive is in progress

A minor nit, but you might want to update this list from the one in the
documentation.

> diff --git a/builtin/commit.c b/builtin/commit.c
> index a17a5df..9706ed9 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -114,7 +114,8 @@ static struct strbuf message = STRBUF_INIT;
>  static enum {
>  	STATUS_FORMAT_LONG,
>  	STATUS_FORMAT_SHORT,
> -	STATUS_FORMAT_PORCELAIN
> +	STATUS_FORMAT_PORCELAIN,
> +	STATUS_FORMAT_SEQUENCER
>  } status_format = STATUS_FORMAT_LONG;

Hmm. So the new format is its own distinct output format. I could not
say "I would like to see short status, and by the way, show me the
sequencer state", as you can with "-b". Is it possible to do this (or
even desirable; getting the sequencer state should be way cheaper, so
conflating the two may not be what some callers want).

Not complaining, just wondering about the intended use cases.

Also, does there need to be a --porcelain version of this output? It
seems like we can have multiple words (e.g., in a merge, with conflicted
entries). If there is no arbitrary data, we do not have to worry about
delimiters and quoting.  But I wonder if we would ever want to expand
the information to include arbitrary strings, at which point we would
want NUL delimiters; should we start with that now?

> +	// Determine main sequencer activity

Please avoid C99 comments (there are others in the patch, too).

> +void wt_sequencer_print(struct wt_status *s)
> +{
> +	struct wt_status_state state;
> +
> +	wt_status_get_state(s, &state);
> +
> +	if (state.merge_in_progress)
> +		wt_print_token(s, "merge");
> +	if (state.am_in_progress)
> +		wt_print_token(s, "am");
> +	if (state.rebase_in_progress)
> +		wt_print_token(s, "rebase");
> +	if (state.rebase_interactive_in_progress)
> +		wt_print_token(s, "rebase-interactive");
> +	if (state.cherry_pick_in_progress)
> +		wt_print_token(s, "cherry-pick");
> +	if (state.bisect_in_progress)
> +		wt_print_token(s, "bisect");
> +
> +	switch (state.substate) {
> +	case WT_SUBSTATE_NOMINAL:
> +		break;
> +	case WT_SUBSTATE_CONFLICTED:
> +		wt_print_token(s, "conflicted");
> +		break;
> +	case WT_SUBSTATE_RESOLVED:
> +		wt_print_token(s, "resolved");
> +		break;
> +	case WT_SUBSTATE_EDITED:
> +		wt_print_token(s, "edited");
> +		break;
> +	case WT_SUBSTATE_EDITING:
> +		wt_print_token(s, "editing");
> +		break;
> +	case WT_SUBSTATE_SPLITTING:
> +		wt_print_token(s, "splitting");
> +		break;
> +	case WT_SUBSTATE_AM_EMPTY:
> +		wt_print_token(s, "am-empty");
> +		break;
> +	}
> +}

It is clear from this code that some tokens can happen together, and
some are mutually exclusive. Should the documentation talk about that,
or do we want to literally keep it as a list of tags?

-Peff

  reply	other threads:[~2012-10-25  9:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 20:02 [PATCHv2] git-status: show short sequencer state Phil Hord
2012-10-23 20:02 ` Phil Hord
2012-10-25  9:29   ` Jeff King [this message]
2012-10-25 16:05     ` Phil Hord
2012-10-29 18:05       ` Phil Hord
2012-10-29 21:41         ` Jeff King
2012-10-29 22:26           ` Phil Hord
2012-10-29 23:31             ` [PATCHv2 0/3] git-status short sequencer state info Phil Hord
2012-10-29 23:31               ` [PATCHv2 1/3] Refactor print_state into get_state Phil Hord
2012-10-29 23:31               ` [PATCHv2 2/3] wt-status: More state retrieval abstraction Phil Hord
2012-10-29 23:31               ` [PATCHv2 3/3] git-status: show short sequencer state Phil Hord
2012-11-09 18:56               ` [PATCHv3 0/4] git-status short sequencer state info Phil Hord
2012-11-09 18:56                 ` [PATCHv3 1/4] Refactor print_state into get_state Phil Hord
2012-11-12 18:29                   ` Ramkumar Ramachandra
2012-11-09 18:56                 ` [PATCHv3 2/4] wt-status: Teach sequencer advice to use get_state Phil Hord
2012-11-09 18:56                 ` [PATCHv3 3/4] git-status: show short sequencer state Phil Hord
2012-11-12 17:45                   ` Junio C Hamano
2012-11-12 18:14                     ` Phil Hord
2012-11-13 23:50                       ` Phil Hord
2012-11-14 13:29                         ` Junio C Hamano
2012-11-14 13:44                           ` Phil Hord
2012-11-14 17:44                             ` Junio C Hamano
2012-11-14 19:14                               ` Phil Hord
2012-11-14 19:35                                 ` Junio C Hamano
2012-11-14 19:57                                   ` Junio C Hamano
2012-11-09 18:56                 ` [PATCHv3 4/4] Add tests for git-status --sequencer Phil Hord

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121025092919.GG8390@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Franck.Jonas@ensimag.imag.fr \
    --cc=Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr \
    --cc=Lucien.Kong@ensimag.imag.fr \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=Thomas.Nguy@ensimag.imag.fr \
    --cc=Valentin.Duperray@ensimag.imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hordp@cisco.com \
    --cc=konglu@minatec.inpg.fr \
    --cc=phil.hord@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).