Merge branch 'ss/wt-status-committable'
Code clean-up in the internal machinery used by "git status" and "git commit --dry-run". * ss/wt-status-committable: roll wt_status_state into wt_status and populate in the collect phase wt-status.c: set the committable flag in the collect phase t7501: add test of "commit --dry-run --short" wt-status: rename commitable to committable wt-status.c: move has_unmerged earlier in the file
This commit is contained in:
@ -508,8 +508,9 @@ static int run_status(FILE *fp, const char *index_file, const char *prefix, int
|
||||
|
||||
wt_status_collect(s);
|
||||
wt_status_print(s);
|
||||
wt_status_collect_free_buffers(s);
|
||||
|
||||
return s->commitable;
|
||||
return s->committable;
|
||||
}
|
||||
|
||||
static int is_a_merge(const struct commit *current_head)
|
||||
@ -655,7 +656,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||
{
|
||||
struct stat statbuf;
|
||||
struct strbuf committer_ident = STRBUF_INIT;
|
||||
int commitable;
|
||||
int committable;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
const char *hook_arg1 = NULL;
|
||||
const char *hook_arg2 = NULL;
|
||||
@ -872,7 +873,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||
|
||||
saved_color_setting = s->use_color;
|
||||
s->use_color = 0;
|
||||
commitable = run_status(s->fp, index_file, prefix, 1, s);
|
||||
committable = run_status(s->fp, index_file, prefix, 1, s);
|
||||
s->use_color = saved_color_setting;
|
||||
string_list_clear(&s->change, 1);
|
||||
} else {
|
||||
@ -891,7 +892,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||
for (i = 0; i < active_nr; i++)
|
||||
if (ce_intent_to_add(active_cache[i]))
|
||||
ita_nr++;
|
||||
commitable = active_nr - ita_nr > 0;
|
||||
committable = active_nr - ita_nr > 0;
|
||||
} else {
|
||||
/*
|
||||
* Unless the user did explicitly request a submodule
|
||||
@ -907,7 +908,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||
if (ignore_submodule_arg &&
|
||||
!strcmp(ignore_submodule_arg, "all"))
|
||||
flags.ignore_submodules = 1;
|
||||
commitable = index_differs_from(parent, &flags, 1);
|
||||
committable = index_differs_from(parent, &flags, 1);
|
||||
}
|
||||
}
|
||||
strbuf_release(&committer_ident);
|
||||
@ -919,7 +920,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
|
||||
* explicit --allow-empty. In the cherry-pick case, it may be
|
||||
* empty due to conflict resolution, which the user should okay.
|
||||
*/
|
||||
if (!commitable && whence != FROM_MERGE && !allow_empty &&
|
||||
if (!committable && whence != FROM_MERGE && !allow_empty &&
|
||||
!(amend && is_a_merge(current_head))) {
|
||||
s->display_comment_prefix = old_display_comment_prefix;
|
||||
run_status(stdout, index_file, prefix, 0, s);
|
||||
@ -1189,14 +1190,14 @@ static int parse_and_validate_options(int argc, const char *argv[],
|
||||
static int dry_run_commit(int argc, const char **argv, const char *prefix,
|
||||
const struct commit *current_head, struct wt_status *s)
|
||||
{
|
||||
int commitable;
|
||||
int committable;
|
||||
const char *index_file;
|
||||
|
||||
index_file = prepare_index(argc, argv, prefix, current_head, 1);
|
||||
commitable = run_status(stdout, index_file, prefix, 0, s);
|
||||
committable = run_status(stdout, index_file, prefix, 0, s);
|
||||
rollback_index_files();
|
||||
|
||||
return commitable ? 0 : 1;
|
||||
return committable ? 0 : 1;
|
||||
}
|
||||
|
||||
define_list_config_array_extra(color_status_slots, {"added"});
|
||||
@ -1391,6 +1392,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
s.prefix = prefix;
|
||||
|
||||
wt_status_print(&s);
|
||||
wt_status_collect_free_buffers(&s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user