From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Eric Sunshine" <sunshine@sunshineco.com>,
"Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
marcnarc@xiplink.com, "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v5 0/5] Better ref summary alignment in "git fetch"
Date: Fri, 1 Jul 2016 18:03:26 +0200 [thread overview]
Message-ID: <20160701160331.29252-1-pclouds@gmail.com> (raw)
In-Reply-To: <20160626055810.26960-1-pclouds@gmail.com>
v5 changes the substitute symbol from '$' to '*' in compact mode and
makes sure long lines in compact mode will not make the remote ref
column too big (it's far from perfect but I think it's still good to
do).
I'm not sure if we should bring back "{ -> origin/}foo" format. I can
do it if someone still wants it.
Interdiff
diff --git a/Documentation/git-fetch.txt b/Documentation/git-fetch.txt
index 61e8885..9e42169 100644
--- a/Documentation/git-fetch.txt
+++ b/Documentation/git-fetch.txt
@@ -116,10 +116,10 @@ representing the status of a single ref. Each line is of the form:
The status of up-to-date refs is shown only if the --verbose option is
used.
-In compact output mode, if either entire `<from>` or `<to>` is found
-in the other string, it will be substituted with `$` in the other
-string. or example, `master -> origin/master` becomes
-`master -> origin/$`.
+In compact output mode, specified with configuration variable
+fetch.output, if either entire `<from>` or `<to>` is found in the
+other string, it will be substituted with `*` in the other string. For
+example, `master -> origin/master` becomes `master -> origin/*`.
flag::
A single character indicating the status of the ref:
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 9d9f4e8..0a2eed1 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -455,7 +455,7 @@ static int compact_format;
static void adjust_refcol_width(const struct ref *ref)
{
- int max, rlen, llen;
+ int max, rlen, llen, len;
/* uptodate lines are only shown on high verbosity level */
if (!verbosity && !oidcmp(&ref->peer_ref->old_oid, &ref->old_oid))
@@ -464,16 +464,6 @@ static void adjust_refcol_width(const struct ref *ref)
max = term_columns();
rlen = utf8_strwidth(prettify_refname(ref->name));
- if (compact_format) {
- /*
- * Not precise calculation because '$' can appear in
- * ref->name and reduce actual length.
- */
- if (refcol_width < rlen)
- refcol_width = rlen;
- return;
- }
-
llen = utf8_strwidth(prettify_refname(ref->peer_ref->name));
/*
@@ -482,9 +472,19 @@ static void adjust_refcol_width(const struct ref *ref)
* anyway because we don't know if the error explanation part
* will be printed in update_local_ref)
*/
- if (21 /* flag and summary */ + rlen + 4 /* -> */ + llen >= max)
+ if (compact_format) {
+ llen = 0;
+ max = max * 2 / 3;
+ }
+ len = 21 /* flag and summary */ + rlen + 4 /* -> */ + llen;
+ if (len >= max)
return;
+ /*
+ * Not precise calculation for compact mode because '*' can
+ * appear on the left hand side of '->' and shrink the column
+ * back.
+ */
if (refcol_width < rlen)
refcol_width = rlen;
}
@@ -519,7 +519,9 @@ static void print_remote_to_local(struct strbuf *display,
strbuf_addf(display, "%-*s -> %s", refcol_width, remote, local);
}
-static int dollarize(struct strbuf *haystack, const char *needle)
+static int find_and_replace(struct strbuf *haystack,
+ const char *needle,
+ const char *placeholder)
{
const char *p = strstr(haystack->buf, needle);
int plen, nlen;
@@ -535,7 +537,8 @@ static int dollarize(struct strbuf *haystack, const char *needle)
if (plen > nlen && p[nlen] != '/')
return 0;
- strbuf_splice(haystack, p - haystack->buf, nlen, "$", 1);
+ strbuf_splice(haystack, p - haystack->buf, nlen,
+ placeholder, strlen(placeholder));
return 1;
}
@@ -546,15 +549,15 @@ static void print_compact(struct strbuf *display,
struct strbuf l = STRBUF_INIT;
if (!strcmp(remote, local)) {
- strbuf_addf(display, "%-*s -> $", refcol_width, remote);
+ strbuf_addf(display, "%-*s -> *", refcol_width, remote);
return;
}
strbuf_addstr(&r, remote);
strbuf_addstr(&l, local);
- if (!dollarize(&r, local))
- dollarize(&l, remote);
+ if (!find_and_replace(&r, local, "*"))
+ find_and_replace(&l, remote, "*");
print_remote_to_local(display, r.buf, l.buf);
strbuf_release(&r);
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 3a92718..6032776 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -712,8 +712,8 @@ test_expect_success 'fetch compact output' '
grep -e "->" | cut -c 22- >../actual
) &&
cat >expect <<-\EOF &&
- master -> origin/$
- extraaa -> $
+ master -> origin/*
+ extraaa -> *
EOF
test_cmp expect actual
'
Nguyễn Thái Ngọc Duy (5):
git-fetch.txt: document fetch output
fetch: refactor ref update status formatting code
fetch: change flag code for displaying tag update and deleted ref
fetch: align all "remote -> local" output
fetch: reduce duplicate in ref update status lines with placeholder
Documentation/config.txt | 5 ++
Documentation/git-fetch.txt | 51 ++++++++++++
builtin/fetch.c | 197 +++++++++++++++++++++++++++++++++++---------
t/t5510-fetch.sh | 30 +++++++
4 files changed, 243 insertions(+), 40 deletions(-)
--
2.8.2.531.gd073806
next prev parent reply other threads:[~2016-07-01 16:03 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 ` [PATCH 1/2] fetch: better alignment in ref summary Nguyễn Thái Ngọc Duy
2016-05-23 0:58 ` 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 ` Nguyễn Thái Ngọc Duy [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160701160331.29252-1-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=marcnarc@xiplink.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/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.