From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] fetch: better alignment in ref summary
Date: Mon, 8 Sep 2014 14:40:02 +0700 [thread overview]
Message-ID: <1410162002-15608-1-git-send-email-pclouds@gmail.com> (raw)
Currently fetch hard-codes the "remote" column to be 10. For repos
with long branch names, the output could look ugly like this
From github.com:pclouds/git
* [new branch] 2nd-index -> pclouds/2nd-index
* [new branch] 3nd-index -> pclouds/3nd-index
* [new branch] file-watcher -> pclouds/file-watcher
* [new branch] inst -> pclouds/inst
* [new branch] large-file-fixes -> pclouds/large-file-fixes
* [new branch] ls -> pclouds/ls
* [new branch] master -> pclouds/master
* [new branch] multiple-work-trees -> pclouds/multiple-work-trees
* [new branch] mv -> pclouds/mv
* [new branch] read-cache-daemon -> pclouds/read-cache-daemon
* [new branch] split-blob -> pclouds/split-blob
* [new branch] split-index -> pclouds/split-index
* [new branch] status-fast-fast -> pclouds/status-fast-fast
* [new branch] untracked-cache -> pclouds/untracked-cache
This patch makes the output a bit better with minimum code change
From github.com:pclouds/git
* [new branch] 2nd-index -> pclouds/2nd-index
* [new branch] 3nd-index -> pclouds/3nd-index
* [new branch] file-watcher -> pclouds/file-watcher
* [new branch] inst -> pclouds/inst
* [new branch] large-file-fixes -> pclouds/large-file-fixes
* [new branch] ls -> pclouds/ls
* [new branch] master -> pclouds/master
* [new branch] multiple-work-trees -> pclouds/multiple-work-trees
* [new branch] mv -> pclouds/mv
* [new branch] read-cache-daemon -> pclouds/read-cache-daemon
* [new branch] split-blob -> pclouds/split-blob
* [new branch] split-index -> pclouds/split-index
* [new branch] status-fast-fast -> pclouds/status-fast-fast
* [new branch] untracked-cache -> pclouds/untracked-cache
To make all "->" aligned, we may need to go through the ref list
twice, or buffer the output and let column.c align it. Either way
needs a lot more work than this.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Maybe good enough for other people as well, I don't know..
builtin/fetch.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 7320395..84e47dd 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -436,7 +436,7 @@ fail:
: STORE_REF_ERROR_OTHER;
}
-#define REFCOL_WIDTH 10
+static int REFCOL_WIDTH = 10;
static int update_local_ref(struct ref *ref,
const char *remote,
@@ -447,6 +447,10 @@ static int update_local_ref(struct ref *ref,
enum object_type type;
struct branch *current_branch = branch_get(NULL);
const char *pretty_ref = prettify_refname(ref->name);
+ int len = gettext_width(remote);
+
+ if (REFCOL_WIDTH < len)
+ REFCOL_WIDTH = len;
type = sha1_object_info(ref->new_sha1, NULL);
if (type < 0)
--
2.0.2.841.g8f98430
reply other threads:[~2014-09-08 7:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410162002-15608-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.