git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
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 1/2] fetch: better alignment in ref summary
Date: Sun, 22 May 2016 18:20:18 +0700	[thread overview]
Message-ID: <20160522112019.26516-2-pclouds@gmail.com> (raw)
In-Reply-To: <20160522112019.26516-1-pclouds@gmail.com>

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>
---
 builtin/fetch.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 1cf15d0..223e09b 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -465,7 +465,14 @@ fail:
 			   : STORE_REF_ERROR_OTHER;
 }
 
-#define REFCOL_WIDTH  10
+static int REFCOL_WIDTH = 10;
+
+static void adjust_refcol_width(int len)
+{
+	if (REFCOL_WIDTH < len) {
+		REFCOL_WIDTH = len;
+	}
+}
 
 static int update_local_ref(struct ref *ref,
 			    const char *remote,
@@ -477,6 +484,8 @@ static int update_local_ref(struct ref *ref,
 	struct branch *current_branch = branch_get(NULL);
 	const char *pretty_ref = prettify_refname(ref->name);
 
+	adjust_refcol_width(gettext_width(remote));
+
 	type = sha1_object_info(ref->new_oid.hash, NULL);
 	if (type < 0)
 		die(_("object %s not found"), oid_to_hex(&ref->new_oid));
-- 
2.8.2.524.g6ff3d78

  reply	other threads:[~2016-05-22 11:20 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-22 11:20 [PATCH 0/2] Better ref summary alignment in "git fetch" Nguyễn Thái Ngọc Duy
2016-05-22 11:20 ` Nguyễn Thái Ngọc Duy [this message]
2016-05-23  0:58   ` [PATCH 1/2] fetch: better alignment in ref summary Junio C Hamano
2016-05-23  1:59     ` Duy Nguyen
2016-05-26 14:22       ` Marc Branchaud
2016-05-26 16:29         ` Jeff King
2016-05-26 17:42           ` Junio C Hamano
2016-05-26 18:13             ` Marc Branchaud
2016-05-26 19:31               ` Junio C Hamano
2016-05-26 22:13                 ` Marc Branchaud
2016-05-26  5:18   ` Jeff King
2016-06-02 13:58     ` Duy Nguyen
2016-06-02 16:16       ` Junio C Hamano
2016-05-22 11:20 ` [PATCH 2/2] fetch: reduce ref column size when there are enough short ref names Nguyễn Thái Ngọc Duy
2016-06-03 11:08 ` [PATCH v2 0/3] Better ref summary alignment in "git fetch" Nguyễn Thái Ngọc Duy
2016-06-03 11:08   ` [PATCH v2 1/3] git-fetch.txt: document fetch output Nguyễn Thái Ngọc Duy
2016-06-03 14:33     ` Marc Branchaud
2016-06-03 16:55     ` Jeff King
2016-06-03 11:08   ` [PATCH v2 2/3] fetch: refactor ref update status formatting code Nguyễn Thái Ngọc Duy
2016-06-03 16:48     ` Junio C Hamano
2016-06-03 11:08   ` [PATCH v2 3/3] fetch: reduce duplicate in ref update status lines Nguyễn Thái Ngọc Duy
2016-06-03 14:53     ` Marc Branchaud
2016-06-03 17:04       ` Junio C Hamano
2016-06-03 20:00         ` Marc Branchaud
2016-06-03 20:53           ` Junio C Hamano
2016-06-04  3:11             ` Duy Nguyen
2016-06-04  0:31       ` Duy Nguyen
2016-06-04 16:30         ` Junio C Hamano
2016-06-05  3:15           ` Duy Nguyen
2016-06-03 17:00     ` Junio C Hamano
2016-06-03 23:49       ` Duy Nguyen
2016-06-03 17:06     ` Jeff King
2016-06-03 23:52       ` Duy Nguyen
2016-06-04  4:53         ` Junio C Hamano
2016-06-03 17:00   ` [PATCH v2 0/3] Better ref summary alignment in "git fetch" Jeff King
2016-06-03 17:37     ` Junio C Hamano
2016-06-05  3:11   ` [PATCH v3 0/6] " Nguyễn Thái Ngọc Duy
2016-06-05  3:11     ` [PATCH v3 1/6] git-fetch.txt: document fetch output Nguyễn Thái Ngọc Duy
2016-06-06 14:24       ` Marc Branchaud
2016-06-05  3:11     ` [PATCH v3 2/6] fetch: refactor ref update status formatting code Nguyễn Thái Ngọc Duy
2016-06-05  3:11     ` [PATCH v3 3/6] fetch: change flag code for displaying tag update and deleted ref Nguyễn Thái Ngọc Duy
2016-06-05  3:11     ` [PATCH v3 4/6] fetch: align all "remote -> local" output Nguyễn Thái Ngọc Duy
2016-06-05  3:11     ` [PATCH v3 5/6] fetch: reduce duplicate in ref update status lines with { -> } Nguyễn Thái Ngọc Duy
2016-06-05  3:11     ` [PATCH v3 6/6] fetch: reduce duplicate in ref update status lines with placeholder Nguyễn Thái Ngọc Duy
2016-06-26  5:58     ` [PATCH v4 0/5] Better ref summary alignment in "git fetch" Nguyễn Thái Ngọc Duy
2016-06-26  5:58       ` [PATCH v4 1/5] git-fetch.txt: document fetch output Nguyễn Thái Ngọc Duy
2016-07-04 14:07         ` Jakub Narębski
2016-07-04 15:17           ` Duy Nguyen
2016-07-04 15:25             ` Jakub Narębski
2016-07-04 15:52               ` Duy Nguyen
2016-06-26  5:58       ` [PATCH v4 2/5] fetch: refactor ref update status formatting code Nguyễn Thái Ngọc Duy
2016-06-26  5:58       ` [PATCH v4 3/5] fetch: change flag code for displaying tag update and deleted ref Nguyễn Thái Ngọc Duy
2016-06-26  5:58       ` [PATCH v4 4/5] fetch: align all "remote -> local" output Nguyễn Thái Ngọc Duy
2016-06-26  5:58       ` [PATCH v4 5/5] fetch: reduce duplicate in ref update status lines with placeholder Nguyễn Thái Ngọc Duy
2016-06-27  4:33         ` Eric Sunshine
2016-06-27  5:42           ` Duy Nguyen
2016-06-27 15:31           ` Junio C Hamano
2016-06-27 18:43       ` [PATCH v4 0/5] Better ref summary alignment in "git fetch" Jeff King
2016-06-27 19:27         ` Duy Nguyen
2016-06-30 16:16         ` Duy Nguyen
2016-07-01  6:09           ` Jeff King
2016-07-01 16:03       ` [PATCH v5 " Nguyễn Thái Ngọc Duy
2016-07-01 16:03         ` [PATCH v5 1/5] git-fetch.txt: document fetch output Nguyễn Thái Ngọc Duy
2016-07-01 16:03         ` [PATCH v5 2/5] fetch: refactor ref update status formatting code Nguyễn Thái Ngọc Duy
2016-07-01 16:03         ` [PATCH v5 3/5] fetch: change flag code for displaying tag update and deleted ref Nguyễn Thái Ngọc Duy
2016-07-01 16:03         ` [PATCH v5 4/5] fetch: align all "remote -> local" output Nguyễn Thái Ngọc Duy
2016-07-01 16:03         ` [PATCH v5 5/5] fetch: reduce duplicate in ref update status lines with placeholder Nguyễn Thái Ngọc Duy
2016-07-01 23:21         ` [PATCH v5 0/5] Better ref summary alignment in "git fetch" Junio C Hamano
2016-07-02  4:39           ` Duy Nguyen
2016-07-04 13:17         ` Marc Branchaud
2016-07-04 15:08           ` Duy Nguyen

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

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160522112019.26516-2-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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).