From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] status: show branch name if possible in in-progress info
Date: Tue, 29 Jan 2013 19:10:50 +0700 [thread overview]
Message-ID: <1359461450-24456-1-git-send-email-pclouds@gmail.com> (raw)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Seems like a good thing to do.
t/t7512-status-help.sh | 36 +++++++++++++++----------------
wt-status.c | 58 ++++++++++++++++++++++++++++++++++++++++++--------
wt-status.h | 1 +
3 files changed, 68 insertions(+), 27 deletions(-)
diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh
index b3f6eb9..096ba6f 100755
--- a/t/t7512-status-help.sh
+++ b/t/t7512-status-help.sh
@@ -76,7 +76,7 @@ test_expect_success 'status when rebase in progress before resolving conflicts'
test_must_fail git rebase HEAD^ --onto HEAD^^ &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently rebasing.
+ # You are currently rebasing '\''rebase_conflicts'\''.
# (fix conflicts and then run "git rebase --continue")
# (use "git rebase --skip" to skip this patch)
# (use "git rebase --abort" to check out the original branch)
@@ -102,7 +102,7 @@ test_expect_success 'status when rebase in progress before rebase --continue' '
git add main.txt &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently rebasing.
+ # You are currently rebasing '\''rebase_conflicts'\''.
# (all conflicts fixed: run "git rebase --continue")
#
# Changes to be committed:
@@ -133,7 +133,7 @@ test_expect_success 'status during rebase -i when conflicts unresolved' '
test_must_fail git rebase -i rebase_i_conflicts &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently rebasing.
+ # You are currently rebasing '\''rebase_i_conflicts_second'\''.
# (fix conflicts and then run "git rebase --continue")
# (use "git rebase --skip" to skip this patch)
# (use "git rebase --abort" to check out the original branch)
@@ -158,7 +158,7 @@ test_expect_success 'status during rebase -i after resolving conflicts' '
git add main.txt &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently rebasing.
+ # You are currently rebasing '\''rebase_i_conflicts_second'\''.
# (all conflicts fixed: run "git rebase --continue")
#
# Changes to be committed:
@@ -185,7 +185,7 @@ test_expect_success 'status when rebasing -i in edit mode' '
git rebase -i HEAD~2 &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''rebase_i_edit'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -210,7 +210,7 @@ test_expect_success 'status when splitting a commit' '
git reset HEAD^ &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently splitting a commit during a rebase.
+ # You are currently splitting a commit while rebasing '\''split_commit'\''.
# (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit:
@@ -240,7 +240,7 @@ test_expect_success 'status after editing the last commit with --amend during a
git commit --amend -m "foo" &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''amend_last'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -269,7 +269,7 @@ test_expect_success 'status: (continue first edit) second edit' '
git rebase --continue &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''several_edits'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -290,7 +290,7 @@ test_expect_success 'status: (continue first edit) second edit and split' '
git reset HEAD^ &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently splitting a commit during a rebase.
+ # You are currently splitting a commit while rebasing '\''several_edits'\''.
# (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit:
@@ -316,7 +316,7 @@ test_expect_success 'status: (continue first edit) second edit and amend' '
git commit --amend -m "foo" &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''several_edits'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -337,7 +337,7 @@ test_expect_success 'status: (amend first edit) second edit' '
git rebase --continue &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''several_edits'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -359,7 +359,7 @@ test_expect_success 'status: (amend first edit) second edit and split' '
git reset HEAD^ &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently splitting a commit during a rebase.
+ # You are currently splitting a commit while rebasing '\''several_edits'\''.
# (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit:
@@ -386,7 +386,7 @@ test_expect_success 'status: (amend first edit) second edit and amend' '
git commit --amend -m "d" &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''several_edits'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -409,7 +409,7 @@ test_expect_success 'status: (split first edit) second edit' '
git rebase --continue &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''several_edits'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -433,7 +433,7 @@ test_expect_success 'status: (split first edit) second edit and split' '
git reset HEAD^ &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently splitting a commit during a rebase.
+ # You are currently splitting a commit while rebasing '\''several_edits'\''.
# (Once your working directory is clean, run "git rebase --continue")
#
# Changes not staged for commit:
@@ -462,7 +462,7 @@ test_expect_success 'status: (split first edit) second edit and amend' '
git commit --amend -m "h" &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently editing a commit during a rebase.
+ # You are currently editing a commit while rebasing '\''several_edits'\''.
# (use "git commit --amend" to amend the current commit)
# (use "git rebase --continue" once you are satisfied with your changes)
#
@@ -558,7 +558,7 @@ test_expect_success 'status when bisecting' '
git bisect good one_bisect &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently bisecting.
+ # You are currently bisecting '\''bisect'\''.
# (use "git bisect reset" to get back to the original branch)
#
nothing to commit (use -u to show untracked files)
@@ -580,7 +580,7 @@ test_expect_success 'status when rebase conflicts with statushints disabled' '
test_must_fail git rebase HEAD^ --onto HEAD^^ &&
cat >expected <<-\EOF &&
# Not currently on any branch.
- # You are currently rebasing.
+ # You are currently rebasing '\''statushints_disabled'\''.
#
# Unmerged paths:
# both modified: main.txt
diff --git a/wt-status.c b/wt-status.c
index d7cfe8f..cc7e2d7 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -872,7 +872,13 @@ static void show_rebase_in_progress(struct wt_status *s,
struct stat st;
if (has_unmerged(s)) {
- status_printf_ln(s, color, _("You are currently rebasing."));
+ if (state->branch)
+ status_printf_ln(s, color,
+ _("You are currently rebasing '%s'."),
+ state->branch);
+ else
+ status_printf_ln(s, color,
+ _("You are currently rebasing."));
if (advice_status_hints) {
status_printf_ln(s, color,
_(" (fix conflicts and then run \"git rebase --continue\")"));
@@ -882,17 +888,35 @@ static void show_rebase_in_progress(struct wt_status *s,
_(" (use \"git rebase --abort\" to check out the original branch)"));
}
} else if (state->rebase_in_progress || !stat(git_path("MERGE_MSG"), &st)) {
- status_printf_ln(s, color, _("You are currently rebasing."));
+ if (state->branch)
+ status_printf_ln(s, color,
+ _("You are currently rebasing '%s'."),
+ state->branch);
+ else
+ 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)) {
- status_printf_ln(s, color, _("You are currently splitting a commit during a rebase."));
+ if (state->branch)
+ status_printf_ln(s, color,
+ _("You are currently splitting a commit while rebasing '%s'."),
+ state->branch);
+ else
+ status_printf_ln(s, color,
+ _("You are currently splitting a commit during a rebase."));
if (advice_status_hints)
status_printf_ln(s, color,
_(" (Once your working directory is clean, run \"git rebase --continue\")"));
} else {
- status_printf_ln(s, color, _("You are currently editing a commit during a rebase."));
+ if (state->branch)
+ status_printf_ln(s, color,
+ _("You are currently editing a commit while rebasing '%s'."),
+ state->branch);
+ else
+ status_printf_ln(s, color,
+ _("You are currently editing a commit during a rebase."));
if (advice_status_hints && !s->amend) {
status_printf_ln(s, color,
_(" (use \"git commit --amend\" to amend the current commit)"));
@@ -923,7 +947,7 @@ static void show_bisect_in_progress(struct wt_status *s,
struct wt_status_state *state,
const char *color)
{
- status_printf_ln(s, color, _("You are currently bisecting."));
+ status_printf_ln(s, color, _("You are currently bisecting '%s'."), state->branch);
if (advice_status_hints)
status_printf_ln(s, color,
_(" (use \"git bisect reset\" to get back to the original branch)"));
@@ -935,6 +959,7 @@ static void wt_status_print_state(struct wt_status *s)
const char *state_color = color(WT_STATUS_HEADER, s);
struct wt_status_state state;
struct stat st;
+ struct strbuf sb = STRBUF_INIT;
memset(&state, 0, sizeof(state));
@@ -947,28 +972,43 @@ static void wt_status_print_state(struct wt_status *s)
state.am_empty_patch = 1;
} else {
state.rebase_in_progress = 1;
+ strbuf_read_file(&sb, git_path("rebase-apply/head-name"), 0);
}
} else if (!stat(git_path("rebase-merge"), &st)) {
if (!stat(git_path("rebase-merge/interactive"), &st))
state.rebase_interactive_in_progress = 1;
else
state.rebase_in_progress = 1;
+ strbuf_read_file(&sb, git_path("rebase-merge/head-name"), 0);
} else if (!stat(git_path("CHERRY_PICK_HEAD"), &st)) {
state.cherry_pick_in_progress = 1;
}
- if (!stat(git_path("BISECT_LOG"), &st))
+ if (!stat(git_path("BISECT_LOG"), &st)) {
+ strbuf_read_file(&sb, git_path("BISECT_START"), 0);
state.bisect_in_progress = 1;
+ }
if (state.merge_in_progress)
show_merge_in_progress(s, &state, state_color);
else if (state.am_in_progress)
show_am_in_progress(s, &state, state_color);
- else if (state.rebase_in_progress || state.rebase_interactive_in_progress)
+ else if (state.rebase_in_progress || state.rebase_interactive_in_progress) {
+ while (sb.len && sb.buf[sb.len - 1] == '\n')
+ strbuf_setlen(&sb, sb.len - 1);
+ if (!prefixcmp(sb.buf, "refs/heads/"))
+ state.branch = sb.buf + strlen("refs/heads/");
+ else if (!prefixcmp(sb.buf, "refs/"))
+ state.branch = sb.buf;
show_rebase_in_progress(s, &state, state_color);
- else if (state.cherry_pick_in_progress)
+ } else if (state.cherry_pick_in_progress)
show_cherry_pick_in_progress(s, &state, state_color);
- if (state.bisect_in_progress)
+ if (state.bisect_in_progress) {
+ while (sb.len && sb.buf[sb.len - 1] == '\n')
+ strbuf_setlen(&sb, sb.len - 1);
+ state.branch = sb.buf;
show_bisect_in_progress(s, &state, state_color);
+ }
+ strbuf_release(&sb);
}
void wt_status_print(struct wt_status *s)
diff --git a/wt-status.h b/wt-status.h
index 236b41f..c5eae29 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -79,6 +79,7 @@ struct wt_status_state {
int rebase_interactive_in_progress;
int cherry_pick_in_progress;
int bisect_in_progress;
+ const char *branch;
};
void wt_status_prepare(struct wt_status *s);
--
1.8.1.1.459.g5970e58
next reply other threads:[~2013-01-29 12:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-29 12:10 Nguyễn Thái Ngọc Duy [this message]
2013-01-29 12:31 ` [PATCH] status: show branch name if possible in in-progress info Matthieu Moy
2013-01-29 12:56 ` Duy Nguyen
2013-01-29 13:13 ` Matthieu Moy
2013-01-29 16:18 ` Junio C Hamano
2013-01-29 14:58 ` [PATCH v2] status: show the " Nguyễn Thái Ngọc Duy
2013-01-29 18:44 ` Jonathan Nieder
2013-01-30 1:13 ` Duy Nguyen
2013-02-03 5:53 ` [PATCH v3] " Nguyễn Thái Ngọc Duy
2013-02-05 6:38 ` Jonathan Nieder
2013-02-05 12:20 ` Duy Nguyen
2013-02-05 16:28 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1359461450-24456-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
/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.
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.