* [PATCH] fetch: better alignment in ref summary
@ 2014-09-08 7:40 Nguyễn Thái Ngọc Duy
0 siblings, 0 replies; only message in thread
From: Nguyễn Thái Ngọc Duy @ 2014-09-08 7:40 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-09-08 7:40 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-08 7:40 [PATCH] fetch: better alignment in ref summary Nguyễn Thái Ngọc Duy
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.