{"thread":{"id":"37511","subject":"[PATCH] fetch: better alignment in ref summary","startedAt":"2014-09-08T07:40:02Z","lastAt":"2014-09-08T07:40:02Z","messageCount":1,"participants":["Nguyễn Thái Ngọc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"249024","messageId":"1410162002-15608-1-git-send-email-pclouds@gmail.com","threadId":"37511","inReplyTo":null,"subject":"[PATCH] fetch: better alignment in ref summary","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2014-09-08T07:40:02Z","receivedAt":"2014-09-08T07:40:02Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Currently fetch hard-codes the \"remote\" column to be 10. For repos\nwith long branch names, the output could look ugly like this\n\nFrom github.com:pclouds/git\n * [new branch]      2nd-index  -> pclouds/2nd-index\n * [new branch]      3nd-index  -> pclouds/3nd-index\n * [new branch]      file-watcher -> pclouds/file-watcher\n * [new branch]      inst       -> pclouds/inst\n * [new branch]      large-file-fixes -> pclouds/large-file-fixes\n * [new branch]      ls         -> pclouds/ls\n * [new branch]      master     -> pclouds/master\n * [new branch]      multiple-work-trees -> pclouds/multiple-work-trees\n * [new branch]      mv         -> pclouds/mv\n * [new branch]      read-cache-daemon -> pclouds/read-cache-daemon\n * [new branch]      split-blob -> pclouds/split-blob\n * [new branch]      split-index -> pclouds/split-index\n * [new branch]      status-fast-fast -> pclouds/status-fast-fast\n * [new branch]      untracked-cache -> pclouds/untracked-cache\n\nThis patch makes the output a bit better with minimum code change\n\nFrom github.com:pclouds/git\n * [new branch]      2nd-index  -> pclouds/2nd-index\n * [new branch]      3nd-index  -> pclouds/3nd-index\n * [new branch]      file-watcher -> pclouds/file-watcher\n * [new branch]      inst         -> pclouds/inst\n * [new branch]      large-file-fixes -> pclouds/large-file-fixes\n * [new branch]      ls               -> pclouds/ls\n * [new branch]      master           -> pclouds/master\n * [new branch]      multiple-work-trees -> pclouds/multiple-work-trees\n * [new branch]      mv                  -> pclouds/mv\n * [new branch]      read-cache-daemon   -> pclouds/read-cache-daemon\n * [new branch]      split-blob          -> pclouds/split-blob\n * [new branch]      split-index         -> pclouds/split-index\n * [new branch]      status-fast-fast    -> pclouds/status-fast-fast\n * [new branch]      untracked-cache     -> pclouds/untracked-cache\n\nTo make all \"->\" aligned, we may need to go through the ref list\ntwice, or buffer the output and let column.c align it. Either way\nneeds a lot more work than this.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Maybe good enough for other people as well, I don't know..\n\n builtin/fetch.c | 6 +++++-\n 1 file changed, 5 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/fetch.c b/builtin/fetch.c\nindex 7320395..84e47dd 100644\n--- a/builtin/fetch.c\n+++ b/builtin/fetch.c\n@@ -436,7 +436,7 @@ fail:\n \t\t\t   : STORE_REF_ERROR_OTHER;\n }\n \n-#define REFCOL_WIDTH  10\n+static int REFCOL_WIDTH = 10;\n \n static int update_local_ref(struct ref *ref,\n \t\t\t    const char *remote,\n@@ -447,6 +447,10 @@ static int update_local_ref(struct ref *ref,\n \tenum object_type type;\n \tstruct branch *current_branch = branch_get(NULL);\n \tconst char *pretty_ref = prettify_refname(ref->name);\n+\tint len = gettext_width(remote);\n+\n+\tif (REFCOL_WIDTH < len)\n+\t\tREFCOL_WIDTH = len;\n \n \ttype = sha1_object_info(ref->new_sha1, NULL);\n \tif (type < 0)\n-- \n2.0.2.841.g8f98430\n"}]}