From: Junio C Hamano Date: Fri, 18 Jun 2010 18:16:55 +0000 (-0700) Subject: Merge branch 'mg/status-b' X-Git-Tag: v1.7.2-rc0~54 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/880bd9d08081752bb4e2891aa3c16c82808ecb2e?ds=inline;hp=-c Merge branch 'mg/status-b' * mg/status-b: Documentation+t5708: document and test status -s -b Show branch information in short output of git status --- 880bd9d08081752bb4e2891aa3c16c82808ecb2e diff --combined builtin/commit.c index a4e4966319,effe087660..a861686643 --- a/builtin/commit.c +++ b/builtin/commit.c @@@ -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 */ + 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), @@@ -1088,7 -1086,7 +1092,7 @@@ 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);