git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Another use of "@"?
@ 2013-05-03  2:51 Duy Nguyen
  2013-05-03  6:28 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Duy Nguyen @ 2013-05-03  2:51 UTC (permalink / raw)
  To: Git Mailing List, Ramkumar Ramachandra, Felipe Contreras

Hi,

My setup is a bit peculiar where I do git development on three
different machines. Say I updated branch long-branch-name on machine
A. Then I continue my work on machine B. I would want to hard reset
that long-branch-name on machine B before resuming my work. What I
usually do is

git co long-branch-name
git diff A/long-branch-name
git reset --hard A/long-branch-name

but typing long-branch-name (even with TAB completion) is not fun.
Could I do this (or something similar) instead?

git co long-branch-name
git diff A/@
git reset --hard A/@
--
Duy

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

* Re: Another use of "@"?
  2013-05-03  2:51 Another use of "@"? Duy Nguyen
@ 2013-05-03  6:28 ` Junio C Hamano
  2013-05-03  6:38   ` Junio C Hamano
  2013-05-03 22:09   ` Matthieu Moy
  2013-05-03  6:39 ` Felipe Contreras
  2013-05-04 12:44 ` Ramkumar Ramachandra
  2 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2013-05-03  6:28 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, Ramkumar Ramachandra, Felipe Contreras

Duy Nguyen <pclouds@gmail.com> writes:

> My setup is a bit peculiar where I do git development on three
> different machines. Say I updated branch long-branch-name on machine
> A. Then I continue my work on machine B. I would want to hard reset
> that long-branch-name on machine B before resuming my work. What I
> usually do is
>
> git co long-branch-name
> git diff A/long-branch-name
> git reset --hard A/long-branch-name

Perhaps

    git checkout long-bra<TAB>
    git diff A/!$
    git reset --hard !$

In any case, not a Git question, I would have to say.

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

* Re: Another use of "@"?
  2013-05-03  6:28 ` Junio C Hamano
@ 2013-05-03  6:38   ` Junio C Hamano
  2013-05-03  6:51     ` Duy Nguyen
  2013-05-03 22:09   ` Matthieu Moy
  1 sibling, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2013-05-03  6:38 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, Ramkumar Ramachandra, Felipe Contreras

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

> Duy Nguyen <pclouds@gmail.com> writes:
>
>> My setup is a bit peculiar where I do git development on three
>> different machines. Say I updated branch long-branch-name on machine
>> A. Then I continue my work on machine B. I would want to hard reset
>> that long-branch-name on machine B before resuming my work. What I
>> usually do is
>>
>> git co long-branch-name
>> git diff A/long-branch-name
>> git reset --hard A/long-branch-name
>
> Perhaps
>
>     git checkout long-bra<TAB>
>     git diff A/!$
>     git reset --hard !$
>
> In any case, not a Git question, I would have to say.

As a Git question, probably the answers are

	git co long-bra<TAB>
        git diff @{u}
        git reset --hard @{u}

with an appropriate setting of the upstream, perhaps?

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

* Re: Another use of "@"?
  2013-05-03  2:51 Another use of "@"? Duy Nguyen
  2013-05-03  6:28 ` Junio C Hamano
@ 2013-05-03  6:39 ` Felipe Contreras
  2013-05-04 12:44 ` Ramkumar Ramachandra
  2 siblings, 0 replies; 11+ messages in thread
From: Felipe Contreras @ 2013-05-03  6:39 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, Ramkumar Ramachandra

On Thu, May 2, 2013 at 9:51 PM, Duy Nguyen <pclouds@gmail.com> wrote:
> Hi,
>
> My setup is a bit peculiar where I do git development on three
> different machines. Say I updated branch long-branch-name on machine
> A. Then I continue my work on machine B. I would want to hard reset
> that long-branch-name on machine B before resuming my work. What I
> usually do is
>
> git co long-branch-name
> git diff A/long-branch-name
> git reset --hard A/long-branch-name
>
> but typing long-branch-name (even with TAB completion) is not fun.
> Could I do this (or something similar) instead?
>
> git co long-branch-name
> git diff A/@
> git reset --hard A/@

Maybe this would make more sense:

%git co long-branch-name
%git reset --keep A/long-branch-name

If you have changes but they don't conflict, they will be carried
over, and it they do conflict, the reset won't continue. I think in
most cases there will be no conflict, so the times you need to do 'git
diff' will be rather small.

Yes, many times I would like an idiom that would just replace
something with the current branch, like your A/@, but I don't know
where the right place for that would be.

Also, I feel we are missing some kind of branch, like a
remote-specific upstream, so instead of 'git reset A/foo' you would do
'git reset A@{u}'. By default the remote-specific upstream would be
the same name of the branch, but it could be configured.

Moreover, we should probably have common aliases distributed (e.g. git co).

-- 
Felipe Contreras

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

