diff options
Diffstat (limited to 'wt-status.c')
| -rw-r--r-- | wt-status.c | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/wt-status.c b/wt-status.c index 6a6397ca8f..454601afa1 100644 --- a/wt-status.c +++ b/wt-status.c @@ -1,4 +1,5 @@ #define USE_THE_REPOSITORY_VARIABLE +#define DISABLE_SIGN_COMPARE_WARNINGS #include "git-compat-util.h" #include "advice.h" @@ -717,6 +718,7 @@ static int add_file_to_list(const struct object_id *oid, static void wt_status_collect_changes_initial(struct wt_status *s) { struct index_state *istate = s->repo->index; + struct strbuf base = STRBUF_INIT; int i; for (i = 0; i < istate->cache_nr; i++) { @@ -735,7 +737,6 @@ static void wt_status_collect_changes_initial(struct wt_status *s) * expanding the trees to find the elements that are new in this * tree and marking them with DIFF_STATUS_ADDED. */ - struct strbuf base = STRBUF_INIT; struct pathspec ps = { 0 }; struct tree *tree = lookup_tree(istate->repo, &ce->oid); @@ -743,9 +744,11 @@ static void wt_status_collect_changes_initial(struct wt_status *s) ps.has_wildcard = 1; ps.max_depth = -1; + strbuf_reset(&base); strbuf_add(&base, ce->name, ce->ce_namelen); read_tree_at(istate->repo, tree, &base, 0, &ps, add_file_to_list, s); + continue; } @@ -772,6 +775,8 @@ static void wt_status_collect_changes_initial(struct wt_status *s) s->committable = 1; } } + + strbuf_release(&base); } static void wt_status_collect_untracked(struct wt_status *s) @@ -1284,7 +1289,8 @@ static void show_am_in_progress(struct wt_status *s, static char *read_line_from_git_path(const char *filename) { struct strbuf buf = STRBUF_INIT; - FILE *fp = fopen_or_warn(git_path("%s", filename), "r"); + FILE *fp = fopen_or_warn(repo_git_path_append(the_repository, &buf, + "%s", filename), "r"); if (!fp) { strbuf_release(&buf); @@ -1378,27 +1384,33 @@ static void abbrev_oid_in_line(struct strbuf *line) static int read_rebase_todolist(const char *fname, struct string_list *lines) { - struct strbuf line = STRBUF_INIT; - FILE *f = fopen(git_path("%s", fname), "r"); + struct strbuf buf = STRBUF_INIT; + FILE *f = fopen(repo_git_path_append(the_repository, &buf, "%s", fname), "r"); + int ret; if (!f) { - if (errno == ENOENT) - return -1; + if (errno == ENOENT) { + ret = -1; + goto out; + } die_errno("Could not open file %s for reading", - git_path("%s", fname)); + repo_git_path_replace(the_repository, &buf, "%s", fname)); } - while (!strbuf_getline_lf(&line, f)) { - if (starts_with(line.buf, comment_line_str)) + while (!strbuf_getline_lf(&buf, f)) { + if (starts_with(buf.buf, comment_line_str)) continue; - strbuf_trim(&line); - if (!line.len) + strbuf_trim(&buf); + if (!buf.len) continue; - abbrev_oid_in_line(&line); - string_list_append(lines, line.buf); + abbrev_oid_in_line(&buf); + string_list_append(lines, buf.buf); } fclose(f); - strbuf_release(&line); - return 0; + + ret = 0; +out: + strbuf_release(&buf); + return ret; } static void show_rebase_information(struct wt_status *s, @@ -1429,9 +1441,12 @@ static void show_rebase_information(struct wt_status *s, i < have_done.nr; i++) status_printf_ln(s, color, " %s", have_done.items[i].string); - if (have_done.nr > nr_lines_to_show && s->hints) + if (have_done.nr > nr_lines_to_show && s->hints) { + char *path = repo_git_path(the_repository, "rebase-merge/done"); status_printf_ln(s, color, - _(" (see more in file %s)"), git_path("rebase-merge/done")); + _(" (see more in file %s)"), path); + free(path); + } } if (yet_to_do.nr == 0) @@ -1809,10 +1824,10 @@ void wt_status_get_state(struct repository *r, if (!sequencer_get_last_command(r, &action)) { if (action == REPLAY_PICK && !state->cherry_pick_in_progress) { state->cherry_pick_in_progress = 1; - oidcpy(&state->cherry_pick_head_oid, null_oid()); + oidcpy(&state->cherry_pick_head_oid, null_oid(the_hash_algo)); } else if (action == REPLAY_REVERT && !state->revert_in_progress) { state->revert_in_progress = 1; - oidcpy(&state->revert_head_oid, null_oid()); + oidcpy(&state->revert_head_oid, null_oid(the_hash_algo)); } } if (get_detached_from) |
