Merge branch 'mg/status-b'
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Jun 2010 18:16:55 +0000 (11:16 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Jun 2010 18:16:55 +0000 (11:16 -0700)
* mg/status-b:
Documentation+t5708: document and test status -s -b
Show branch information in short output of git status

1  2 
builtin/commit.c
diff --combined builtin/commit.c
index a4e4966319651c03a3bb933795c502b24b2324d4,effe087660af53e54e8d8515dfe609df1254700b..a8616866435a0a73aaa74ac1742399d7381c018a
@@@ -93,6 -93,7 +93,7 @@@ static enum 
        STATUS_FORMAT_SHORT,
        STATUS_FORMAT_PORCELAIN,
  } status_format = STATUS_FORMAT_LONG;
+ static int status_show_branch;
  
  static int opt_parse_m(const struct option *opt, const char *arg, int unset)
  {
@@@ -134,6 -135,7 +135,7 @@@ static struct option builtin_commit_opt
        OPT_BOOLEAN(0, "dry-run", &dry_run, "show what would be committed"),
        OPT_SET_INT(0, "short", &status_format, "show status concisely",
                    STATUS_FORMAT_SHORT),
+       OPT_BOOLEAN(0, "branch", &status_show_branch, "show branch information"),
        OPT_SET_INT(0, "porcelain", &status_format,
                    "show porcelain output format", STATUS_FORMAT_PORCELAIN),
        OPT_BOOLEAN('z', "null", &null_termination,
@@@ -424,7 -426,7 +426,7 @@@ static int run_status(FILE *fp, const c
  
        switch (status_format) {
        case STATUS_FORMAT_SHORT:
-               wt_shortstatus_print(s, null_termination);
+               wt_shortstatus_print(s, null_termination, status_show_branch);
                break;
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(s, null_termination);
@@@ -462,21 -464,15 +464,21 @@@ static void determine_author_info(void
                if (!a)
                        die("invalid commit: %s", use_message);
  
 -              lb = strstr(a + 8, " <");
 -              rb = strstr(a + 8, "> ");
 -              eol = strchr(a + 8, '\n');
 -              if (!lb || !rb || !eol)
 +              lb = strchrnul(a + strlen("\nauthor "), '<');
 +              rb = strchrnul(lb, '>');
 +              eol = strchrnul(rb, '\n');
 +              if (!*lb || !*rb || !*eol)
                        die("invalid commit: %s", use_message);
  
 -              name = xstrndup(a + 8, lb - (a + 8));
 -              email = xstrndup(lb + 2, rb - (lb + 2));
 -              date = xstrndup(rb + 2, eol - (rb + 2));
 +              if (lb == a + strlen("\nauthor "))
 +                      /* \nauthor <foo@example.com> */
 +                      name = xcalloc(1, 1);
 +              else
 +                      name = xmemdupz(a + strlen("\nauthor "),
 +                                      (lb - strlen(" ") -
 +                                       (a + strlen("\nauthor "))));
 +              email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<")));
 +              date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> ")));
        }
  
        if (force_author) {
@@@ -1036,6 -1032,8 +1038,8 @@@ int cmd_status(int argc, const char **a
                OPT__VERBOSE(&verbose),
                OPT_SET_INT('s', "short", &status_format,
                            "show status concisely", STATUS_FORMAT_SHORT),
+               OPT_BOOLEAN('b', "branch", &status_show_branch,
+                           "show branch information"),
                OPT_SET_INT(0, "porcelain", &status_format,
                            "show porcelain output format",
                            STATUS_FORMAT_PORCELAIN),
  
        switch (status_format) {
        case STATUS_FORMAT_SHORT:
-               wt_shortstatus_print(&s, null_termination);
+               wt_shortstatus_print(&s, null_termination, status_show_branch);
                break;
        case STATUS_FORMAT_PORCELAIN:
                wt_porcelain_print(&s, null_termination);