fetch: pass summary_width down the callchain
The leaf function on the "fetch" side that uses TRANSPORT_SUMMARY_WIDTH constant is builtin/fetch.c::format_display() and it has two distinct callchains. The one that reports the primary result of fetch originates at store_updated_refs(); the other one that reports the pruning of the remote-tracking refs originates at prune_refs(). Teach these two places to pass summary_width down the callchain, just like we did for the "push" side in the previous commit. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -17,9 +17,6 @@
|
|||||||
#include "argv-array.h"
|
#include "argv-array.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
|
|
||||||
#define TRANSPORT_SUMMARY(x) \
|
|
||||||
(int)(TRANSPORT_SUMMARY_WIDTH + strlen(x) - gettext_width(x)), (x)
|
|
||||||
|
|
||||||
static const char * const builtin_fetch_usage[] = {
|
static const char * const builtin_fetch_usage[] = {
|
||||||
N_("git fetch [<options>] [<repository> [<refspec>...]]"),
|
N_("git fetch [<options>] [<repository> [<refspec>...]]"),
|
||||||
N_("git fetch [<options>] <group>"),
|
N_("git fetch [<options>] <group>"),
|
||||||
@ -569,9 +566,12 @@ static void print_compact(struct strbuf *display,
|
|||||||
|
|
||||||
static void format_display(struct strbuf *display, char code,
|
static void format_display(struct strbuf *display, char code,
|
||||||
const char *summary, const char *error,
|
const char *summary, const char *error,
|
||||||
const char *remote, const char *local)
|
const char *remote, const char *local,
|
||||||
|
int summary_width)
|
||||||
{
|
{
|
||||||
strbuf_addf(display, "%c %-*s ", code, TRANSPORT_SUMMARY(summary));
|
int width = (summary_width + strlen(summary) - gettext_width(summary));
|
||||||
|
|
||||||
|
strbuf_addf(display, "%c %-*s ", code, width, summary);
|
||||||
if (!compact_format)
|
if (!compact_format)
|
||||||
print_remote_to_local(display, remote, local);
|
print_remote_to_local(display, remote, local);
|
||||||
else
|
else
|
||||||
@ -583,7 +583,8 @@ static void format_display(struct strbuf *display, char code,
|
|||||||
static int update_local_ref(struct ref *ref,
|
static int update_local_ref(struct ref *ref,
|
||||||
const char *remote,
|
const char *remote,
|
||||||
const struct ref *remote_ref,
|
const struct ref *remote_ref,
|
||||||
struct strbuf *display)
|
struct strbuf *display,
|
||||||
|
int summary_width)
|
||||||
{
|
{
|
||||||
struct commit *current = NULL, *updated;
|
struct commit *current = NULL, *updated;
|
||||||
enum object_type type;
|
enum object_type type;
|
||||||
@ -597,7 +598,7 @@ static int update_local_ref(struct ref *ref,
|
|||||||
if (!oidcmp(&ref->old_oid, &ref->new_oid)) {
|
if (!oidcmp(&ref->old_oid, &ref->new_oid)) {
|
||||||
if (verbosity > 0)
|
if (verbosity > 0)
|
||||||
format_display(display, '=', _("[up to date]"), NULL,
|
format_display(display, '=', _("[up to date]"), NULL,
|
||||||
remote, pretty_ref);
|
remote, pretty_ref, summary_width);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,7 +612,7 @@ static int update_local_ref(struct ref *ref,
|
|||||||
*/
|
*/
|
||||||
format_display(display, '!', _("[rejected]"),
|
format_display(display, '!', _("[rejected]"),
|
||||||
_("can't fetch in current branch"),
|
_("can't fetch in current branch"),
|
||||||
remote, pretty_ref);
|
remote, pretty_ref, summary_width);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +622,7 @@ static int update_local_ref(struct ref *ref,
|
|||||||
r = s_update_ref("updating tag", ref, 0);
|
r = s_update_ref("updating tag", ref, 0);
|
||||||
format_display(display, r ? '!' : 't', _("[tag update]"),
|
format_display(display, r ? '!' : 't', _("[tag update]"),
|
||||||
r ? _("unable to update local ref") : NULL,
|
r ? _("unable to update local ref") : NULL,
|
||||||
remote, pretty_ref);
|
remote, pretty_ref, summary_width);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -654,7 +655,7 @@ static int update_local_ref(struct ref *ref,
|
|||||||
r = s_update_ref(msg, ref, 0);
|
r = s_update_ref(msg, ref, 0);
|
||||||
format_display(display, r ? '!' : '*', what,
|
format_display(display, r ? '!' : '*', what,
|
||||||
r ? _("unable to update local ref") : NULL,
|
r ? _("unable to update local ref") : NULL,
|
||||||
remote, pretty_ref);
|
remote, pretty_ref, summary_width);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,7 +671,7 @@ static int update_local_ref(struct ref *ref,
|
|||||||
r = s_update_ref("fast-forward", ref, 1);
|
r = s_update_ref("fast-forward", ref, 1);
|
||||||
format_display(display, r ? '!' : ' ', quickref.buf,
|
format_display(display, r ? '!' : ' ', quickref.buf,
|
||||||
r ? _("unable to update local ref") : NULL,
|
r ? _("unable to update local ref") : NULL,
|
||||||
remote, pretty_ref);
|
remote, pretty_ref, summary_width);
|
||||||
strbuf_release(&quickref);
|
strbuf_release(&quickref);
|
||||||
return r;
|
return r;
|
||||||
} else if (force || ref->force) {
|
} else if (force || ref->force) {
|
||||||
@ -685,12 +686,12 @@ static int update_local_ref(struct ref *ref,
|
|||||||
r = s_update_ref("forced-update", ref, 1);
|
r = s_update_ref("forced-update", ref, 1);
|
||||||
format_display(display, r ? '!' : '+', quickref.buf,
|
format_display(display, r ? '!' : '+', quickref.buf,
|
||||||
r ? _("unable to update local ref") : _("forced update"),
|
r ? _("unable to update local ref") : _("forced update"),
|
||||||
remote, pretty_ref);
|
remote, pretty_ref, summary_width);
|
||||||
strbuf_release(&quickref);
|
strbuf_release(&quickref);
|
||||||
return r;
|
return r;
|
||||||
} else {
|
} else {
|
||||||
format_display(display, '!', _("[rejected]"), _("non-fast-forward"),
|
format_display(display, '!', _("[rejected]"), _("non-fast-forward"),
|
||||||
remote, pretty_ref);
|
remote, pretty_ref, summary_width);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -721,6 +722,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
|
|||||||
char *url;
|
char *url;
|
||||||
const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
|
const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
|
||||||
int want_status;
|
int want_status;
|
||||||
|
int summary_width = TRANSPORT_SUMMARY_WIDTH;
|
||||||
|
|
||||||
fp = fopen(filename, "a");
|
fp = fopen(filename, "a");
|
||||||
if (!fp)
|
if (!fp)
|
||||||
@ -830,13 +832,14 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
|
|||||||
|
|
||||||
strbuf_reset(¬e);
|
strbuf_reset(¬e);
|
||||||
if (ref) {
|
if (ref) {
|
||||||
rc |= update_local_ref(ref, what, rm, ¬e);
|
rc |= update_local_ref(ref, what, rm, ¬e,
|
||||||
|
summary_width);
|
||||||
free(ref);
|
free(ref);
|
||||||
} else
|
} else
|
||||||
format_display(¬e, '*',
|
format_display(¬e, '*',
|
||||||
*kind ? kind : "branch", NULL,
|
*kind ? kind : "branch", NULL,
|
||||||
*what ? what : "HEAD",
|
*what ? what : "HEAD",
|
||||||
"FETCH_HEAD");
|
"FETCH_HEAD", summary_width);
|
||||||
if (note.len) {
|
if (note.len) {
|
||||||
if (verbosity >= 0 && !shown_url) {
|
if (verbosity >= 0 && !shown_url) {
|
||||||
fprintf(stderr, _("From %.*s\n"),
|
fprintf(stderr, _("From %.*s\n"),
|
||||||
@ -903,6 +906,7 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
|
|||||||
int url_len, i, result = 0;
|
int url_len, i, result = 0;
|
||||||
struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
|
struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
|
||||||
char *url;
|
char *url;
|
||||||
|
int summary_width = TRANSPORT_SUMMARY_WIDTH;
|
||||||
const char *dangling_msg = dry_run
|
const char *dangling_msg = dry_run
|
||||||
? _(" (%s will become dangling)")
|
? _(" (%s will become dangling)")
|
||||||
: _(" (%s has become dangling)");
|
: _(" (%s has become dangling)");
|
||||||
@ -938,7 +942,8 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
|
|||||||
shown_url = 1;
|
shown_url = 1;
|
||||||
}
|
}
|
||||||
format_display(&sb, '-', _("[deleted]"), NULL,
|
format_display(&sb, '-', _("[deleted]"), NULL,
|
||||||
_("(none)"), prettify_refname(ref->name));
|
_("(none)"), prettify_refname(ref->name),
|
||||||
|
summary_width);
|
||||||
fprintf(stderr, " %s\n",sb.buf);
|
fprintf(stderr, " %s\n",sb.buf);
|
||||||
strbuf_release(&sb);
|
strbuf_release(&sb);
|
||||||
warn_dangling_symref(stderr, dangling_msg, ref->name);
|
warn_dangling_symref(stderr, dangling_msg, ref->name);
|
||||||
|
Reference in New Issue
Block a user