* Re: Another use of "@"?
  2013-05-03  6:38   ` Junio C Hamano
@ 2013-05-03  6:51     ` Duy Nguyen
  2013-05-03  9:23       ` Thomas Rast
  0 siblings, 1 reply; 11+ messages in thread
From: Duy Nguyen @ 2013-05-03  6:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Ramkumar Ramachandra, Felipe Contreras

On Fri, May 3, 2013 at 4:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Duy Nguyen <pclouds@gmail.com> writes:
>>
>>> My setup is a bit peculiar where I do git development on three
>>> different machines. Say I updated branch long-branch-name on machine
>>> A. Then I continue my work on machine B. I would want to hard reset
>>> that long-branch-name on machine B before resuming my work. What I
>>> usually do is
>>>
>>> git co long-branch-name
>>> git diff A/long-branch-name
>>> git reset --hard A/long-branch-name
>>
>> Perhaps
>>
>>     git checkout long-bra<TAB>
>>     git diff A/!$
>>     git reset --hard !$

"diff" does not have to follow "checkout".

>> In any case, not a Git question, I would have to say.
>
> As a Git question, probably the answers are
>
>         git co long-bra<TAB>
>         git diff @{u}
>         git reset --hard @{u}
>
> with an appropriate setting of the upstream, perhaps?

and @{u} can't be used because I might want to resume from machine C
instead of A. I don't have a single upstream.
--
Duy

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

* Re: Another use of "@"?
  2013-05-03  6:51     ` Duy Nguyen
@ 2013-05-03  9:23       ` Thomas Rast
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Rast @ 2013-05-03  9:23 UTC (permalink / raw)
  To: Duy Nguyen
  Cc: Junio C Hamano, Git Mailing List, Ramkumar Ramachandra,
	Felipe Contreras

Duy Nguyen <pclouds@gmail.com> writes:

> On Fri, May 3, 2013 at 4:38 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Junio C Hamano <gitster@pobox.com> writes:
>>
>>> Duy Nguyen <pclouds@gmail.com> writes:
>>>
>>>> My setup is a bit peculiar where I do git development on three
>>>> different machines. Say I updated branch long-branch-name on machine
>>>> A. Then I continue my work on machine B. I would want to hard reset
>>>> that long-branch-name on machine B before resuming my work. What I
>>>> usually do is
>>>>
>>>> git co long-branch-name
>>>> git diff A/long-branch-name
>>>> git reset --hard A/long-branch-name
>>>
>>> Perhaps
>>>
>>>     git checkout long-bra<TAB>
>>>     git diff A/!$
>>>     git reset --hard !$
>
> "diff" does not have to follow "checkout".

At least in bash with readline, you can also use M-. to cycle through
the last arguments of the previous commands.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

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

* Re: Another use of "@"?
  2013-05-03  6:28 ` Junio C Hamano
  2013-05-03  6:38   ` Junio C Hamano
@ 2013-05-03 22:09   ` Matthieu Moy
  2013-05-04  3:26     ` Duy Nguyen
  1 sibling, 1 reply; 11+ messages in thread
From: Matthieu Moy @ 2013-05-03 22:09 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Duy Nguyen, Git Mailing List, Ramkumar Ramachandra,
	Felipe Contreras

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

> Duy Nguyen <pclouds@gmail.com> writes:
>
>> My setup is a bit peculiar where I do git development on three
>> different machines. Say I updated branch long-branch-name on machine
>> A. Then I continue my work on machine B. I would want to hard reset
>> that long-branch-name on machine B before resuming my work. What I
>> usually do is
>>
>> git co long-branch-name
>> git diff A/long-branch-name
>> git reset --hard A/long-branch-name
>
> Perhaps
>
>     git checkout long-bra<TAB>
>     git diff A/!$
>     git reset --hard !$

I think Duy meant

  git diff A/$(git symbolic-ref --short HEAD)

i.e. "the branch with the same name as the current one, but on a
different remote". If this is the question, then it is a Git thing more
than a shell one.

The A/@ could make sense, but I'm wondering whether we're taking the
direction of implementing some kind of Brainfuck dialect in Git revision
specifiers. I'm not sure we want to add more special characters here and
there with subtly different meanings (@ = HEAD, @{1} = HEAD@{1}, A/@ =
A/$(git symbolic-ref --short HEAD)).

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

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

* Re: Another use of "@"?
  2013-05-03 22:09   ` Matthieu Moy
@ 2013-05-04  3:26     ` Duy Nguyen
  2013-05-04  3:48       ` Duy Nguyen
  0 siblings, 1 reply; 11+ messages in thread
From: Duy Nguyen @ 2013-05-04  3:26 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: Junio C Hamano, Git Mailing List, Ramkumar Ramachandra,
	Felipe Contreras

On Sat, May 4, 2013 at 5:09 AM, Matthieu Moy
<Matthieu.Moy@grenoble-inp.fr> wrote:
> The A/@ could make sense, but I'm wondering whether we're taking the
> direction of implementing some kind of Brainfuck dialect in Git revision
> specifiers. I'm not sure we want to add more special characters here and
> there with subtly different meanings (@ = HEAD, @{1} = HEAD@{1}, A/@ =
> A/$(git symbolic-ref --short HEAD)).

