git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Phil Hord <hordp@cisco.com>
To: git@vger.kernel.org
Cc: phil.hord@gmail.com, Jeff King <peff@peff.net>,
	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>,
	Phil Hord <hordp@cisco.com>
Subject: [PATCHv3 2/4] wt-status: Teach sequencer advice to use get_state
Date: Fri,  9 Nov 2012 13:56:23 -0500	[thread overview]
Message-ID: <1352487385-5929-3-git-send-email-hordp@cisco.com> (raw)
In-Reply-To: <1352487385-5929-1-git-send-email-hordp@cisco.com>

wt_status_print_state retrieves some sequencer state information via
wt_status_get_state, but other state information it deduces on its
own.  Replace these "local knowledge" deductions with wt_status
variables so we can share more common code in the future.
---
 wt-status.c | 16 +++++++++-------
 wt-status.h |  3 +++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 760f52b..a888120 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -781,7 +781,7 @@ static void show_merge_in_progress(struct wt_status *s,
 				struct wt_status_state *state,
 				const char *color)
 {
-	if (has_unmerged(s)) {
+	if (state->has_unmerged) {
 		status_printf_ln(s, color, _("You have unmerged paths."));
 		if (advice_status_hints)
 			status_printf_ln(s, color,
@@ -867,9 +867,7 @@ static void show_rebase_in_progress(struct wt_status *s,
 				struct wt_status_state *state,
 				const char *color)
 {
-	struct stat st;
-
-	if (has_unmerged(s)) {
+	if (state->has_unmerged) {
 		status_printf_ln(s, color, _("You are currently rebasing."));
 		if (advice_status_hints) {
 			status_printf_ln(s, color,
@@ -879,12 +877,12 @@ static void show_rebase_in_progress(struct wt_status *s,
 			status_printf_ln(s, color,
 				_("  (use \"git rebase --abort\" to check out the original branch)"));
 		}
-	} else if (state->rebase_in_progress || !stat(git_path("MERGE_MSG"), &st)) {
+	} else if (state->rebase_in_progress || state->commit_is_pending) {
 		status_printf_ln(s, color, _("You are currently rebasing."));
 		if (advice_status_hints)
 			status_printf_ln(s, color,
 				_("  (all conflicts fixed: run \"git rebase --continue\")"));
-	} else if (split_commit_in_progress(s)) {
+	} else if (state->split_in_progress) {
 		status_printf_ln(s, color, _("You are currently splitting a commit during a rebase."));
 		if (advice_status_hints)
 			status_printf_ln(s, color,
@@ -907,7 +905,7 @@ static void show_cherry_pick_in_progress(struct wt_status *s,
 {
 	status_printf_ln(s, color, _("You are currently cherry-picking."));
 	if (advice_status_hints) {
-		if (has_unmerged(s))
+		if (state->has_unmerged)
 			status_printf_ln(s, color,
 				_("  (fix conflicts and run \"git commit\")"));
 		else
@@ -955,6 +953,10 @@ static void wt_status_get_state(struct wt_status *s , struct wt_status_state *st
 	}
 	if (!stat(git_path("BISECT_LOG"), &st))
 		state->bisect_in_progress = 1;
+
+	state->has_unmerged = has_unmerged(s);
+	state->split_in_progress = split_commit_in_progress(s);
+	state->commit_is_pending = !stat(git_path("MERGE_MSG"), &st);
 }
 
 static void wt_status_print_state(struct wt_status *s)
diff --git a/wt-status.h b/wt-status.h
index 236b41f..0b866a2 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -79,6 +79,9 @@ struct wt_status_state {
 	int rebase_interactive_in_progress;
 	int cherry_pick_in_progress;
 	int bisect_in_progress;
+	int split_in_progress;
+	int has_unmerged;
+	int commit_is_pending;
 };
 
 void wt_status_prepare(struct wt_status *s);
-- 
1.8.0.3.gde9c7d5.dirty

  parent reply	other threads:[~2012-11-09 18:57 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
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                 ` Phil Hord [this message]
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=1352487385-5929-3-git-send-email-hordp@cisco.com \
    --to=hordp@cisco.com \
    --cc=Franck.Jonas@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=konglu@minatec.inpg.fr \
    --cc=peff@peff.net \
    --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).