]> granicus.if.org Git - git/commitdiff
transport: allow summary-width to be computed dynamically
authorJunio C Hamano <gitster@pobox.com>
Fri, 21 Oct 2016 22:28:07 +0000 (15:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Oct 2016 22:28:07 +0000 (15:28 -0700)
Now we have identified three callchains that have a set of refs that
they want to show their <old, new> object names in an aligned output,
we can replace their reference to the constant TRANSPORT_SUMMARY_WIDTH
with a helper function call to transport_summary_width() that takes
the set of ref as a parameter.  This step does not yet iterate over
the refs and compute, which is left as an exercise to the readers.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
transport.c
transport.h

index 40696e533892c6da6cd8bb5e8cdf380b54ddb5cf..09813cd826cbe0dfd196cb4ef120394f9b2a84a6 100644 (file)
@@ -722,7 +722,7 @@ static int store_updated_refs(const char *raw_url, const char *remote_name,
        char *url;
        const char *filename = dry_run ? "/dev/null" : git_path_fetch_head();
        int want_status;
-       int summary_width = TRANSPORT_SUMMARY_WIDTH;
+       int summary_width = transport_summary_width(ref_map);
 
        fp = fopen(filename, "a");
        if (!fp)
@@ -906,7 +906,7 @@ static int prune_refs(struct refspec *refs, int ref_count, struct ref *ref_map,
        int url_len, i, result = 0;
        struct ref *ref, *stale_refs = get_stale_heads(refs, ref_count, ref_map);
        char *url;
-       int summary_width = TRANSPORT_SUMMARY_WIDTH;
+       int summary_width = transport_summary_width(stale_refs);
        const char *dangling_msg = dry_run
                ? _("   (%s will become dangling)")
                : _("   (%s has become dangling)");
index ec02b789245d08044e07afc148fd7352cb4383f2..d4b8bf5f25c72fa37b68110ba6ccc527456e4ef9 100644 (file)
@@ -429,6 +429,11 @@ static int print_one_push_status(struct ref *ref, const char *dest, int count,
        return 1;
 }
 
+int transport_summary_width(const struct ref *refs)
+{
+       return (2 * FALLBACK_DEFAULT_ABBREV + 3);
+}
+
 void transport_print_push_status(const char *dest, struct ref *refs,
                                  int verbose, int porcelain, unsigned int *reject_reasons)
 {
@@ -436,7 +441,7 @@ void transport_print_push_status(const char *dest, struct ref *refs,
        int n = 0;
        unsigned char head_sha1[20];
        char *head;
-       int summary_width = TRANSPORT_SUMMARY_WIDTH;
+       int summary_width = transport_summary_width(refs);
 
        head = resolve_refdup("HEAD", RESOLVE_REF_READING, head_sha1, NULL);
 
index e783377e4004998e585182a015ba67c9db4b1575..706d99e8183a87f825b7e54c02b69f611b3664cf 100644 (file)
@@ -142,7 +142,7 @@ struct transport {
 #define TRANSPORT_PUSH_ATOMIC 8192
 #define TRANSPORT_PUSH_OPTIONS 16384
 
-#define TRANSPORT_SUMMARY_WIDTH (2 * FALLBACK_DEFAULT_ABBREV + 3)
+extern int transport_summary_width(const struct ref *refs);
 
 /* Returns a transport suitable for the url */
 struct transport *transport_get(struct remote *, const char *);