mirror of
https://github.com/git/git
synced 2024-08-25 10:45:59 +00:00
Merge branch 'jk/maint-status-porcelain-z-b' into maint
"git status --porcelain" ignored "--branch" option by mistake. The output for "git status --branch -z" was also incorrect and did not terminate the record for the current branch name with NUL as asked. By Jeff King * jk/maint-status-porcelain-z-b: status: respect "-b" for porcelain format status: fix null termination with "-b" status: refactor null_termination option commit: refactor option parsing
This commit is contained in:
commit
a8bd582d30
|
@ -177,7 +177,7 @@ order is reversed (e.g 'from \-> to' becomes 'to from'). Second, a NUL
|
||||||
and the terminating newline (but a space still separates the status
|
and the terminating newline (but a space still separates the status
|
||||||
field from the first filename). Third, filenames containing special
|
field from the first filename). Third, filenames containing special
|
||||||
characters are not specially formatted; no quoting or
|
characters are not specially formatted; no quoting or
|
||||||
backslash-escaping is performed. Fourth, there is no branch line.
|
backslash-escaping is performed.
|
||||||
|
|
||||||
CONFIGURATION
|
CONFIGURATION
|
||||||
-------------
|
-------------
|
||||||
|
|
135
builtin/commit.c
135
builtin/commit.c
|
@ -109,13 +109,11 @@ static int show_ignored_in_status;
|
||||||
static const char *only_include_assumed;
|
static const char *only_include_assumed;
|
||||||
static struct strbuf message = STRBUF_INIT;
|
static struct strbuf message = STRBUF_INIT;
|
||||||
|
|
||||||
static int null_termination;
|
|
||||||
static enum {
|
static enum {
|
||||||
STATUS_FORMAT_LONG,
|
STATUS_FORMAT_LONG,
|
||||||
STATUS_FORMAT_SHORT,
|
STATUS_FORMAT_SHORT,
|
||||||
STATUS_FORMAT_PORCELAIN
|
STATUS_FORMAT_PORCELAIN
|
||||||
} status_format = STATUS_FORMAT_LONG;
|
} status_format = STATUS_FORMAT_LONG;
|
||||||
static int status_show_branch;
|
|
||||||
|
|
||||||
static int opt_parse_m(const struct option *opt, const char *arg, int unset)
|
static int opt_parse_m(const struct option *opt, const char *arg, int unset)
|
||||||
{
|
{
|
||||||
|
@ -129,59 +127,6 @@ static int opt_parse_m(const struct option *opt, const char *arg, int unset)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct option builtin_commit_options[] = {
|
|
||||||
OPT__QUIET(&quiet, "suppress summary after successful commit"),
|
|
||||||
OPT__VERBOSE(&verbose, "show diff in commit message template"),
|
|
||||||
|
|
||||||
OPT_GROUP("Commit message options"),
|
|
||||||
OPT_FILENAME('F', "file", &logfile, "read message from file"),
|
|
||||||
OPT_STRING(0, "author", &force_author, "author", "override author for commit"),
|
|
||||||
OPT_STRING(0, "date", &force_date, "date", "override date for commit"),
|
|
||||||
OPT_CALLBACK('m', "message", &message, "message", "commit message", opt_parse_m),
|
|
||||||
OPT_STRING('c', "reedit-message", &edit_message, "commit", "reuse and edit message from specified commit"),
|
|
||||||
OPT_STRING('C', "reuse-message", &use_message, "commit", "reuse message from specified commit"),
|
|
||||||
OPT_STRING(0, "fixup", &fixup_message, "commit", "use autosquash formatted message to fixup specified commit"),
|
|
||||||
OPT_STRING(0, "squash", &squash_message, "commit", "use autosquash formatted message to squash specified commit"),
|
|
||||||
OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C/-c/--amend)"),
|
|
||||||
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
|
|
||||||
OPT_FILENAME('t', "template", &template_file, "use specified template file"),
|
|
||||||
OPT_BOOL('e', "edit", &edit_flag, "force edit of commit"),
|
|
||||||
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
|
|
||||||
OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"),
|
|
||||||
{ OPTION_STRING, 'S', "gpg-sign", &sign_commit, "key id",
|
|
||||||
"GPG sign commit", PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
|
|
||||||
/* end commit message options */
|
|
||||||
|
|
||||||
OPT_GROUP("Commit contents options"),
|
|
||||||
OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
|
|
||||||
OPT_BOOLEAN('i', "include", &also, "add specified files to index for commit"),
|
|
||||||
OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"),
|
|
||||||
OPT_BOOLEAN('p', "patch", &patch_interactive, "interactively add changes"),
|
|
||||||
OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
|
|
||||||
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
|
|
||||||
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,
|
|
||||||
"machine-readable output", STATUS_FORMAT_PORCELAIN),
|
|
||||||
OPT_BOOLEAN('z', "null", &null_termination,
|
|
||||||
"terminate entries with NUL"),
|
|
||||||
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
|
|
||||||
OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
|
|
||||||
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
|
|
||||||
/* end commit contents options */
|
|
||||||
|
|
||||||
{ OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL,
|
|
||||||
"ok to record an empty change",
|
|
||||||
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
|
|
||||||
{ OPTION_BOOLEAN, 0, "allow-empty-message", &allow_empty_message, NULL,
|
|
||||||
"ok to record a change with an empty message",
|
|
||||||
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
|
|
||||||
|
|
||||||
OPT_END()
|
|
||||||
};
|
|
||||||
|
|
||||||
static void determine_whence(struct wt_status *s)
|
static void determine_whence(struct wt_status *s)
|
||||||
{
|
{
|
||||||
if (file_exists(git_path("MERGE_HEAD")))
|
if (file_exists(git_path("MERGE_HEAD")))
|
||||||
|
@ -513,10 +458,10 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
|
||||||
|
|
||||||
switch (status_format) {
|
switch (status_format) {
|
||||||
case STATUS_FORMAT_SHORT:
|
case STATUS_FORMAT_SHORT:
|
||||||
wt_shortstatus_print(s, null_termination, status_show_branch);
|
wt_shortstatus_print(s);
|
||||||
break;
|
break;
|
||||||
case STATUS_FORMAT_PORCELAIN:
|
case STATUS_FORMAT_PORCELAIN:
|
||||||
wt_porcelain_print(s, null_termination);
|
wt_porcelain_print(s);
|
||||||
break;
|
break;
|
||||||
case STATUS_FORMAT_LONG:
|
case STATUS_FORMAT_LONG:
|
||||||
wt_status_print(s);
|
wt_status_print(s);
|
||||||
|
@ -1046,6 +991,7 @@ static const char *read_commit_message(const char *name)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_and_validate_options(int argc, const char *argv[],
|
static int parse_and_validate_options(int argc, const char *argv[],
|
||||||
|
const struct option *options,
|
||||||
const char * const usage[],
|
const char * const usage[],
|
||||||
const char *prefix,
|
const char *prefix,
|
||||||
struct commit *current_head,
|
struct commit *current_head,
|
||||||
|
@ -1053,8 +999,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
|
||||||
{
|
{
|
||||||
int f = 0;
|
int f = 0;
|
||||||
|
|
||||||
argc = parse_options(argc, argv, prefix, builtin_commit_options, usage,
|
argc = parse_options(argc, argv, prefix, options, usage, 0);
|
||||||
0);
|
|
||||||
|
|
||||||
if (force_author && !strchr(force_author, '>'))
|
if (force_author && !strchr(force_author, '>'))
|
||||||
force_author = find_author_by_nickname(force_author);
|
force_author = find_author_by_nickname(force_author);
|
||||||
|
@ -1135,7 +1080,7 @@ static int parse_and_validate_options(int argc, const char *argv[],
|
||||||
if (all && argc > 0)
|
if (all && argc > 0)
|
||||||
die(_("Paths with -a does not make sense."));
|
die(_("Paths with -a does not make sense."));
|
||||||
|
|
||||||
if (null_termination && status_format == STATUS_FORMAT_LONG)
|
if (s->null_termination && status_format == STATUS_FORMAT_LONG)
|
||||||
status_format = STATUS_FORMAT_PORCELAIN;
|
status_format = STATUS_FORMAT_PORCELAIN;
|
||||||
if (status_format != STATUS_FORMAT_LONG)
|
if (status_format != STATUS_FORMAT_LONG)
|
||||||
dry_run = 1;
|
dry_run = 1;
|
||||||
|
@ -1222,19 +1167,19 @@ static int git_status_config(const char *k, const char *v, void *cb)
|
||||||
|
|
||||||
int cmd_status(int argc, const char **argv, const char *prefix)
|
int cmd_status(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
struct wt_status s;
|
static struct wt_status s;
|
||||||
int fd;
|
int fd;
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
static struct option builtin_status_options[] = {
|
static struct option builtin_status_options[] = {
|
||||||
OPT__VERBOSE(&verbose, "be verbose"),
|
OPT__VERBOSE(&verbose, "be verbose"),
|
||||||
OPT_SET_INT('s', "short", &status_format,
|
OPT_SET_INT('s', "short", &status_format,
|
||||||
"show status concisely", STATUS_FORMAT_SHORT),
|
"show status concisely", STATUS_FORMAT_SHORT),
|
||||||
OPT_BOOLEAN('b', "branch", &status_show_branch,
|
OPT_BOOLEAN('b', "branch", &s.show_branch,
|
||||||
"show branch information"),
|
"show branch information"),
|
||||||
OPT_SET_INT(0, "porcelain", &status_format,
|
OPT_SET_INT(0, "porcelain", &status_format,
|
||||||
"machine-readable output",
|
"machine-readable output",
|
||||||
STATUS_FORMAT_PORCELAIN),
|
STATUS_FORMAT_PORCELAIN),
|
||||||
OPT_BOOLEAN('z', "null", &null_termination,
|
OPT_BOOLEAN('z', "null", &s.null_termination,
|
||||||
"terminate entries with NUL"),
|
"terminate entries with NUL"),
|
||||||
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
|
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg,
|
||||||
"mode",
|
"mode",
|
||||||
|
@ -1259,7 +1204,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||||
builtin_status_options,
|
builtin_status_options,
|
||||||
builtin_status_usage, 0);
|
builtin_status_usage, 0);
|
||||||
|
|
||||||
if (null_termination && status_format == STATUS_FORMAT_LONG)
|
if (s.null_termination && status_format == STATUS_FORMAT_LONG)
|
||||||
status_format = STATUS_FORMAT_PORCELAIN;
|
status_format = STATUS_FORMAT_PORCELAIN;
|
||||||
|
|
||||||
handle_untracked_files_arg(&s);
|
handle_untracked_files_arg(&s);
|
||||||
|
@ -1284,10 +1229,10 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
switch (status_format) {
|
switch (status_format) {
|
||||||
case STATUS_FORMAT_SHORT:
|
case STATUS_FORMAT_SHORT:
|
||||||
wt_shortstatus_print(&s, null_termination, status_show_branch);
|
wt_shortstatus_print(&s);
|
||||||
break;
|
break;
|
||||||
case STATUS_FORMAT_PORCELAIN:
|
case STATUS_FORMAT_PORCELAIN:
|
||||||
wt_porcelain_print(&s, null_termination);
|
wt_porcelain_print(&s);
|
||||||
break;
|
break;
|
||||||
case STATUS_FORMAT_LONG:
|
case STATUS_FORMAT_LONG:
|
||||||
s.verbose = verbose;
|
s.verbose = verbose;
|
||||||
|
@ -1422,6 +1367,60 @@ static int run_rewrite_hook(const unsigned char *oldsha1,
|
||||||
|
|
||||||
int cmd_commit(int argc, const char **argv, const char *prefix)
|
int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
|
static struct wt_status s;
|
||||||
|
static struct option builtin_commit_options[] = {
|
||||||
|
OPT__QUIET(&quiet, "suppress summary after successful commit"),
|
||||||
|
OPT__VERBOSE(&verbose, "show diff in commit message template"),
|
||||||
|
|
||||||
|
OPT_GROUP("Commit message options"),
|
||||||
|
OPT_FILENAME('F', "file", &logfile, "read message from file"),
|
||||||
|
OPT_STRING(0, "author", &force_author, "author", "override author for commit"),
|
||||||
|
OPT_STRING(0, "date", &force_date, "date", "override date for commit"),
|
||||||
|
OPT_CALLBACK('m', "message", &message, "message", "commit message", opt_parse_m),
|
||||||
|
OPT_STRING('c', "reedit-message", &edit_message, "commit", "reuse and edit message from specified commit"),
|
||||||
|
OPT_STRING('C', "reuse-message", &use_message, "commit", "reuse message from specified commit"),
|
||||||
|
OPT_STRING(0, "fixup", &fixup_message, "commit", "use autosquash formatted message to fixup specified commit"),
|
||||||
|
OPT_STRING(0, "squash", &squash_message, "commit", "use autosquash formatted message to squash specified commit"),
|
||||||
|
OPT_BOOLEAN(0, "reset-author", &renew_authorship, "the commit is authored by me now (used with -C/-c/--amend)"),
|
||||||
|
OPT_BOOLEAN('s', "signoff", &signoff, "add Signed-off-by:"),
|
||||||
|
OPT_FILENAME('t', "template", &template_file, "use specified template file"),
|
||||||
|
OPT_BOOL('e', "edit", &edit_flag, "force edit of commit"),
|
||||||
|
OPT_STRING(0, "cleanup", &cleanup_arg, "default", "how to strip spaces and #comments from message"),
|
||||||
|
OPT_BOOLEAN(0, "status", &include_status, "include status in commit message template"),
|
||||||
|
{ OPTION_STRING, 'S', "gpg-sign", &sign_commit, "key id",
|
||||||
|
"GPG sign commit", PARSE_OPT_OPTARG, NULL, (intptr_t) "" },
|
||||||
|
/* end commit message options */
|
||||||
|
|
||||||
|
OPT_GROUP("Commit contents options"),
|
||||||
|
OPT_BOOLEAN('a', "all", &all, "commit all changed files"),
|
||||||
|
OPT_BOOLEAN('i', "include", &also, "add specified files to index for commit"),
|
||||||
|
OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"),
|
||||||
|
OPT_BOOLEAN('p', "patch", &patch_interactive, "interactively add changes"),
|
||||||
|
OPT_BOOLEAN('o', "only", &only, "commit only specified files"),
|
||||||
|
OPT_BOOLEAN('n', "no-verify", &no_verify, "bypass pre-commit hook"),
|
||||||
|
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", &s.show_branch, "show branch information"),
|
||||||
|
OPT_SET_INT(0, "porcelain", &status_format,
|
||||||
|
"machine-readable output", STATUS_FORMAT_PORCELAIN),
|
||||||
|
OPT_BOOLEAN('z', "null", &s.null_termination,
|
||||||
|
"terminate entries with NUL"),
|
||||||
|
OPT_BOOLEAN(0, "amend", &amend, "amend previous commit"),
|
||||||
|
OPT_BOOLEAN(0, "no-post-rewrite", &no_post_rewrite, "bypass post-rewrite hook"),
|
||||||
|
{ OPTION_STRING, 'u', "untracked-files", &untracked_files_arg, "mode", "show untracked files, optional modes: all, normal, no. (Default: all)", PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
|
||||||
|
/* end commit contents options */
|
||||||
|
|
||||||
|
{ OPTION_BOOLEAN, 0, "allow-empty", &allow_empty, NULL,
|
||||||
|
"ok to record an empty change",
|
||||||
|
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
|
||||||
|
{ OPTION_BOOLEAN, 0, "allow-empty-message", &allow_empty_message, NULL,
|
||||||
|
"ok to record a change with an empty message",
|
||||||
|
PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },
|
||||||
|
|
||||||
|
OPT_END()
|
||||||
|
};
|
||||||
|
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
struct strbuf author_ident = STRBUF_INIT;
|
struct strbuf author_ident = STRBUF_INIT;
|
||||||
const char *index_file, *reflog_msg;
|
const char *index_file, *reflog_msg;
|
||||||
|
@ -1431,7 +1430,6 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||||
struct commit_list *parents = NULL, **pptr = &parents;
|
struct commit_list *parents = NULL, **pptr = &parents;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
int allow_fast_forward = 1;
|
int allow_fast_forward = 1;
|
||||||
struct wt_status s;
|
|
||||||
struct commit *current_head = NULL;
|
struct commit *current_head = NULL;
|
||||||
struct commit_extra_header *extra = NULL;
|
struct commit_extra_header *extra = NULL;
|
||||||
|
|
||||||
|
@ -1449,7 +1447,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
|
||||||
if (!current_head || parse_commit(current_head))
|
if (!current_head || parse_commit(current_head))
|
||||||
die(_("could not parse HEAD commit"));
|
die(_("could not parse HEAD commit"));
|
||||||
}
|
}
|
||||||
argc = parse_and_validate_options(argc, argv, builtin_commit_usage,
|
argc = parse_and_validate_options(argc, argv, builtin_commit_options,
|
||||||
|
builtin_commit_usage,
|
||||||
prefix, current_head, &s);
|
prefix, current_head, &s);
|
||||||
if (dry_run)
|
if (dry_run)
|
||||||
return dry_run_commit(argc, argv, prefix, current_head, &s);
|
return dry_run_commit(argc, argv, prefix, current_head, &s);
|
||||||
|
|
|
@ -271,6 +271,15 @@ test_expect_success 'status -s -b' '
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'status -s -z -b' '
|
||||||
|
tr "\\n" Q <expect >expect.q &&
|
||||||
|
mv expect.q expect &&
|
||||||
|
git status -s -z -b >output &&
|
||||||
|
nul_to_q <output >output.q &&
|
||||||
|
mv output.q output &&
|
||||||
|
test_cmp expect output
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup dir3' '
|
test_expect_success 'setup dir3' '
|
||||||
mkdir dir3 &&
|
mkdir dir3 &&
|
||||||
: >dir3/untracked1 &&
|
: >dir3/untracked1 &&
|
||||||
|
@ -647,9 +656,14 @@ test_expect_success 'status --porcelain ignores color.status' '
|
||||||
git config --unset color.status
|
git config --unset color.status
|
||||||
git config --unset color.ui
|
git config --unset color.ui
|
||||||
|
|
||||||
test_expect_success 'status --porcelain ignores -b' '
|
test_expect_success 'status --porcelain respects -b' '
|
||||||
|
|
||||||
git status --porcelain -b >output &&
|
git status --porcelain -b >output &&
|
||||||
|
{
|
||||||
|
echo "## master" &&
|
||||||
|
cat expect
|
||||||
|
} >tmp &&
|
||||||
|
mv tmp expect &&
|
||||||
test_cmp expect output
|
test_cmp expect output
|
||||||
|
|
||||||
'
|
'
|
||||||
|
|
35
wt-status.c
35
wt-status.c
|
@ -777,7 +777,7 @@ void wt_status_print(struct wt_status *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_shortstatus_unmerged(int null_termination, struct string_list_item *it,
|
static void wt_shortstatus_unmerged(struct string_list_item *it,
|
||||||
struct wt_status *s)
|
struct wt_status *s)
|
||||||
{
|
{
|
||||||
struct wt_status_change_data *d = it->util;
|
struct wt_status_change_data *d = it->util;
|
||||||
|
@ -793,7 +793,7 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite
|
||||||
case 7: how = "UU"; break; /* both modified */
|
case 7: how = "UU"; break; /* both modified */
|
||||||
}
|
}
|
||||||
color_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), "%s", how);
|
color_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), "%s", how);
|
||||||
if (null_termination) {
|
if (s->null_termination) {
|
||||||
fprintf(stdout, " %s%c", it->string, 0);
|
fprintf(stdout, " %s%c", it->string, 0);
|
||||||
} else {
|
} else {
|
||||||
struct strbuf onebuf = STRBUF_INIT;
|
struct strbuf onebuf = STRBUF_INIT;
|
||||||
|
@ -804,7 +804,7 @@ static void wt_shortstatus_unmerged(int null_termination, struct string_list_ite
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_shortstatus_status(int null_termination, struct string_list_item *it,
|
static void wt_shortstatus_status(struct string_list_item *it,
|
||||||
struct wt_status *s)
|
struct wt_status *s)
|
||||||
{
|
{
|
||||||
struct wt_status_change_data *d = it->util;
|
struct wt_status_change_data *d = it->util;
|
||||||
|
@ -818,7 +818,7 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
|
||||||
else
|
else
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
putchar(' ');
|
putchar(' ');
|
||||||
if (null_termination) {
|
if (s->null_termination) {
|
||||||
fprintf(stdout, "%s%c", it->string, 0);
|
fprintf(stdout, "%s%c", it->string, 0);
|
||||||
if (d->head_path)
|
if (d->head_path)
|
||||||
fprintf(stdout, "%s%c", d->head_path, 0);
|
fprintf(stdout, "%s%c", d->head_path, 0);
|
||||||
|
@ -846,10 +846,10 @@ static void wt_shortstatus_status(int null_termination, struct string_list_item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wt_shortstatus_other(int null_termination, struct string_list_item *it,
|
static void wt_shortstatus_other(struct string_list_item *it,
|
||||||
struct wt_status *s, const char *sign)
|
struct wt_status *s, const char *sign)
|
||||||
{
|
{
|
||||||
if (null_termination) {
|
if (s->null_termination) {
|
||||||
fprintf(stdout, "%s %s%c", sign, it->string, 0);
|
fprintf(stdout, "%s %s%c", sign, it->string, 0);
|
||||||
} else {
|
} else {
|
||||||
struct strbuf onebuf = STRBUF_INIT;
|
struct strbuf onebuf = STRBUF_INIT;
|
||||||
|
@ -889,8 +889,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
|
||||||
if (s->is_initial)
|
if (s->is_initial)
|
||||||
color_fprintf(s->fp, header_color, _("Initial commit on "));
|
color_fprintf(s->fp, header_color, _("Initial commit on "));
|
||||||
if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
|
if (!stat_tracking_info(branch, &num_ours, &num_theirs)) {
|
||||||
color_fprintf_ln(s->fp, branch_color_local,
|
color_fprintf(s->fp, branch_color_local, "%s", branch_name);
|
||||||
"%s", branch_name);
|
fputc(s->null_termination ? '\0' : '\n', s->fp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -914,14 +914,15 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
|
||||||
color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
|
color_fprintf(s->fp, branch_color_remote, "%d", num_theirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
color_fprintf_ln(s->fp, header_color, "]");
|
color_fprintf(s->fp, header_color, "]");
|
||||||
|
fputc(s->null_termination ? '\0' : '\n', s->fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch)
|
void wt_shortstatus_print(struct wt_status *s)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (show_branch)
|
if (s->show_branch)
|
||||||
wt_shortstatus_print_tracking(s);
|
wt_shortstatus_print_tracking(s);
|
||||||
|
|
||||||
for (i = 0; i < s->change.nr; i++) {
|
for (i = 0; i < s->change.nr; i++) {
|
||||||
|
@ -931,28 +932,28 @@ void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_br
|
||||||
it = &(s->change.items[i]);
|
it = &(s->change.items[i]);
|
||||||
d = it->util;
|
d = it->util;
|
||||||
if (d->stagemask)
|
if (d->stagemask)
|
||||||
wt_shortstatus_unmerged(null_termination, it, s);
|
wt_shortstatus_unmerged(it, s);
|
||||||
else
|
else
|
||||||
wt_shortstatus_status(null_termination, it, s);
|
wt_shortstatus_status(it, s);
|
||||||
}
|
}
|
||||||
for (i = 0; i < s->untracked.nr; i++) {
|
for (i = 0; i < s->untracked.nr; i++) {
|
||||||
struct string_list_item *it;
|
struct string_list_item *it;
|
||||||
|
|
||||||
it = &(s->untracked.items[i]);
|
it = &(s->untracked.items[i]);
|
||||||
wt_shortstatus_other(null_termination, it, s, "??");
|
wt_shortstatus_other(it, s, "??");
|
||||||
}
|
}
|
||||||
for (i = 0; i < s->ignored.nr; i++) {
|
for (i = 0; i < s->ignored.nr; i++) {
|
||||||
struct string_list_item *it;
|
struct string_list_item *it;
|
||||||
|
|
||||||
it = &(s->ignored.items[i]);
|
it = &(s->ignored.items[i]);
|
||||||
wt_shortstatus_other(null_termination, it, s, "!!");
|
wt_shortstatus_other(it, s, "!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wt_porcelain_print(struct wt_status *s, int null_termination)
|
void wt_porcelain_print(struct wt_status *s)
|
||||||
{
|
{
|
||||||
s->use_color = 0;
|
s->use_color = 0;
|
||||||
s->relative_paths = 0;
|
s->relative_paths = 0;
|
||||||
s->prefix = NULL;
|
s->prefix = NULL;
|
||||||
wt_shortstatus_print(s, null_termination, 0);
|
wt_shortstatus_print(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ struct wt_status {
|
||||||
enum untracked_status_type show_untracked_files;
|
enum untracked_status_type show_untracked_files;
|
||||||
const char *ignore_submodule_arg;
|
const char *ignore_submodule_arg;
|
||||||
char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
|
char color_palette[WT_STATUS_MAXSLOT][COLOR_MAXLEN];
|
||||||
|
int null_termination;
|
||||||
|
int show_branch;
|
||||||
|
|
||||||
/* These are computed during processing of the individual sections */
|
/* These are computed during processing of the individual sections */
|
||||||
int commitable;
|
int commitable;
|
||||||
|
@ -72,8 +74,8 @@ void wt_status_prepare(struct wt_status *s);
|
||||||
void wt_status_print(struct wt_status *s);
|
void wt_status_print(struct wt_status *s);
|
||||||
void wt_status_collect(struct wt_status *s);
|
void wt_status_collect(struct wt_status *s);
|
||||||
|
|
||||||
void wt_shortstatus_print(struct wt_status *s, int null_termination, int show_branch);
|
void wt_shortstatus_print(struct wt_status *s);
|
||||||
void wt_porcelain_print(struct wt_status *s, int null_termination);
|
void wt_porcelain_print(struct wt_status *s);
|
||||||
|
|
||||||
void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...)
|
void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, ...)
|
||||||
;
|
;
|
||||||
|
|
Loading…
Reference in a new issue