Another subtle overloading of @ that might be desirable (althought
might be achievable another way). "git log -g"  is equal to "git log
-g HEAD" but there is no easy way (that I know of) to do "git log -g
$(git symbolic-ref HEAD)". "@" could fill the inconvenient spot here,
I think. Alias is no good because I won't be able to add extra
options.
--
Duy

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

* Re: Another use of "@"?
  2013-05-04  3:26     ` Duy Nguyen
@ 2013-05-04  3:48       ` Duy Nguyen
  0 siblings, 0 replies; 11+ messages in thread
From: Duy Nguyen @ 2013-05-04  3:48 UTC (permalink / raw)
  To: Matthieu Moy
  Cc: Junio C Hamano, Git Mailing List, Ramkumar Ramachandra,
	Felipe Contreras

On Sat, May 4, 2013 at 10:26 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Sat, May 4, 2013 at 5:09 AM, Matthieu Moy
> <Matthieu.Moy@grenoble-inp.fr> wrote:
>> The A/@ could make sense, but I'm wondering whether we're taking the
>> direction of implementing some kind of Brainfuck dialect in Git revision
>> specifiers. I'm not sure we want to add more special characters here and
>> there with subtly different meanings (@ = HEAD, @{1} = HEAD@{1}, A/@ =
>> A/$(git symbolic-ref --short HEAD)).
>
> Another subtle overloading of @ that might be desirable (althought
> might be achievable another way). "git log -g"  is equal to "git log
> -g HEAD" but there is no easy way (that I know of) to do "git log -g
> $(git symbolic-ref HEAD)". "@" could fill the inconvenient spot here,
> I think. Alias is no good because I won't be able to add extra
> options.

I wouldn't mind typing <ref>@{link} that does "git symbolic-ref
<ref>", though. Because ref is optional, "git log -g @{link}" is not
bad. "link" is probably not a good name for this.
--
Duy

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

* Re: Another use of "@"?
  2013-05-03  2:51 Another use of "@"? Duy Nguyen
  2013-05-03  6:28 ` Junio C Hamano
  2013-05-03  6:39 ` Felipe Contreras
@ 2013-05-04 12:44 ` Ramkumar Ramachandra
  2013-05-04 21:11   ` Matthieu Moy
  2 siblings, 1 reply; 11+ messages in thread
From: Ramkumar Ramachandra @ 2013-05-04 12:44 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, Felipe Contreras

[joining the discussion late; was travelling]

Duy Nguyen wrote:
> git co long-branch-name
> git diff A/@
> git reset --hard A/@

In this form, this looks highly inconsistent.  You have to decide if
you want @ to resolve to the current branch name or HEAD.  Our current
@-proposal makes @@{1} display the reflog for HEAD for instance.  The
other problem is that we resolve things like @{-1} to full refs like
refs/heads/master.  Making a A/@{-1} work makes little or no sense,
because that refs/heads needs to be changed to refs/remotes in the
first place.  What about refs/decapitated/@{-1}?  Should we support
it?

I tend to agree with Junio here: @{u} is the way forward.  We need to
define useful reduced consistent semantics; while inventing a
mini-language to do all kinds of revision manipulations may be a fun
theoretical exercise, it's too much effort for too little gain.  We
have to learn to work within the limitations of what we've invented so
far.

On Matthieu's note, I have a comment: symbolic refs are an absolute
dead end.  We didn't think of it from the start, and it's too late
now.  Do NOT go there: from my investigation, I believe that hooking
up everything to the revision parser is the way forward.

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

* Re: Another use of "@"?
  2013-05-04 12:44 ` Ramkumar Ramachandra
@ 2013-05-04 21:11   ` Matthieu Moy
  0 siblings, 0 replies; 11+ messages in thread
From: Matthieu Moy @ 2013-05-04 21:11 UTC (permalink / raw)
  To: Ramkumar Ramachandra; +Cc: Duy Nguyen, Git Mailing List, Felipe Contreras

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> On Matthieu's note, I have a comment: symbolic refs are an absolute
> dead end.  We didn't think of it from the start, and it's too late
> now.  Do NOT go there: from my investigation, I believe that hooking
> up everything to the revision parser is the way forward.

My comment was not about the solution, but about the problem (which
seemed to have been misunderstood). The question seems to be "get the
reference with the same names as what HEAD points to, but on remote A",
and the "points to" part is about symbolic references.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

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

end of thread, other threads:[~2013-05-04 21:12 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-03  2:51 Another use of "@"? Duy Nguyen
2013-05-03  6:28 ` Junio C Hamano
2013-05-03  6:38   ` Junio C Hamano
2013-05-03  6:51     ` Duy Nguyen
2013-05-03  9:23       ` Thomas Rast
2013-05-03 22:09   ` Matthieu Moy
2013-05-04  3:26     ` Duy Nguyen
2013-05-04  3:48       ` Duy Nguyen
2013-05-03  6:39 ` Felipe Contreras
2013-05-04 12:44 ` Ramkumar Ramachandra
2013-05-04 21:11   ` 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).