summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f9189cf)
raw | patch | inline | side by side (parent: f9189cf)
author | Chris Parsons <chris@edendevelopment.co.uk> | |
Thu, 22 May 2008 12:50:02 +0000 (08:50 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Fri, 23 May 2008 06:51:22 +0000 (23:51 -0700) |
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt | patch | blob | history | |
wt-status.c | patch | blob | history | |
wt-status.h | patch | blob | history |
index 217980f48d9d9ac71860d61313e9afa9c6b7c332..554977b89519fb11a6a02d100bf65c3531e86f6f 100644 (file)
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
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 a44c5433754eb89cb84a64c7c7c6d2181bcf7641..6e6516cd874a92376a672dcdc181aed6a3b5636c 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
"\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[] =
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);
}
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);
+ s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
if (s->branch) {
const char *on_what = "On branch ";
const char *branch_name = s->branch;
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 7d61410b1733825e3bb8042781a75de3ee62c41d..f0675fdff33420ba42f3a700501003a43afda376 100644 (file)
--- a/wt-status.h
+++ b/wt-status.h
WT_STATUS_UPDATED,
WT_STATUS_CHANGED,
WT_STATUS_UNTRACKED,
+ WT_STATUS_NOBRANCH,
};
struct wt_status {