@ -776,9 +776,14 @@ void wt_status_collect(struct wt_status *s)
@@ -776,9 +776,14 @@ void wt_status_collect(struct wt_status *s)
void wt_status_collect_free_buffers(struct wt_status *s)
{
free(s->state.branch);
free(s->state.onto);
free(s->state.detached_from);
wt_status_state_free_buffers(&s->state);
}
void wt_status_state_free_buffers(struct wt_status_state *state)
{
FREE_AND_NULL(state->branch);
FREE_AND_NULL(state->onto);
FREE_AND_NULL(state->detached_from);
}
static void wt_longstatus_print_unmerged(struct wt_status *s)
@ -1225,7 +1230,7 @@ static int split_commit_in_progress(struct wt_status *s)
@@ -1225,7 +1230,7 @@ static int split_commit_in_progress(struct wt_status *s)
* The function assumes that the line does not contain useless spaces
* before or after the command.
*/
static void abbrev_sha1_in_line(struct strbuf *line)
static void abbrev_oid_in_line(struct strbuf *line)
{
struct strbuf **split;
int i;
@ -1275,7 +1280,7 @@ static int read_rebase_todolist(const char *fname, struct string_list *lines)
@@ -1275,7 +1280,7 @@ static int read_rebase_todolist(const char *fname, struct string_list *lines)
strbuf_trim(&line);
if (!line.len)
continue;
abbrev_sha1_in_line(&line);
abbrev_oid_in_line(&line);
string_list_append(lines, line.buf);
}
fclose(f);
@ -1568,9 +1573,9 @@ static void wt_status_get_detached_from(struct repository *r,
@@ -1568,9 +1573,9 @@ static void wt_status_get_detached_from(struct repository *r,
}
if (dwim_ref(cb.buf.buf, cb.buf.len, &oid, &ref, 1) == 1 &&
/* sha1 is a commit? match without further lookup */
/* oid is a commit? match without further lookup */
(oideq(&cb.noid, &oid) ||
/* perhaps sha1 is a tag, try to dereference to a commit */
/* perhaps oid is a tag, try to dereference to a commit */
((commit = lookup_commit_reference_gently(r, &oid, 1)) != NULL &&
oideq(&cb.noid, &commit->object.oid)))) {
const char *from = ref;
@ -1799,29 +1804,36 @@ static void wt_longstatus_print(struct wt_status *s)
@@ -1799,29 +1804,36 @@ static void wt_longstatus_print(struct wt_status *s)
; /* nothing */
else if (s->workdir_dirty) {
if (s->hints)
printf(_("no changes added to commit "
"(use \"git add\" and/or \"git commit -a\")\n"));
fprintf(s->fp, _("no changes added to commit "
"(use \"git add\" and/or "
"\"git commit -a\")\n"));
else
printf(_("no changes added to commit\n"));
fprintf(s->fp, _("no changes added to "
"commit\n"));
} else if (s->untracked.nr) {
if (s->hints)
printf(_("nothing added to commit but untracked files "
"present (use \"git add\" to track)\n"));
fprintf(s->fp, _("nothing added to commit but "
"untracked files present (use "
"\"git add\" to track)\n"));
else
printf(_("nothing added to commit but untracked files present\n"));
fprintf(s->fp, _("nothing added to commit but "
"untracked files present\n"));
} else if (s->is_initial) {
if (s->hints)
printf(_("nothing to commit (create/copy files "
"and use \"git add\" to track)\n"));
fprintf(s->fp, _("nothing to commit (create/"
"copy files and use \"git "
"add\" to track)\n"));
else
printf(_("nothing to commit\n"));
fprintf(s->fp, _("nothing to commit\n"));
} else if (!s->show_untracked_files) {
if (s->hints)
printf(_("nothing to commit (use -u to show untracked files)\n"));
fprintf(s->fp, _("nothing to commit (use -u to "
"show untracked files)\n"));
else
printf(_("nothing to commit\n"));
fprintf(s->fp, _("nothing to commit\n"));
} else
printf(_("nothing to commit, working tree clean\n"));
fprintf(s->fp, _("nothing to commit, working tree "
"clean\n"));
}
if(s->show_stash)
wt_longstatus_print_stash_summary(s);
@ -1844,12 +1856,12 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
@@ -1844,12 +1856,12 @@ static void wt_shortstatus_unmerged(struct string_list_item *it,
}
color_fprintf(s->fp, color(WT_STATUS_UNMERGED, s), "%s", how);
if (s->null_termination) {
fprintf(stdout, " %s%c", it->string, 0);
fprintf(s->fp, " %s%c", it->string, 0);
} else {
struct strbuf onebuf = STRBUF_INIT;
const char *one;
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
printf(" %s\n", one);
fprintf(s->fp, " %s\n", one);
strbuf_release(&onebuf);
}
}
@ -1862,16 +1874,16 @@ static void wt_shortstatus_status(struct string_list_item *it,
@@ -1862,16 +1874,16 @@ static void wt_shortstatus_status(struct string_list_item *it,
if (d->index_status)
color_fprintf(s->fp, color(WT_STATUS_UPDATED, s), "%c", d->index_status);
else
putchar(' ');
fputc(' ', s->fp);
if (d->worktree_status)
color_fprintf(s->fp, color(WT_STATUS_CHANGED, s), "%c", d->worktree_status);
else
putchar(' ');
putchar(' ');
fputc(' ', s->fp);
fputc(' ', s->fp);
if (s->null_termination) {
fprintf(stdout, "%s%c", it->string, 0);
fprintf(s->fp, "%s%c", it->string, 0);
if (d->rename_source)
fprintf(stdout, "%s%c", d->rename_source, 0);
fprintf(s->fp, "%s%c", d->rename_source, 0);
} else {
struct strbuf onebuf = STRBUF_INIT;
const char *one;
@ -1879,11 +1891,11 @@ static void wt_shortstatus_status(struct string_list_item *it,
@@ -1879,11 +1891,11 @@ static void wt_shortstatus_status(struct string_list_item *it,
if (d->rename_source) {
one = quote_path(d->rename_source, s->prefix, &onebuf,
QUOTE_PATH_QUOTE_SP);
printf("%s -> ", one);
fprintf(s->fp, "%s -> ", one);
strbuf_release(&onebuf);
}
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
printf("%s\n", one);
fprintf(s->fp, "%s\n", one);
strbuf_release(&onebuf);
}
}
@ -1892,13 +1904,13 @@ static void wt_shortstatus_other(struct string_list_item *it,
@@ -1892,13 +1904,13 @@ static void wt_shortstatus_other(struct string_list_item *it,
struct wt_status *s, const char *sign)
{
if (s->null_termination) {
fprintf(stdout, "%s %s%c", sign, it->string, 0);
fprintf(s->fp, "%s %s%c", sign, it->string, 0);
} else {
struct strbuf onebuf = STRBUF_INIT;
const char *one;
one = quote_path(it->string, s->prefix, &onebuf, QUOTE_PATH_QUOTE_SP);
color_fprintf(s->fp, color(WT_STATUS_UNTRACKED, s), "%s", sign);
printf(" %s\n", one);
fprintf(s->fp, " %s\n", one);
strbuf_release(&onebuf);
}
}