* [PATCH v2] Updated status to show 'Not currently on any branch' in red
@ 2008-05-22 10:19 Chris Parsons
2008-05-22 12:50 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Chris Parsons @ 2008-05-22 10:19 UTC (permalink / raw)
To: git, Junio C Hamano
This provides additional warning to users when attempting to
commit to a detached HEAD. It is configurable in color.status.nobranch.
Signed-off-by: Chris Parsons <chris@edendevelopment.co.uk>
---
Updated to incorporate changes suggested by Jeff King.
Documentation/config.txt | 6 ++++--
wt-status.c | 11 ++++++++---
wt-status.h | 1 +
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 217980f..a073dc1 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -523,8 +523,10 @@ color.status.<slot>::
one of `header` (the header text of the status message),
`added` or `updated` (files which are added but not committed),
`changed` (files which are changed but not added in the index),
- or `untracked` (files which are not tracked by git). The values of
- these variables may be specified as in color.branch.<slot>.
+ `untracked` (files which are not tracked by git), or
+ `nobranch` (the color the 'no branch' warning is shown in, defaulting
+ to red). The values of these variables may be specified as in
+ color.branch.<slot>.
commit.template::
Specify a file to use as the template for new commit messages.
diff --git a/wt-status.c b/wt-status.c
index a44c543..78bc769 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -18,6 +18,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
"\033[32m", /* WT_STATUS_UPDATED: green */
"\033[31m", /* WT_STATUS_CHANGED: red */
"\033[31m", /* WT_STATUS_UNTRACKED: red */
+ "\033[31m", /* WT_STATUS_NOBRANCH: red */
};
static const char use_add_msg[] =
@@ -38,6 +39,8 @@ static int parse_status_slot(const char *var, int
offset)
return WT_STATUS_CHANGED;
if (!strcasecmp(var+offset, "untracked"))
return WT_STATUS_UNTRACKED;
+ if (!strcasecmp(var+offset, "nobranch"))
+ return WT_STATUS_NOBRANCH;
die("bad config variable '%s'", var);
}
@@ -315,7 +318,8 @@ void wt_status_print(struct wt_status *s)
{
unsigned char sha1[20];
s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
-
+ const char* branch_color = color(WT_STATUS_HEADER);
+
if (s->branch) {
const char *on_what = "On branch ";
const char *branch_name = s->branch;
@@ -323,10 +327,11 @@ void wt_status_print(struct wt_status *s)
branch_name += 11;
else if (!strcmp(branch_name, "HEAD")) {
branch_name = "";
+ branch_color = color(WT_STATUS_NOBRANCH);
on_what = "Not currently on any branch.";
}
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
- "# %s%s", on_what, branch_name);
+ color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
+ color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
}
if (s->is_initial) {
diff --git a/wt-status.h b/wt-status.h
index 7d61410..f0675fd 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -8,6 +8,7 @@ enum color_wt_status {
WT_STATUS_UPDATED,
WT_STATUS_CHANGED,
WT_STATUS_UNTRACKED,
+ WT_STATUS_NOBRANCH,
};
struct wt_status {
--
1.5.5.1.249.g3fdb.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Updated status to show 'Not currently on any branch' in red
2008-05-22 10:19 [PATCH v2] Updated status to show 'Not currently on any branch' in red Chris Parsons
@ 2008-05-22 12:50 ` Jeff King
2008-05-22 13:12 ` Chris Parsons
2008-05-23 6:19 ` Junio C Hamano
0 siblings, 2 replies; 4+ messages in thread
From: Jeff King @ 2008-05-22 12:50 UTC (permalink / raw)
To: Chris Parsons; +Cc: git, Junio C Hamano
From: Chris Parsons <chris@edendevelopment.co.uk>
This provides additional warning to users when attempting to
commit to a detached HEAD. It is configurable in color.status.nobranch.
Signed-off-by: Chris Parsons <chris@edendevelopment.co.uk>
Acked-by: Jeff King <peff@peff.net>
---
On Thu, May 22, 2008 at 11:19:18AM +0100, Chris Parsons wrote:
> Updated to incorporate changes suggested by Jeff King.
The improvements look good to me.
This patch was severely whitespaced damaged, probably due to:
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
in the original, so I am resending an unmangled version for Junio's
convenience. Chris, please make sure to turn off flowed text when
sending future patches.
Documentation/config.txt | 6 ++++--
wt-status.c | 9 +++++++--
wt-status.h | 1 +
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 217980f..554977b 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -523,8 +523,10 @@ color.status.<slot>::
one of `header` (the header text of the status message),
`added` or `updated` (files which are added but not committed),
`changed` (files which are changed but not added in the index),
- or `untracked` (files which are not tracked by git). The values of
- these variables may be specified as in color.branch.<slot>.
+ `untracked` (files which are not tracked by git), or
+ `nobranch` (the color the 'no branch' warning is shown in, defaulting
+ to red). The values of these variables may be specified as in
+ color.branch.<slot>.
commit.template::
Specify a file to use as the template for new commit messages.
diff --git a/wt-status.c b/wt-status.c
index a44c543..7a3223e 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -18,6 +18,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
"\033[32m", /* WT_STATUS_UPDATED: green */
"\033[31m", /* WT_STATUS_CHANGED: red */
"\033[31m", /* WT_STATUS_UNTRACKED: red */
+ "\033[31m", /* WT_STATUS_NOBRANCH: red */
};
static const char use_add_msg[] =
@@ -38,6 +39,8 @@ static int parse_status_slot(const char *var, int offset)
return WT_STATUS_CHANGED;
if (!strcasecmp(var+offset, "untracked"))
return WT_STATUS_UNTRACKED;
+ if (!strcasecmp(var+offset, "nobranch"))
+ return WT_STATUS_NOBRANCH;
die("bad config variable '%s'", var);
}
@@ -315,6 +318,7 @@ void wt_status_print(struct wt_status *s)
{
unsigned char sha1[20];
s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
+ const char* branch_color = color(WT_STATUS_HEADER);
if (s->branch) {
const char *on_what = "On branch ";
@@ -323,10 +327,11 @@ void wt_status_print(struct wt_status *s)
branch_name += 11;
else if (!strcmp(branch_name, "HEAD")) {
branch_name = "";
+ branch_color = color(WT_STATUS_NOBRANCH);
on_what = "Not currently on any branch.";
}
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
- "# %s%s", on_what, branch_name);
+ color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
+ color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
}
if (s->is_initial) {
diff --git a/wt-status.h b/wt-status.h
index 7d61410..f0675fd 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -8,6 +8,7 @@ enum color_wt_status {
WT_STATUS_UPDATED,
WT_STATUS_CHANGED,
WT_STATUS_UNTRACKED,
+ WT_STATUS_NOBRANCH,
};
struct wt_status {
--
1.5.5.1.450.gdbd2d
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Updated status to show 'Not currently on any branch' in red
2008-05-22 12:50 ` Jeff King
@ 2008-05-22 13:12 ` Chris Parsons
2008-05-23 6:19 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Chris Parsons @ 2008-05-22 13:12 UTC (permalink / raw)
To: Jeff King; +Cc: git
On 22 May 2008, at 13:50, Jeff King wrote:
> in the original, so I am resending an unmangled version for Junio's
> convenience. Chris, please make sure to turn off flowed text when
> sending future patches.
Hmph - sorry about that. I did read SubmittingPatches carefully, but I
guess Apple Mail tripped me up.
Thanks
Chris
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] Updated status to show 'Not currently on any branch' in red
2008-05-22 12:50 ` Jeff King
2008-05-22 13:12 ` Chris Parsons
@ 2008-05-23 6:19 ` Junio C Hamano
1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2008-05-23 6:19 UTC (permalink / raw)
To: Jeff King; +Cc: Chris Parsons, git
Thanks, both.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-05-23 6:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22 10:19 [PATCH v2] Updated status to show 'Not currently on any branch' in red Chris Parsons
2008-05-22 12:50 ` Jeff King
2008-05-22 13:12 ` Chris Parsons
2008-05-23 6:19 ` Junio C Hamano
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 NNTP newsgroup(s).