From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>,
jari <jari.aalto@cante.net>, Miles Bader <miles@gnu.org>,
git@vger.kernel.org
Subject: Re: [PATCH] git-reset.txt: Use commit~1 notation over commit^
Date: Thu, 2 Dec 2010 13:46:17 -0500 [thread overview]
Message-ID: <20101202184617.GA20225@sigill.intra.peff.net> (raw)
In-Reply-To: <7veia0rrew.fsf@alter.siamese.dyndns.org>
On Thu, Dec 02, 2010 at 09:55:03AM -0800, Junio C Hamano wrote:
> Perhaps we need to also fix "git name-rev master^" which currently does
> not try to reduce "master~1" to "master^".
This patch does it:
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index c946a82..417bae5 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -142,8 +142,12 @@ static const char *get_rev_name(const struct object *o)
int len = strlen(n->tip_name);
if (len > 2 && !strcmp(n->tip_name + len - 2, "^0"))
len -= 2;
- snprintf(buffer, sizeof(buffer), "%.*s~%d", len, n->tip_name,
- n->generation);
+ if (n->generation == 1)
+ snprintf(buffer, sizeof(buffer), "%.*s^", len,
+ n->tip_name);
+ else
+ snprintf(buffer, sizeof(buffer), "%.*s~%d", len,
+ n->tip_name, n->generation);
return buffer;
}
but I am not sure the results are always more readable. I think "foo^"
is perhaps nicer than "foo~1". But in more complex examples, I kind of
think the ~1 is easier to read. E.g.:
# old
$ git name-rev 9904fadf
9904fadf tags/v1.7.3-rc2~1^2~1
# new
$ git name-rev 9904fadf
9904fadf tags/v1.7.3-rc2~1^2^
Somehow the visual appearance of "^2^" ends up being more confusing to
me than ~1^2~1, I guess because in the latter there is a regular set of
modifier-number pairs.
But I admit that is just my subjective opinion.
-Peff
next prev parent reply other threads:[~2010-12-02 18:46 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-01 18:14 [PATCH] git-reset.txt: Use commit~1 notation over commit^ jari.aalto
2010-12-01 19:13 ` Drew Northup
2010-12-01 19:37 ` Jari Aalto
2010-12-01 22:01 ` Kevin Ballard
2010-12-01 22:49 ` Jari Aalto
2010-12-01 22:56 ` Kevin Ballard
2010-12-01 22:06 ` Junio C Hamano
2010-12-01 22:50 ` Jari Aalto
2010-12-02 0:07 ` Andreas Schwab
2010-12-02 5:37 ` Jari Aalto
2010-12-01 22:56 ` Santi Béjar
2010-12-02 5:39 ` Jari Aalto
2010-12-02 6:17 ` Miles Bader
2010-12-02 12:14 ` Jari Aalto
2010-12-02 12:51 ` Drew Northup
2010-12-02 13:17 ` Miles Bader
2010-12-02 13:20 ` jari
2010-12-02 17:44 ` Andreas Schwab
2010-12-02 17:55 ` Junio C Hamano
2010-12-02 18:46 ` Jeff King [this message]
2010-12-02 18:54 ` Junio C Hamano
2010-12-02 19:05 ` Jeff King
2010-12-02 2:46 ` Miles Bader
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=20101202184617.GA20225@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jari.aalto@cante.net \
--cc=miles@gnu.org \
--cc=schwab@linux-m68k.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 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 NNTP newsgroup(s).