Commit 73ba5d78 authored by Stephen P. Smith's avatar Stephen P. Smith Committed by Junio C Hamano

roll wt_status_state into wt_status and populate in the collect phase

Status variables were initialized in the collect phase and some
variables were later freed in the print functions.

A "struct wt_status" used to be sufficient for the output phase to
work.  It was designed to be filled in the collect phase and consumed
in the output phase, but over time some fields were added and output
phase started filling the fields.

A "struct wt_status_state" that was used in other codepaths turned out
to be useful in the "git status" output.  This is not tied to "struct
wt_status", so filling in the collect phase was not consistently
followed.

Move the status state structure variables into the status state
structure and populate them in the collect functions.

Create a new function to free the buffers that were being freed in the
print function.  Call this new function in commit.c where both the
collect and print functions were being called.

Based on a patch suggestion by Junio C Hamano. [1]

[1] https://public-inbox.org/git/xmqqr2i5ueg4.fsf@gitster-ct.c.googlers.com/Signed-off-by: default avatarStephen P. Smith <ischis2@cox.net>
Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
parent f3bd35fa
......@@ -506,6 +506,7 @@ 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->committable;
}
......@@ -1388,6 +1389,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;
}
......
This diff is collapsed.
......@@ -64,6 +64,24 @@ enum wt_status_format {
STATUS_FORMAT_UNSPECIFIED
};
struct wt_status_state {
int merge_in_progress;
int am_in_progress;
int am_empty_patch;
int rebase_in_progress;
int rebase_interactive_in_progress;
int cherry_pick_in_progress;
int bisect_in_progress;
int revert_in_progress;
int detached_at;
char *branch;
char *onto;
char *detached_from;
struct object_id detached_oid;
struct object_id revert_head_oid;
struct object_id cherry_pick_head_oid;
};
struct wt_status {
int is_initial;
char *branch;
......@@ -93,6 +111,7 @@ struct wt_status {
int rename_score;
int rename_limit;
enum wt_status_format status_format;
struct wt_status_state state;
unsigned char sha1_commit[GIT_MAX_RAWSZ]; /* when not Initial */
/* These are computed during processing of the individual sections */
......@@ -107,29 +126,12 @@ struct wt_status {
uint32_t untracked_in_ms;
};
struct wt_status_state {
int merge_in_progress;
int am_in_progress;
int am_empty_patch;
int rebase_in_progress;
int rebase_interactive_in_progress;
int cherry_pick_in_progress;
int bisect_in_progress;
int revert_in_progress;
int detached_at;
char *branch;
char *onto;
char *detached_from;
struct object_id detached_oid;
struct object_id revert_head_oid;
struct object_id cherry_pick_head_oid;
};
size_t wt_status_locate_end(const char *s, size_t len);
void wt_status_add_cut_line(FILE *fp);
void wt_status_prepare(struct wt_status *s);
void wt_status_print(struct wt_status *s);
void wt_status_collect(struct wt_status *s);
void wt_status_collect_free_buffers(struct wt_status *s);
void wt_status_get_state(struct wt_status_state *state, int get_detached_from);
int wt_status_check_rebase(const struct worktree *wt,
struct wt_status_state *state);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment