summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7d43de9)
raw | patch | inline | side by side (parent: 7d43de9)
author | Aleksi Aalto <aga@iki.fi> | |
Wed, 17 Nov 2010 23:40:05 +0000 (01:40 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 30 Nov 2010 00:31:34 +0000 (16:31 -0800) |
You can tell "git status" to paint the name of the current branch in its
output (the line that says "On branch ...") by setting the configuration
variable color.status.branch; it is by default turned off.
Signed-off-by: Aleksi Aalto <aga@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
output (the line that says "On branch ...") by setting the configuration
variable color.status.branch; it is by default turned off.
Signed-off-by: Aleksi Aalto <aga@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/config.txt | patch | blob | history | |
builtin/commit.c | patch | blob | history | |
t/t7508-status.sh | patch | blob | history | |
wt-status.c | patch | blob | history | |
wt-status.h | patch | blob | history |
index 6a6c0b5bd83774c9c92f5530f327019c322d3c2a..6cd762dfb867f5599ed57eac9cab8c6a14378081 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),
- `untracked` (files which are not tracked by git), or
+ `untracked` (files which are not tracked by git),
+ `branch` (the current branch), 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>.
diff --git a/builtin/commit.c b/builtin/commit.c
index 4fd1a1692f867e54eddd406d505e584ee0451cf8..025c342e5e870b11da488f9183059442c6664ad6 100644 (file)
--- a/builtin/commit.c
+++ b/builtin/commit.c
{
if (!strcasecmp(var+offset, "header"))
return WT_STATUS_HEADER;
+ if (!strcasecmp(var+offset, "branch"))
+ return WT_STATUS_ONBRANCH;
if (!strcasecmp(var+offset, "updated")
|| !strcasecmp(var+offset, "added"))
return WT_STATUS_UPDATED;
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index 4de3e27950ca34ffe3f5e72052108ce9d74b0227..ba36d72661c59611583a8e74059ad2db1d353760 100755 (executable)
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
test_expect_success 'setup unique colors' '
- git config status.color.untracked blue
+ git config status.color.untracked blue &&
+ git config status.color.branch green
'
cat >expect <<\EOF
-# On branch master
+# On branch <GREEN>master<RESET>
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
diff --git a/wt-status.c b/wt-status.c
index d9f3d9fe9369ceaac07f5b405e25cf94d824e102..19c9cb1d2312ad65e79dfb0aa28c182f497eb53a 100644 (file)
--- a/wt-status.c
+++ b/wt-status.c
GIT_COLOR_RED, /* WT_STATUS_UNMERGED */
GIT_COLOR_GREEN, /* WT_STATUS_LOCAL_BRANCH */
GIT_COLOR_RED, /* WT_STATUS_REMOTE_BRANCH */
+ GIT_COLOR_NORMAL, /* WT_STATUS_ONBRANCH */
};
static const char *color(int slot, struct wt_status *s)
void wt_status_print(struct wt_status *s)
{
- const char *branch_color = color(WT_STATUS_HEADER, s);
+ const char *branch_color = color(WT_STATUS_ONBRANCH, s);
+ const char *branch_status_color = color(WT_STATUS_HEADER, s);
if (s->branch) {
const char *on_what = "On branch ";
branch_name += 11;
else if (!strcmp(branch_name, "HEAD")) {
branch_name = "";
- branch_color = color(WT_STATUS_NOBRANCH, s);
+ branch_status_color = color(WT_STATUS_NOBRANCH, s);
on_what = "Not currently on any branch.";
}
color_fprintf(s->fp, color(WT_STATUS_HEADER, s), "# ");
- color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
+ color_fprintf(s->fp, branch_status_color, "%s", on_what);
+ color_fprintf_ln(s->fp, branch_color, "%s", branch_name);
if (!s->is_initial)
wt_status_print_tracking(s);
}
diff --git a/wt-status.h b/wt-status.h
index 9df9c9fad2512d7c1d7d6456cdd645d641b5a089..20b17cf4393b8f9acce93320fb97998ad7cd609b 100644 (file)
--- a/wt-status.h
+++ b/wt-status.h
WT_STATUS_NOBRANCH,
WT_STATUS_UNMERGED,
WT_STATUS_LOCAL_BRANCH,
- WT_STATUS_REMOTE_BRANCH
+ WT_STATUS_REMOTE_BRANCH,
+ WT_STATUS_ONBRANCH,
+ WT_STATUS_MAXSLOT
};
enum untracked_status_type {
int show_ignored_files;
enum untracked_status_type show_untracked_files;
const char *ignore_submodule_arg;
- char color_palette[WT_STATUS_REMOTE_BRANCH+1][COLOR_MAXLEN];
+ char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
/* These are computed during processing of the individual sections */
int commitable;