git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Support of '^' as alias for 'HEAD^'
@ 2012-07-14  0:39 Zeeshan Ali (Khattak)
  2012-07-14  9:48 ` Stefan Näwe
  0 siblings, 1 reply; 10+ messages in thread
From: Zeeshan Ali (Khattak) @ 2012-07-14  0:39 UTC (permalink / raw)
  To: git

Hi,
  Many times I want to refer to 'HEAD^', 'HEAD^^' and sometimes even
further up the tree. It would be really nice if I didn't have to type
'HEAD^' but could only type '^'. Bash completion make things easier
but it automatically inserts a space immediately after HEAD so you
have to hit backspace. I think this change would be good in general
anyway.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14  0:39 Support of '^' as alias for 'HEAD^' Zeeshan Ali (Khattak)
@ 2012-07-14  9:48 ` Stefan Näwe
  2012-07-14 20:17   ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Stefan Näwe @ 2012-07-14  9:48 UTC (permalink / raw)
  To: git

Zeeshan Ali (Khattak <zeeshanak <at> gnome.org> writes:

> 
> Hi,
>   Many times I want to refer to 'HEAD^', 'HEAD^^' and sometimes even
> further up the tree. It would be really nice if I didn't have to type
> 'HEAD^' but could only type '^'. Bash completion make things easier
> but it automatically inserts a space immediately after HEAD so you
> have to hit backspace. I think this change would be good in general
> anyway.

Or even '~1', '~3'.

Where's the '+1' button...?

Stefan

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14  9:48 ` Stefan Näwe
@ 2012-07-14 20:17   ` Junio C Hamano
  2012-07-14 20:34     ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2012-07-14 20:17 UTC (permalink / raw)
  To: Stefan Näwe; +Cc: git, Zeeshan Ali (Khattak)

Stefan Näwe <stefan.naewe@gmail.com> writes:

> Zeeshan Ali (Khattak <zeeshanak <at> gnome.org> writes:
>> 
>> Many times I want to refer to 'HEAD^', 'HEAD^^' and sometimes even
>> further up the tree. It would be really nice if I didn't have to type
>> 'HEAD^' but could only type '^'. Bash completion make things easier
>> but it automatically inserts a space immediately after HEAD so you
>> have to hit backspace. I think this change would be good in general
>> anyway.
>
> Or even '~1', '~3'.

"^" has a problem when used with other things (does "log ^^2
origin" mean "log HEAD^2..origin"?  Or "log HEAD^^2 origin"), so I
do not think it would never fly as an abbreviated syntax.

While I see your "~<N>" much distasteful compared to "^", you still
need to be a bit more careful when analysing the benefit of such an
abbreviation.  To shells used by many people, these mean tilde
expansion ~<N> to refer to elements on the dirstack and you need to
quote, perhaps like \~3.

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14 20:17   ` Junio C Hamano
@ 2012-07-14 20:34     ` Junio C Hamano
  2012-07-14 20:49       ` Zeeshan Ali (Khattak)
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2012-07-14 20:34 UTC (permalink / raw)
  To: Stefan Näwe; +Cc: git, Zeeshan Ali (Khattak)

Junio C Hamano <gitster@pobox.com> writes:

> Stefan Näwe <stefan.naewe@gmail.com> writes:
>
>> Zeeshan Ali (Khattak <zeeshanak <at> gnome.org> writes:
>>> 
>>> Many times I want to refer to 'HEAD^', 'HEAD^^' and sometimes even
>>> further up the tree. It would be really nice if I didn't have to type
>>> 'HEAD^' but could only type '^'. Bash completion make things easier
>>> but it automatically inserts a space immediately after HEAD so you
>>> have to hit backspace. I think this change would be good in general
>>> anyway.
>>
>> Or even '~1', '~3'.
>
> "^" has a problem when used with other things (does "log ^^2
> origin" mean "log HEAD^2..origin"?  Or "log HEAD^^2 origin"), so I
> do not think it would never fly as an abbreviated syntax.
>
> While I see your "~<N>" much distasteful compared to "^", you still

s/dist/less dist/; sorry ;-)

> need to be a bit more careful when analysing the benefit of such an
> abbreviation.  To shells used by many people, these mean tilde
> expansion ~<N> to refer to elements on the dirstack and you need to
> quote, perhaps like \~3.

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14 20:34     ` Junio C Hamano
@ 2012-07-14 20:49       ` Zeeshan Ali (Khattak)
  2012-07-14 21:26         ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Zeeshan Ali (Khattak) @ 2012-07-14 20:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Stefan Näwe, git

On Sat, Jul 14, 2012 at 11:34 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Stefan Näwe <stefan.naewe@gmail.com> writes:
>>
>>> Zeeshan Ali (Khattak <zeeshanak <at> gnome.org> writes:
>>>>
>>>> Many times I want to refer to 'HEAD^', 'HEAD^^' and sometimes even
>>>> further up the tree. It would be really nice if I didn't have to type
>>>> 'HEAD^' but could only type '^'. Bash completion make things easier
>>>> but it automatically inserts a space immediately after HEAD so you
>>>> have to hit backspace. I think this change would be good in general
>>>> anyway.
>>>
>>> Or even '~1', '~3'.
>>
>> "^" has a problem when used with other things (does "log ^^2
>> origin" mean "log HEAD^2..origin"?  Or "log HEAD^^2 origin"), so I
>> do not think it would never fly as an abbreviated syntax.

What about '^' and '^^' that I suggested?

>> While I see your "~<N>" much distasteful compared to "^", you still
>
> s/dist/less dist/; sorry ;-)

Why?

>> need to be a bit more careful when analysing the benefit of such an
>> abbreviation.  To shells used by many people, these mean tilde
>> expansion ~<N> to refer to elements on the dirstack and you need to
>> quote, perhaps like \~3.

That would kinda beat the purpose I think, would be nice to just type
1 key rather than 3 to refer to HEAD (2 keys would still be good
enough IMHO).

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14 20:49       ` Zeeshan Ali (Khattak)
@ 2012-07-14 21:26         ` Junio C Hamano
  2012-07-14 22:24           ` Zeeshan Ali (Khattak)
  0 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2012-07-14 21:26 UTC (permalink / raw)
  To: Zeeshan Ali (Khattak); +Cc: Stefan Näwe, git

"Zeeshan Ali (Khattak)" <zeeshanak@gnome.org> writes:

> What about '^' and '^^' that I suggested?
>
>>> While I see your "~<N>" much distasteful compared to "^", you still
>>
>> s/dist/less dist/; sorry ;-)
>
> Why?

That "^^" is the most important reason why your "^ is the same as
HEAD^" is flawed, and goes against my taste.

Think what "log ^^ origin" would mean.  Is it "log ^HEAD^ origin"?
Is it "log HEAD^^ origin"?  They mean totally different things.

Compared to that, at least ~<n> does not have such ambiguity within
the context of Git (having to quote is an ambiguity within the
context of using Git with shells that support dirstacks in their
tilde expansion).

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14 21:26         ` Junio C Hamano
@ 2012-07-14 22:24           ` Zeeshan Ali (Khattak)
  2012-07-15  7:44             ` Jeff King
  2012-07-15 17:45             ` Holger Hellmuth
  0 siblings, 2 replies; 10+ messages in thread
From: Zeeshan Ali (Khattak) @ 2012-07-14 22:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Stefan Näwe, git

On Sun, Jul 15, 2012 at 12:26 AM, Junio C Hamano <gitster@pobox.com> wrote:
> "Zeeshan Ali (Khattak)" <zeeshanak@gnome.org> writes:
>
>> What about '^' and '^^' that I suggested?
>>
>>>> While I see your "~<N>" much distasteful compared to "^", you still
>>>
>>> s/dist/less dist/; sorry ;-)
>>
>> Why?
>
> That "^^" is the most important reason why your "^ is the same as
> HEAD^" is flawed, and goes against my taste.
>
> Think what "log ^^ origin" would mean.  Is it "log ^HEAD^ origin"?
> Is it "log HEAD^^ origin"?  They mean totally different things.

Sorry for my ignorance here but what does ^ *before* HEAD even mean? I
tried playing with different combinations of ^ and HEAD here (e.g
^HEAD^, ^HEAD^^, ^HEAD^^^) with both log and show commands but git
just silently returns on them. Is this ^ before HEAD actually used
cause I have never seen/heard of that before. Google isn't able to
help either.

> Compared to that, at least ~<n> does not have such ambiguity within
> the context of Git (having to quote is an ambiguity within the
> context of using Git with shells that support dirstacks in their
> tilde expansion).

Don't know whats dirstacks support either but that I guess just means
that bash (the shell I have always used) doesn't do that.

-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14 22:24           ` Zeeshan Ali (Khattak)
@ 2012-07-15  7:44             ` Jeff King
  2012-07-15 17:45             ` Holger Hellmuth
  1 sibling, 0 replies; 10+ messages in thread
From: Jeff King @ 2012-07-15  7:44 UTC (permalink / raw)
  To: Zeeshan Ali (Khattak); +Cc: Junio C Hamano, Stefan Näwe, git

On Sun, Jul 15, 2012 at 01:24:18AM +0300, Zeeshan Ali (Khattak) wrote:

> > Think what "log ^^ origin" would mean.  Is it "log ^HEAD^ origin"?
> > Is it "log HEAD^^ origin"?  They mean totally different things.
> 
> Sorry for my ignorance here but what does ^ *before* HEAD even mean? I

It means "not" (before "HEAD" or any other commit specifier). See
"Specifying Ranges" in "git help revisions".

> > Compared to that, at least ~<n> does not have such ambiguity within
> > the context of Git (having to quote is an ambiguity within the
> > context of using Git with shells that support dirstacks in their
> > tilde expansion).
> 
> Don't know whats dirstacks support either but that I guess just means
> that bash (the shell I have always used) doesn't do that.

Bash does support them, but you may not use them personally. Here are
some examples of how a more bare "~" can go wrong:

  $ set -x
  [this instructs the shell to show us what it is executing]

  $ git log ~
  + git log /home/peff
  [oops, the shell expanded our home directory and passed it to git]

  $ git log ~1
  + git log '~1'
  [this one works ok, but...]

  $ pushd /tmp
  $ pushd $HOME
  $ git log ~1
  + git log /tmp
  [oops, pushd users cannot use ~<n> without quoting]

-Peff

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-14 22:24           ` Zeeshan Ali (Khattak)
  2012-07-15  7:44             ` Jeff King
@ 2012-07-15 17:45             ` Holger Hellmuth
  2012-07-15 21:48               ` Zeeshan Ali (Khattak)
  1 sibling, 1 reply; 10+ messages in thread
From: Holger Hellmuth @ 2012-07-15 17:45 UTC (permalink / raw)
  To: Zeeshan Ali (Khattak); +Cc: Junio C Hamano, Stefan Näwe, git

Am 15.07.2012 00:24, schrieb Zeeshan Ali (Khattak):
> On Sun, Jul 15, 2012 at 12:26 AM, Junio C Hamano<gitster@pobox.com>  wrote:
>> "Zeeshan Ali (Khattak)"<zeeshanak@gnome.org>  writes:
>>
>>> What about '^' and '^^' that I suggested?

If you want a shortcut, you might try this:

echo "ref: HEAD" > .git/h

Then you can use 'h' instead of 'HEAD'.

Tested it and it seemed to work. If not someone on this list surely will 
correct me.

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

* Re: Support of '^' as alias for 'HEAD^'
  2012-07-15 17:45             ` Holger Hellmuth
@ 2012-07-15 21:48               ` Zeeshan Ali (Khattak)
  0 siblings, 0 replies; 10+ messages in thread
From: Zeeshan Ali (Khattak) @ 2012-07-15 21:48 UTC (permalink / raw)
  To: Holger Hellmuth; +Cc: Junio C Hamano, Stefan Näwe, git

On Sun, Jul 15, 2012 at 8:45 PM, Holger Hellmuth <hellmuth@ira.uka.de> wrote:
> Am 15.07.2012 00:24, schrieb Zeeshan Ali (Khattak):
>
>> On Sun, Jul 15, 2012 at 12:26 AM, Junio C Hamano<gitster@pobox.com>
>> wrote:
>>>
>>> "Zeeshan Ali (Khattak)"<zeeshanak@gnome.org>  writes:
>>>
>>>> What about '^' and '^^' that I suggested?
>
>
> If you want a shortcut, you might try this:
>
> echo "ref: HEAD" > .git/h
>
> Then you can use 'h' instead of 'HEAD'.
>
> Tested it and it seemed to work. If not someone on this list surely will
> correct me.

Thanks, was hoping to have something thats supported out of the box in
future git but I guess I can settle for a local hack too. :)


-- 
Regards,

Zeeshan Ali (Khattak)
FSF member#5124

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

end of thread, other threads:[~2012-07-15 21:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-14  0:39 Support of '^' as alias for 'HEAD^' Zeeshan Ali (Khattak)
2012-07-14  9:48 ` Stefan Näwe
2012-07-14 20:17   ` Junio C Hamano
2012-07-14 20:34     ` Junio C Hamano
2012-07-14 20:49       ` Zeeshan Ali (Khattak)
2012-07-14 21:26         ` Junio C Hamano
2012-07-14 22:24           ` Zeeshan Ali (Khattak)
2012-07-15  7:44             ` Jeff King
2012-07-15 17:45             ` Holger Hellmuth
2012-07-15 21:48               ` Zeeshan Ali (Khattak)

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