public
Description: GitHub mirror of the publicly available git repo, updated hourly. It's here so we can use the collaboration tools of GitHub. Updates ONLY from git public repo. If you want changes pulled, contact the git team, not me.
Clone URL: git://github.com/gitmirror/git.git
Updated status to show 'Not currently on any branch' in red

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>
ChrisMDP (author)
Thu May 22 05:50:02 -0700 2008
Junio C Hamano (committer)
Thu May 22 23:51:22 -0700 2008
commit  950ce2e22db4a3c1ff9ad598b46ccb22c517a336
tree    049fd11a2346c2ec1c20ce0787f8eaf6b97dce44
parent  f9189cf8f2427b10a40b5b3e530e2c893bc64ae9
...
523
524
525
526
527
 
 
 
 
528
529
530
...
523
524
525
 
 
526
527
528
529
530
531
532
0
@@ -523,8 +523,10 @@ color.status.<slot>::
0
   one of `header` (the header text of the status message),
0
   `added` or `updated` (files which are added but not committed),
0
   `changed` (files which are changed but not added in the index),
0
- or `untracked` (files which are not tracked by git). The values of
0
- these variables may be specified as in color.branch.<slot>.
0
+ `untracked` (files which are not tracked by git), or
0
+ `nobranch` (the color the 'no branch' warning is shown in, defaulting
0
+ to red). The values of these variables may be specified as in
0
+ color.branch.<slot>.
0
 
0
 commit.template::
0
   Specify a file to use as the template for new commit messages.
...
18
19
20
 
21
22
23
...
38
39
40
 
 
41
42
43
...
314
315
316
317
 
318
 
319
320
321
...
323
324
325
 
326
327
328
329
 
 
330
331
332
...
18
19
20
21
22
23
24
...
39
40
41
42
43
44
45
46
...
317
318
319
 
320
321
322
323
324
325
...
327
328
329
330
331
332
 
 
333
334
335
336
337
0
@@ -18,6 +18,7 @@ static char wt_status_colors[][COLOR_MAXLEN] = {
0
   "\033[32m", /* WT_STATUS_UPDATED: green */
0
   "\033[31m", /* WT_STATUS_CHANGED: red */
0
   "\033[31m", /* WT_STATUS_UNTRACKED: red */
0
+ "\033[31m", /* WT_STATUS_NOBRANCH: red */
0
 };
0
 
0
 static const char use_add_msg[] =
0
@@ -38,6 +39,8 @@ static int parse_status_slot(const char *var, int offset)
0
     return WT_STATUS_CHANGED;
0
   if (!strcasecmp(var+offset, "untracked"))
0
     return WT_STATUS_UNTRACKED;
0
+ if (!strcasecmp(var+offset, "nobranch"))
0
+ return WT_STATUS_NOBRANCH;
0
   die("bad config variable '%s'", var);
0
 }
0
 
0
@@ -314,8 +317,9 @@ static void wt_status_print_verbose(struct wt_status *s)
0
 void wt_status_print(struct wt_status *s)
0
 {
0
   unsigned char sha1[20];
0
- s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
0
+ const char *branch_color = color(WT_STATUS_HEADER);
0
 
0
+ s->is_initial = get_sha1(s->reference, sha1) ? 1 : 0;
0
   if (s->branch) {
0
     const char *on_what = "On branch ";
0
     const char *branch_name = s->branch;
0
@@ -323,10 +327,11 @@ void wt_status_print(struct wt_status *s)
0
       branch_name += 11;
0
     else if (!strcmp(branch_name, "HEAD")) {
0
       branch_name = "";
0
+ branch_color = color(WT_STATUS_NOBRANCH);
0
       on_what = "Not currently on any branch.";
0
     }
0
- color_fprintf_ln(s->fp, color(WT_STATUS_HEADER),
0
- "# %s%s", on_what, branch_name);
0
+ color_fprintf(s->fp, color(WT_STATUS_HEADER), "# ");
0
+ color_fprintf_ln(s->fp, branch_color, "%s%s", on_what, branch_name);
0
   }
0
 
0
   if (s->is_initial) {
...
8
9
10
 
11
12
13
...
8
9
10
11
12
13
14
0
@@ -8,6 +8,7 @@ enum color_wt_status {
0
   WT_STATUS_UPDATED,
0
   WT_STATUS_CHANGED,
0
   WT_STATUS_UNTRACKED,
0
+ WT_STATUS_NOBRANCH,
0
 };
0
 
0
 struct wt_status {

Comments

    No one has commented yet.