* [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
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
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-04-29 22:34 ` Jeff King
1 sibling, 1 reply; 17+ messages in thread
From: Junio C Hamano @ 2011-04-29 16:21 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
Michael J Gruber <git@drmicha.warpmail.net> writes:
> HEAD~n is often used for rebase invocations etc.
I thought rebase invocations these days use @{u}.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
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
0 siblings, 2 replies; 17+ messages in thread
From: Michael J Gruber @ 2011-05-01 8:30 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Fri, 29 Apr 2011 09:21 -0700, "Junio C Hamano" <gitster@pobox.com>
wrote:
> Michael J Gruber <git@drmicha.warpmail.net> writes:
>
> > HEAD~n is often used for rebase invocations etc.
>
> I thought rebase invocations these days use @{u}.
>
I meant "rebase -i", sorry. And in fact I mostly mean those cases where
I want to "amend" a commit which is not the top most one.
Michael
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
2011-05-01 8:30 ` Michael J Gruber
@ 2011-05-01 9:04 ` Matthieu Moy
2011-05-01 18:34 ` Junio C Hamano
1 sibling, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2011-05-01 9:04 UTC (permalink / raw)
To: Michael J Gruber; +Cc: Junio C Hamano, git
"Michael J Gruber" <git@drmicha.warpmail.net> writes:
> On Fri, 29 Apr 2011 09:21 -0700, "Junio C Hamano" <gitster@pobox.com>
> wrote:
>> Michael J Gruber <git@drmicha.warpmail.net> writes:
>>
>> > HEAD~n is often used for rebase invocations etc.
>>
>> I thought rebase invocations these days use @{u}.
>>
>
> I meant "rebase -i", sorry. And in fact I mostly mean those cases where
> I want to "amend" a commit which is not the top most one.
>
> Michael
... and Junio is right that
git rebase -i @{u}
usually does the right thing: let you amend any of the unpushed commits.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
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
1 sibling, 1 reply; 17+ messages in thread
From: Junio C Hamano @ 2011-05-01 18:34 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
"Michael J Gruber" <git@drmicha.warpmail.net> writes:
> I meant "rebase -i", sorry. And in fact I mostly mean those cases where
> I want to "amend" a commit which is not the top most one.
I also see myself getting tempted to say "rebase -i -2" every once in a
while; it seems to go well with "log -2" especially when the history is
linear.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
2011-05-01 18:34 ` Junio C Hamano
@ 2011-05-01 21:21 ` Matthieu Moy
0 siblings, 0 replies; 17+ messages in thread
From: Matthieu Moy @ 2011-05-01 21:21 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Michael J Gruber, git
Junio C Hamano <gitster@pobox.com> writes:
> "Michael J Gruber" <git@drmicha.warpmail.net> writes:
>
>> I meant "rebase -i", sorry. And in fact I mostly mean those cases where
>> I want to "amend" a commit which is not the top most one.
>
> I also see myself getting tempted to say "rebase -i -2" every once in a
> while; it seems to go well with "log -2" especially when the history is
> linear.
I like that. As easy to type (or more, depending on the keyboard) as ~2,
but no nasty interaction with the shell. OTOH, that would be a
special-case for rebase only (i.e. doesn't make "git show HEAD~2" easier
to type), but that's the most common case.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
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-04-29 22:34 ` Jeff King
2011-04-29 23:23 ` Sverre Rabbelier
2011-04-29 23:31 ` Andreas Schwab
1 sibling, 2 replies; 17+ messages in thread
From: Jeff King @ 2011-04-29 22:34 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
On Fri, Apr 29, 2011 at 05:53:15PM +0200, Michael J Gruber wrote:
> 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.
Hmm. It certainly makes sense in that we often default emptiness to
HEAD, but I don't think we can extend this syntax to other things. For
example, seeing ~n makes me think that ^n or ^{tree} would work. But of
course "^" at the beginning of a ref means something completely
different. So it's not completely consistent.
Consistency-wise, I'm not sure if it makes things better or worse.
Obviously we have "foo.." with an implicit HEAD. You could argue that
".." is a different operator altogether, and that any operator that is a
"ref modifier" like "~" or "^" needs to have a non-implicit ref. But
that gets muddier with "@{4.hours.ago}", which also takes an implicit
value, except that it isn't exactly HEAD. It's the branch pointed to by
HEAD.
So there really isn't a lot of consistency, I guess. It also conflicts
a little with the shell's "~user" syntax, though presumably you don't
have users named "1" and "2".
-Peff
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
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
1 sibling, 1 reply; 17+ messages in thread
From: Sverre Rabbelier @ 2011-04-29 23:23 UTC (permalink / raw)
To: Jeff King; +Cc: Michael J Gruber, git
Heya,
On Sat, Apr 30, 2011 at 00:34, Jeff King <peff@peff.net> wrote:
> So there really isn't a lot of consistency, I guess. It also conflicts
> a little with the shell's "~user" syntax, though presumably you don't
> have users named "1" and "2".
FWIW, I like the patch, mainly because I dislike typing HEAD~n (I
usually mispel it as HEA~n) and agree with peff's analysis, we're such
a long way from being any form of consistent that I don't see this
breaking any user expectations.
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
2011-04-29 23:23 ` Sverre Rabbelier
@ 2011-05-07 2:24 ` Mikael Magnusson
0 siblings, 0 replies; 17+ messages in thread
From: Mikael Magnusson @ 2011-05-07 2:24 UTC (permalink / raw)
To: Sverre Rabbelier; +Cc: Jeff King, Michael J Gruber, git
On 30 April 2011 01:23, Sverre Rabbelier <srabbelier@gmail.com> wrote:
> Heya,
>
> On Sat, Apr 30, 2011 at 00:34, Jeff King <peff@peff.net> wrote:
>> So there really isn't a lot of consistency, I guess. It also conflicts
>> a little with the shell's "~user" syntax, though presumably you don't
>> have users named "1" and "2".
>
> FWIW, I like the patch, mainly because I dislike typing HEAD~n (I
> usually mispel it as HEA~n) and agree with peff's analysis, we're such
> a long way from being any form of consistent that I don't see this
> breaking any user expectations.
Something I always set up in the skeleton dir
($prefix/share/git-core/templates) after installing git is
echo 'ref: HEAD' > h
it makes life so much easier :).
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
2011-04-29 22:34 ` Jeff King
2011-04-29 23:23 ` Sverre Rabbelier
@ 2011-04-29 23:31 ` Andreas Schwab
2011-04-30 5:33 ` Junio C Hamano
1 sibling, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2011-04-29 23:31 UTC (permalink / raw)
To: Jeff King; +Cc: Michael J Gruber, git
Jeff King <peff@peff.net> writes:
> It also conflicts a little with the shell's "~user" syntax, though
> presumably you don't have users named "1" and "2".
Well, you sorta do if you did use pushd.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
2011-04-29 23:31 ` Andreas Schwab
@ 2011-04-30 5:33 ` Junio C Hamano
2011-04-30 9:09 ` Andreas Schwab
0 siblings, 1 reply; 17+ messages in thread
From: Junio C Hamano @ 2011-04-30 5:33 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Jeff King, Michael J Gruber, git
Andreas Schwab <schwab@linux-m68k.org> writes:
> Jeff King <peff@peff.net> writes:
>
>> It also conflicts a little with the shell's "~user" syntax, though
>> presumably you don't have users named "1" and "2".
>
> Well, you sorta do if you did use pushd.
Yeah, I was also worried about that. Or some arcane system
misinterpreting "~0" as the home directory of root ;-)
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
2011-04-30 5:33 ` Junio C Hamano
@ 2011-04-30 9:09 ` Andreas Schwab
2011-05-02 8:42 ` Michael J Gruber
0 siblings, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2011-04-30 9:09 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jeff King, Michael J Gruber, git
Junio C Hamano <gitster@pobox.com> writes:
> Andreas Schwab <schwab@linux-m68k.org> writes:
>
>> Jeff King <peff@peff.net> writes:
>>
>>> It also conflicts a little with the shell's "~user" syntax, though
>>> presumably you don't have users named "1" and "2".
>>
>> Well, you sorta do if you did use pushd.
>
> Yeah, I was also worried about that. Or some arcane system
> misinterpreting "~0" as the home directory of root ;-)
On non-arcane systems ~0 is expanded to the current directory.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [RFC/largely untested/PATCH] sha1_name: interpret ~n as HEAD~n
2011-04-30 9:09 ` Andreas Schwab
@ 2011-05-02 8:42 ` Michael J Gruber
[not found] ` <BANLkTinxszGhtYobuvci5Yi8eTHW+pi2wA@mail.gmail.com>
0 siblings, 1 reply; 17+ messages in thread
From: Michael J Gruber @ 2011-05-02 8:42 UTC (permalink / raw)
To: Andreas Schwab; +Cc: Junio C Hamano, Jeff King, git
Andreas Schwab venit, vidit, dixit 30.04.2011 11:09:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Andreas Schwab <schwab@linux-m68k.org> writes:
>>
>>> Jeff King <peff@peff.net> writes:
>>>
>>>> It also conflicts a little with the shell's "~user" syntax, though
>>>> presumably you don't have users named "1" and "2".
>>>
>>> Well, you sorta do if you did use pushd.
>>
>> Yeah, I was also worried about that. Or some arcane system
>> misinterpreting "~0" as the home directory of root ;-)
>
> On non-arcane systems ~0 is expanded to the current directory.
>
> Andreas.
>
[cumulative reply :)]
While we could use a short-hand for HEAD also I don't think ~0 really is
a concern.
Regarding consistency:
We try to have reasonable defaults and try to dwim (which are different
things) even if that breaks consistency/systematics, because
useful/reasonable and "what I mean" depend on the context.
"^" resp. ".." and "..." are ambiguous and cannot be resolved easily
because for most commands they can mean two things resp. require two
arguments. (".." and "..." could maybe default do "@{u}..HEAD" etc.)
"~<n>" can only take a revision argument to its left, and also it needs
an argument to its left (as opposed to "^"). Therefore we can default it
unambiguously and without braking any current usage (that I know of).
Regarding rebase -i -<n>:
git-rebase (-i) does not have a log/rev-list like interface at all (just
like git-cherry does not), and introducing an argument which looks like
it did would just increase the user confusion, I'm afraid.
Michael
^ permalink raw reply [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).