git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
@ 2011-04-29 15:53 Michael J Gruber
  2011-04-29 16:21 ` Junio C Hamano
  2011-04-29 22:34 ` Jeff King
  0 siblings, 2 replies; 17+ messages in thread
From: Michael J Gruber @ 2011-04-29 15:53 UTC (permalink / raw)
  To: git

HEAD~n is often used for rebase invocations etc. Make it use the same
default we use in other places, i.e. ~n == HEAD~n.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
I haven't checked the side effects but find this super useful. Stop
me right now if this is a bad idea...

An alternative patch subject for this would have been:

sha1_name: We don't need no hg revision numbers, stupid!
---
 sha1_name.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 69cd6c8..5d52eac 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -480,7 +480,10 @@ static int get_nth_ancestor(const char *name, int len,
 	struct commit *commit;
 	int ret;
 
-	ret = get_sha1_1(name, len, sha1);
+	if (len)
+		ret = get_sha1_1(name, len, sha1);
+	else
+		ret = get_sha1("HEAD", sha1);
 	if (ret)
 		return ret;
 	commit = lookup_commit_reference(sha1);
-- 
1.7.5.250.g4493b

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-05-07  2:24 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-29 15:53 [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n Michael J Gruber
2011-04-29 16:21 ` Junio C Hamano
2011-05-01  8:30   ` Michael J Gruber
2011-05-01  9:04     ` Matthieu Moy
2011-05-01 18:34     ` Junio C Hamano
2011-05-01 21:21       ` Matthieu Moy
2011-04-29 22:34 ` Jeff King
2011-04-29 23:23   ` Sverre Rabbelier
2011-05-07  2:24     ` Mikael Magnusson
2011-04-29 23:31   ` Andreas Schwab
2011-04-30  5:33     ` Junio C Hamano
2011-04-30  9:09       ` Andreas Schwab
2011-05-02  8:42         ` Michael J Gruber
     [not found]           ` <BANLkTinxszGhtYobuvci5Yi8eTHW+pi2wA@mail.gmail.com>
2011-05-02 11:04             ` Michael J Gruber
2011-05-02 16:33               ` Junio C Hamano
2011-05-02 17:49                 ` Michael J Gruber
2011-05-02 20:14                   ` Matthieu Moy

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).