Re: [PATCH] Add shell completion for git remote rm

2018-07-16 Thread Keith Smiley
Since there hasn't been any movement on the alternative solutions mentioned 
here, would it be reasonable to accept this patch in the meantime?


--
Keith Smiley

> On Jan 17, 2018, at 01:48, Duy Nguyen  wrote:
> 
>> On Wed, Jan 17, 2018 at 1:17 PM, Kevin Daudt  wrote:
>>> On Wed, Jan 17, 2018 at 07:44:19AM +0700, Duy Nguyen wrote:
>>> PS. This also makes me thing about supporting subcommand aliases, so
>>> that people can add back 'git remote rm' if they like (or something
>>> like 'git r rm' when they alias 'remote' as well). Which is probably a
>>> good thing to do. Long command names are fine when you have completion
>>> support, they are a pain to type otherwise.
>>> 
>> 
>> Couldn't they just create an alias like git rrm then, if they use it so
>> often that it becomes an issue?
> 
> They could. The only exception that may not work is if they want to
> insert some options between "r" and "rm". Sometimes option positions
> matter. Anyway this is just thinking out loud, maybe we don't really
> need it until people scream about it with a valid use case
> 
>> Having another layer of aliases does create a lot of complexity.
> 
> Yes. It's partly the reason I wanted this actually ;-) Many commands
> have gained subcommands nowadays but there's no shared infrastructure
> for managing these subcommands. By adding something that works across
> the board at subcommand level I'm forced to "fix" this (or probably
> never get to do the sub-aliasing because this "fix" takes forever).
> -- 
> Duy



Re: [PATCH] Add shell completion for git remote rm

2018-01-17 Thread Junio C Hamano
Duy Nguyen  writes:

> Looks good. If we want to be more careful, we can follow up with
> something even more annoying like this before removing 'rm'
>
> -- 8< --
> diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
> index 577b969c1b..0a544703e6 100644
> --- a/Documentation/git-remote.txt
> +++ b/Documentation/git-remote.txt
> @@ -90,7 +90,6 @@ In case  and  are the same, and  is a file 
> under
>  the configuration file format.
>  
>  'remove'::
> -'rm'::
>  
>  Remove the remote named . All remote-tracking branches and
>  configuration settings for the remote are removed.
> diff --git a/builtin/remote.c b/builtin/remote.c
> index d95bf904c3..774ef6931e 100644
> --- a/builtin/remote.c
> +++ b/builtin/remote.c
> @@ -1609,7 +1609,10 @@ int cmd_remote(int argc, const char **argv, const char 
> *prefix)
>   result = add(argc, argv);
>   else if (!strcmp(argv[0], "rename"))
>   result = mv(argc, argv);
> - else if (!strcmp(argv[0], "rm") || !strcmp(argv[0], "remove"))
> + else if (!strcmp(argv[0], "rm")) {
> + warning(_("'rm' is a deprecated synonym. Use 'remove' 
> instead."));
> + result = rm(argc, argv);
> + } else if (!strcmp(argv[0], "remove"))
>   result = rm(argc, argv);
>   else if (!strcmp(argv[0], "set-head"))
>   result = set_head(argc, argv);
> -- 8< --

Yes, this is a sensible way to properly deprecate it further before
removal.


Re: [PATCH] Add shell completion for git remote rm

2018-01-17 Thread Duy Nguyen
On Wed, Jan 17, 2018 at 1:17 PM, Kevin Daudt  wrote:
> On Wed, Jan 17, 2018 at 07:44:19AM +0700, Duy Nguyen wrote:
>> PS. This also makes me thing about supporting subcommand aliases, so
>> that people can add back 'git remote rm' if they like (or something
>> like 'git r rm' when they alias 'remote' as well). Which is probably a
>> good thing to do. Long command names are fine when you have completion
>> support, they are a pain to type otherwise.
>>
>
> Couldn't they just create an alias like git rrm then, if they use it so
> often that it becomes an issue?

They could. The only exception that may not work is if they want to
insert some options between "r" and "rm". Sometimes option positions
matter. Anyway this is just thinking out loud, maybe we don't really
need it until people scream about it with a valid use case

> Having another layer of aliases does create a lot of complexity.

Yes. It's partly the reason I wanted this actually ;-) Many commands
have gained subcommands nowadays but there's no shared infrastructure
for managing these subcommands. By adding something that works across
the board at subcommand level I'm forced to "fix" this (or probably
never get to do the sub-aliasing because this "fix" takes forever).
-- 
Duy


Re: [PATCH] Add shell completion for git remote rm

2018-01-16 Thread Kevin Daudt
On Wed, Jan 17, 2018 at 07:44:19AM +0700, Duy Nguyen wrote:
> On Tue, Jan 16, 2018 at 10:57:34AM -0800, Junio C Hamano wrote:
> > Duy Nguyen  writes:
> > 
> > > On Tue, Jan 16, 2018 at 4:43 AM, Keith Smiley  wrote:
> > >> So it sounds like either we should deprecate rm, or I should update the 
> > >> patch to the suggested method where we just complete remotes, but not rm 
> > >> in the list of completions.
> > >
> > > I vote for deprecation. I could send a patch to start warning to
> > > switch from 'rm' to 'remove'. Then perhaps we can delete it after two
> > > releases. It's not classified as plumbing should we don't have worry
> > > too much about scripts relying on 'remote rm'.
> > 
> > I do not know about "two releases" part (which amounts to merely
> > 20-24 weeks), but looking at "git remote -h" output and seeing that
> > we do spell out "rename" (instead of saying "mv" or something cryptic),
> > it probably makes sense to remove "rm" some time in the future.
> > 
> > I actually do think "rm" is _already_ deprecated.  
> > 
> > "git remote --help" does not mention it in its synopsis section and
> > it merely has ", rm" after "remove" as if an afterthought.
> 
> It's actually my bad. I should have replaced 'rm' with 'remove' in
> git-remote.txt in e17dba8fe1 (remote: prefer subcommand name 'remove'
> to 'rm' - 2012-09-06)
> 
> > I am not sure if it is worth being more explicit, perhaps like this?
> 
> Looks good. If we want to be more careful, we can follow up with
> something even more annoying like this before removing 'rm'
> 
> -- 8< --
> diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
> index 577b969c1b..0a544703e6 100644
> --- a/Documentation/git-remote.txt
> +++ b/Documentation/git-remote.txt
> @@ -90,7 +90,6 @@ In case  and  are the same, and  is a file 
> under
>  the configuration file format.
>  
>  'remove'::
> -'rm'::
>  
>  Remove the remote named . All remote-tracking branches and
>  configuration settings for the remote are removed.
> diff --git a/builtin/remote.c b/builtin/remote.c
> index d95bf904c3..774ef6931e 100644
> --- a/builtin/remote.c
> +++ b/builtin/remote.c
> @@ -1609,7 +1609,10 @@ int cmd_remote(int argc, const char **argv, const char 
> *prefix)
>   result = add(argc, argv);
>   else if (!strcmp(argv[0], "rename"))
>   result = mv(argc, argv);
> - else if (!strcmp(argv[0], "rm") || !strcmp(argv[0], "remove"))
> + else if (!strcmp(argv[0], "rm")) {
> + warning(_("'rm' is a deprecated synonym. Use 'remove' 
> instead."));
> + result = rm(argc, argv);
> + } else if (!strcmp(argv[0], "remove"))
>   result = rm(argc, argv);
>   else if (!strcmp(argv[0], "set-head"))
>   result = set_head(argc, argv);
> -- 8< --
> 
> PS. This also makes me thing about supporting subcommand aliases, so
> that people can add back 'git remote rm' if they like (or something
> like 'git r rm' when they alias 'remote' as well). Which is probably a
> good thing to do. Long command names are fine when you have completion
> support, they are a pain to type otherwise.
> 

Couldn't they just create an alias like git rrm then, if they use it so
often that it becomes an issue? Having another layer of aliases does
create a lot of complexity.

> --
> Duy


Re: [PATCH] Add shell completion for git remote rm

2018-01-16 Thread Duy Nguyen
On Tue, Jan 16, 2018 at 10:57:34AM -0800, Junio C Hamano wrote:
> Duy Nguyen  writes:
> 
> > On Tue, Jan 16, 2018 at 4:43 AM, Keith Smiley  wrote:
> >> So it sounds like either we should deprecate rm, or I should update the 
> >> patch to the suggested method where we just complete remotes, but not rm 
> >> in the list of completions.
> >
> > I vote for deprecation. I could send a patch to start warning to
> > switch from 'rm' to 'remove'. Then perhaps we can delete it after two
> > releases. It's not classified as plumbing should we don't have worry
> > too much about scripts relying on 'remote rm'.
> 
> I do not know about "two releases" part (which amounts to merely
> 20-24 weeks), but looking at "git remote -h" output and seeing that
> we do spell out "rename" (instead of saying "mv" or something cryptic),
> it probably makes sense to remove "rm" some time in the future.
> 
> I actually do think "rm" is _already_ deprecated.  
> 
> "git remote --help" does not mention it in its synopsis section and
> it merely has ", rm" after "remove" as if an afterthought.

It's actually my bad. I should have replaced 'rm' with 'remove' in
git-remote.txt in e17dba8fe1 (remote: prefer subcommand name 'remove'
to 'rm' - 2012-09-06)

> I am not sure if it is worth being more explicit, perhaps like this?

Looks good. If we want to be more careful, we can follow up with
something even more annoying like this before removing 'rm'

-- 8< --
diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 577b969c1b..0a544703e6 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -90,7 +90,6 @@ In case  and  are the same, and  is a file 
under
 the configuration file format.
 
 'remove'::
-'rm'::
 
 Remove the remote named . All remote-tracking branches and
 configuration settings for the remote are removed.
diff --git a/builtin/remote.c b/builtin/remote.c
index d95bf904c3..774ef6931e 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -1609,7 +1609,10 @@ int cmd_remote(int argc, const char **argv, const char 
*prefix)
result = add(argc, argv);
else if (!strcmp(argv[0], "rename"))
result = mv(argc, argv);
-   else if (!strcmp(argv[0], "rm") || !strcmp(argv[0], "remove"))
+   else if (!strcmp(argv[0], "rm")) {
+   warning(_("'rm' is a deprecated synonym. Use 'remove' 
instead."));
+   result = rm(argc, argv);
+   } else if (!strcmp(argv[0], "remove"))
result = rm(argc, argv);
else if (!strcmp(argv[0], "set-head"))
result = set_head(argc, argv);
-- 8< --

PS. This also makes me thing about supporting subcommand aliases, so
that people can add back 'git remote rm' if they like (or something
like 'git r rm' when they alias 'remote' as well). Which is probably a
good thing to do. Long command names are fine when you have completion
support, they are a pain to type otherwise.

--
Duy


Re: [PATCH] Add shell completion for git remote rm

2018-01-16 Thread Junio C Hamano
Duy Nguyen  writes:

> On Tue, Jan 16, 2018 at 4:43 AM, Keith Smiley  wrote:
>> So it sounds like either we should deprecate rm, or I should update the 
>> patch to the suggested method where we just complete remotes, but not rm in 
>> the list of completions.
>
> I vote for deprecation. I could send a patch to start warning to
> switch from 'rm' to 'remove'. Then perhaps we can delete it after two
> releases. It's not classified as plumbing should we don't have worry
> too much about scripts relying on 'remote rm'.

I do not know about "two releases" part (which amounts to merely
20-24 weeks), but looking at "git remote -h" output and seeing that
we do spell out "rename" (instead of saying "mv" or something cryptic),
it probably makes sense to remove "rm" some time in the future.

I actually do think "rm" is _already_ deprecated.  

"git remote --help" does not mention it in its synopsis section and
it merely has ", rm" after "remove" as if an afterthought.  I am not
sure if it is worth being more explicit, perhaps like this?

 Documentation/git-remote.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-remote.txt b/Documentation/git-remote.txt
index 577b969c1b..149db90346 100644
--- a/Documentation/git-remote.txt
+++ b/Documentation/git-remote.txt
@@ -93,7 +93,8 @@ the configuration file format.
 'rm'::
 
 Remove the remote named . All remote-tracking branches and
-configuration settings for the remote are removed.
+configuration settings for the remote are removed.  `rm` is a deprecated
+synonym that will be removed in future versions of Git.
 
 'set-head'::
 


Re: [PATCH] Add shell completion for git remote rm

2018-01-16 Thread Duy Nguyen
On Tue, Jan 16, 2018 at 4:43 AM, Keith Smiley  wrote:
> So it sounds like either we should deprecate rm, or I should update the patch 
> to the suggested method where we just complete remotes, but not rm in the 
> list of completions.

I vote for deprecation. I could send a patch to start warning to
switch from 'rm' to 'remove'. Then perhaps we can delete it after two
releases. It's not classified as plumbing should we don't have worry
too much about scripts relying on 'remote rm'.

>
> Thoughts?
>
> --
> Keith Smiley
-- 
Duy


Re: [PATCH] Add shell completion for git remote rm

2018-01-15 Thread Keith Smiley
So it sounds like either we should deprecate rm, or I should update the patch 
to the suggested method where we just complete remotes, but not rm in the list 
of completions.

Thoughts?

-- 
Keith Smiley

On Wed, Jan 3, 2018, at 11:24, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason  writes:
> 
> > On Sat, Dec 30 2017, Todd Zullinger jotted:
> >
> >> And I think that should also apply to
> >> not offering completion for commands/subcommands/options
> >> which are only kept for backward compatibility.
> >
> > Yeah I think it makes sense to at some point stop completing things if
> > we're going to remove stuff, if we decide to remove it.
> >
> >> Here's one way to make 'git remote rm ' work without
> >> including it in the output of 'git remote ':
> >>
> >> diff --git i/contrib/completion/git-completion.bash 
> >> w/contrib/completion/git-completion.bash
> >> index 3683c772c5..aa63f028ab 100644
> >> --- i/contrib/completion/git-completion.bash
> >> +++ w/contrib/completion/git-completion.bash
> >> @@ -2668,7 +2668,9 @@ _git_remote ()
> >>add rename remove set-head set-branches
> >>get-url set-url show prune update
> >>"
> >> -  local subcommand="$(__git_find_on_cmdline "$subcommands")"
> >> +  # Don't advertise rm by including it in subcommands, but complete
> >> +  # remotes if it is used.
> >> +  local subcommand="$(__git_find_on_cmdline "$subcommands rm")"
> >>if [ -z "$subcommand" ]; then
> >>case "$cur" in
> >>--*)
> >
> > Neat!
> 
> Yes, indeed it is nice.
> 
> 


Re: [PATCH] Add shell completion for git remote rm

2018-01-03 Thread Junio C Hamano
Ævar Arnfjörð Bjarmason  writes:

> On Sat, Dec 30 2017, Todd Zullinger jotted:
>
>> And I think that should also apply to
>> not offering completion for commands/subcommands/options
>> which are only kept for backward compatibility.
>
> Yeah I think it makes sense to at some point stop completing things if
> we're going to remove stuff, if we decide to remove it.
>
>> Here's one way to make 'git remote rm ' work without
>> including it in the output of 'git remote ':
>>
>> diff --git i/contrib/completion/git-completion.bash 
>> w/contrib/completion/git-completion.bash
>> index 3683c772c5..aa63f028ab 100644
>> --- i/contrib/completion/git-completion.bash
>> +++ w/contrib/completion/git-completion.bash
>> @@ -2668,7 +2668,9 @@ _git_remote ()
>>  add rename remove set-head set-branches
>>  get-url set-url show prune update
>>  "
>> -local subcommand="$(__git_find_on_cmdline "$subcommands")"
>> +# Don't advertise rm by including it in subcommands, but complete
>> +# remotes if it is used.
>> +local subcommand="$(__git_find_on_cmdline "$subcommands rm")"
>>  if [ -z "$subcommand" ]; then
>>  case "$cur" in
>>  --*)
>
> Neat!

Yes, indeed it is nice.




Re: [PATCH] Add shell completion for git remote rm

2018-01-01 Thread Duy Nguyen
On Fri, Dec 29, 2017 at 11:19 AM, Keith Smiley  wrote:
> It looks like that was just about preferring remove in documentation and the
> like, I think it would still make sense to have both for completion since rm
> is still supported.

'rm' should be deprecated. But because I did not really push for a
deprecation plan and 'rm' still remains after 5 years, I guess it may
be counted as "supported" too (or we can start the deprecation process
now).

>> Keith Smiley wrote:
>>>
>>> Previously git remote rm did not complete your list of removes as remove
>>> does.
>>
>>
>> Looking through the history, the rm subcomand completion was
>> explicitly removed in e17dba8fe1 ("remote: prefer subcommand
>> name 'remove' to 'rm'", 2012-09-06).
-- 
Duy


Re: [PATCH] Add shell completion for git remote rm

2017-12-31 Thread Keith Smiley
I'm definitely happy to update this patch for now to just complete the 
remote names, and not add rm to the list of subcommand completions if 
we're all ok with that!


--
Keith Smiley

On 12/30, Ævar Arnfjörð Bjarmason wrote:


On Sat, Dec 30 2017, Todd Zullinger jotted:


Ævar Arnfjörð Bjarmason wrote:

I think adding 'rm' to completion definitely counts as advertisement.
It doesn't have much practical use, after all: typing 'rm' with
completion is actually one more keystroke than without (rm vs. rm).


This is only one use of the completion interface, maybe you only use it
like that, but not everyone does.

The completion interface has two uses, one is to actually save you
typing, the other is subcommand discovery, and maybe someone who has a
use neither you or I have thought of is about to point out a third.

I'll type "git $whatever $subcommand" as *validation* that I've
found the right command, not to complete it for me. This is a thing
that's in my muscle memory for everything.


Is that meant to be in favor of including rm in the
completion results or against? :)


For.


Since I've been typing "git remote rm" for a while (started before
this deprecation happened) I've actually been meaning to submit
completion for "rm" since it works, not knowing about Duy's patch until
now.

Now, even if someone disagrees that we should have "rm" at all I think
that in general we should not conflate two different things, one is
whether:

git remote 

shows both "rm" and "remove" in the list, and the other is whether:

git remote rm

Should yield:

git remote rm

Or, as now happens:

git remote rm

I can see why we'd, in general, we'd like to not advertise certain
options for completion (due to deprecation, or just to avoid verbosity),
but complete them once they're unambiguously typed out.

I don't know whether the bash completion interface supports making that
distinction, but it would be useful.


It can be done, though I think that it's probably better to
subtly lead people to use 'git remote remove' going forward,
to keep things consistent.  I don't have a strong preference
for or against the rm -> remove change, but since that's
been done I think there's a benefit to keeping things
consistent in the UI.


We changed it in the past, we can always change it again, it's never too
late to fix the UI.

Now whether we *should* change/fix this particular thing is another
matter. I'm just pointing out that we shouldn't fall into the trap of
thinking that git's UI is an established platform that can't be changed.

The vast majority of people who'll ever use git will most likely start
using a version that we're going to release many years into the future.

I'm reminded of the story about the guy who decided makefiles must have
tabs, who didn't want to change it because he already had some dozens of
users.


And I think that should also apply to
not offering completion for commands/subcommands/options
which are only kept for backward compatibility.


Yeah I think it makes sense to at some point stop completing things if
we're going to remove stuff, if we decide to remove it.


Here's one way to make 'git remote rm ' work without
including it in the output of 'git remote ':

diff --git i/contrib/completion/git-completion.bash 
w/contrib/completion/git-completion.bash
index 3683c772c5..aa63f028ab 100644
--- i/contrib/completion/git-completion.bash
+++ w/contrib/completion/git-completion.bash
@@ -2668,7 +2668,9 @@ _git_remote ()
add rename remove set-head set-branches
get-url set-url show prune update
"
-   local subcommand="$(__git_find_on_cmdline "$subcommands")"
+   # Don't advertise rm by including it in subcommands, but complete
+   # remotes if it is used.
+   local subcommand="$(__git_find_on_cmdline "$subcommands rm")"
if [ -z "$subcommand" ]; then
case "$cur" in
--*)


Neat!


Keeping 'git remote rm' working to avoid breaking scripts is
one thing, but having it in the completion code makes it
more likely that it will continue to be seen as a
recommended subcommand.

This leads to patches like this one, where it's presumed
that the lack of completion is simply an oversight or a bug.
Of course, the lack of completion hasn't caused everyone to
forget that 'remote rm' was changed to 'remote remove', so
that reasoning may be full of hot air (or worse). ;)

The current result of 'git remote rm ' isn't so great.
It's arguably worse to have it pretend that no subcommand
was given than to list the remotes.

$ git remote rm 
addremove set-head   update
get-urlrename set-url
prune  set-branches   show


Although that's a bug that has nothing to do with remove/rm, because you
also get:

   $ git remote blahblah 
   $ git rebase doesntexist 

etc. showing you valid subcommands, when perhaps we should show
"warning: no such subcommand `blahblah`/`doesntexist`!" 

Re: [PATCH] Add shell completion for git remote rm

2017-12-30 Thread Ævar Arnfjörð Bjarmason

On Sat, Dec 30 2017, Todd Zullinger jotted:

> Ævar Arnfjörð Bjarmason wrote:
>>> I think adding 'rm' to completion definitely counts as advertisement.
>>> It doesn't have much practical use, after all: typing 'rm' with
>>> completion is actually one more keystroke than without (rm vs. rm).
>>
>> This is only one use of the completion interface, maybe you only use it
>> like that, but not everyone does.
>>
>> The completion interface has two uses, one is to actually save you
>> typing, the other is subcommand discovery, and maybe someone who has a
>> use neither you or I have thought of is about to point out a third.
>>
>> I'll type "git $whatever $subcommand" as *validation* that I've
>> found the right command, not to complete it for me. This is a thing
>> that's in my muscle memory for everything.
>
> Is that meant to be in favor of including rm in the
> completion results or against? :)

For.

>> Since I've been typing "git remote rm" for a while (started before
>> this deprecation happened) I've actually been meaning to submit
>> completion for "rm" since it works, not knowing about Duy's patch until
>> now.
>>
>> Now, even if someone disagrees that we should have "rm" at all I think
>> that in general we should not conflate two different things, one is
>> whether:
>>
>> git remote 
>>
>> shows both "rm" and "remove" in the list, and the other is whether:
>>
>> git remote rm
>>
>> Should yield:
>>
>> git remote rm
>>
>> Or, as now happens:
>>
>> git remote rm
>>
>> I can see why we'd, in general, we'd like to not advertise certain
>> options for completion (due to deprecation, or just to avoid verbosity),
>> but complete them once they're unambiguously typed out.
>>
>> I don't know whether the bash completion interface supports making that
>> distinction, but it would be useful.
>
> It can be done, though I think that it's probably better to
> subtly lead people to use 'git remote remove' going forward,
> to keep things consistent.  I don't have a strong preference
> for or against the rm -> remove change, but since that's
> been done I think there's a benefit to keeping things
> consistent in the UI.

We changed it in the past, we can always change it again, it's never too
late to fix the UI.

Now whether we *should* change/fix this particular thing is another
matter. I'm just pointing out that we shouldn't fall into the trap of
thinking that git's UI is an established platform that can't be changed.

The vast majority of people who'll ever use git will most likely start
using a version that we're going to release many years into the future.

I'm reminded of the story about the guy who decided makefiles must have
tabs, who didn't want to change it because he already had some dozens of
users.

> And I think that should also apply to
> not offering completion for commands/subcommands/options
> which are only kept for backward compatibility.

Yeah I think it makes sense to at some point stop completing things if
we're going to remove stuff, if we decide to remove it.

> Here's one way to make 'git remote rm ' work without
> including it in the output of 'git remote ':
>
> diff --git i/contrib/completion/git-completion.bash 
> w/contrib/completion/git-completion.bash
> index 3683c772c5..aa63f028ab 100644
> --- i/contrib/completion/git-completion.bash
> +++ w/contrib/completion/git-completion.bash
> @@ -2668,7 +2668,9 @@ _git_remote ()
>   add rename remove set-head set-branches
>   get-url set-url show prune update
>   "
> - local subcommand="$(__git_find_on_cmdline "$subcommands")"
> + # Don't advertise rm by including it in subcommands, but complete
> + # remotes if it is used.
> + local subcommand="$(__git_find_on_cmdline "$subcommands rm")"
>   if [ -z "$subcommand" ]; then
>   case "$cur" in
>   --*)

Neat!

> Keeping 'git remote rm' working to avoid breaking scripts is
> one thing, but having it in the completion code makes it
> more likely that it will continue to be seen as a
> recommended subcommand.
>
> This leads to patches like this one, where it's presumed
> that the lack of completion is simply an oversight or a bug.
> Of course, the lack of completion hasn't caused everyone to
> forget that 'remote rm' was changed to 'remote remove', so
> that reasoning may be full of hot air (or worse). ;)
>
> The current result of 'git remote rm ' isn't so great.
> It's arguably worse to have it pretend that no subcommand
> was given than to list the remotes.
>
> $ git remote rm 
> addremove set-head   update
> get-urlrename set-url
> prune  set-branches   show

Although that's a bug that has nothing to do with remove/rm, because you
also get:

$ git remote blahblah 
$ git rebase doesntexist 

etc. showing you valid subcommands, when perhaps we should show
"warning: no such subcommand `blahblah`/`doesntexist`!" instead.

> I think completing nothing or 

Re: [PATCH] Add shell completion for git remote rm

2017-12-29 Thread Todd Zullinger
Ævar Arnfjörð Bjarmason wrote:
>> I think adding 'rm' to completion definitely counts as advertisement.
>> It doesn't have much practical use, after all: typing 'rm' with
>> completion is actually one more keystroke than without (rm vs. rm).
> 
> This is only one use of the completion interface, maybe you only use it
> like that, but not everyone does.
> 
> The completion interface has two uses, one is to actually save you
> typing, the other is subcommand discovery, and maybe someone who has a
> use neither you or I have thought of is about to point out a third.
> 
> I'll type "git $whatever $subcommand" as *validation* that I've
> found the right command, not to complete it for me. This is a thing
> that's in my muscle memory for everything.

Is that meant to be in favor of including rm in the
completion results or against? :)

> Since I've been typing "git remote rm" for a while (started before
> this deprecation happened) I've actually been meaning to submit
> completion for "rm" since it works, not knowing about Duy's patch until
> now.
> 
> Now, even if someone disagrees that we should have "rm" at all I think
> that in general we should not conflate two different things, one is
> whether:
> 
> git remote 
> 
> shows both "rm" and "remove" in the list, and the other is whether:
> 
> git remote rm
> 
> Should yield:
> 
> git remote rm
> 
> Or, as now happens:
> 
> git remote rm
> 
> I can see why we'd, in general, we'd like to not advertise certain
> options for completion (due to deprecation, or just to avoid verbosity),
> but complete them once they're unambiguously typed out.
> 
> I don't know whether the bash completion interface supports making that
> distinction, but it would be useful.

It can be done, though I think that it's probably better to
subtly lead people to use 'git remote remove' going forward,
to keep things consistent.  I don't have a strong preference
for or against the rm -> remove change, but since that's
been done I think there's a benefit to keeping things
consistent in the UI.  And I think that should also apply to
not offering completion for commands/subcommands/options
which are only kept for backward compatibility.

Here's one way to make 'git remote rm ' work without
including it in the output of 'git remote ':

diff --git i/contrib/completion/git-completion.bash 
w/contrib/completion/git-completion.bash
index 3683c772c5..aa63f028ab 100644
--- i/contrib/completion/git-completion.bash
+++ w/contrib/completion/git-completion.bash
@@ -2668,7 +2668,9 @@ _git_remote ()
add rename remove set-head set-branches
get-url set-url show prune update
"
-   local subcommand="$(__git_find_on_cmdline "$subcommands")"
+   # Don't advertise rm by including it in subcommands, but complete
+   # remotes if it is used.
+   local subcommand="$(__git_find_on_cmdline "$subcommands rm")"
if [ -z "$subcommand" ]; then
case "$cur" in
--*)

Keeping 'git remote rm' working to avoid breaking scripts is
one thing, but having it in the completion code makes it
more likely that it will continue to be seen as a
recommended subcommand.

This leads to patches like this one, where it's presumed
that the lack of completion is simply an oversight or a bug.
Of course, the lack of completion hasn't caused everyone to
forget that 'remote rm' was changed to 'remote remove', so
that reasoning may be full of hot air (or worse). ;)

The current result of 'git remote rm ' isn't so great.
It's arguably worse to have it pretend that no subcommand
was given than to list the remotes.

$ git remote rm 
addremove set-head   update
get-urlrename set-url
prune  set-branches   show

I think completing nothing or completing the remotes
(without offering rm in the subcommand list) would be
better, after looking at it a bit.

I don't know how to disable file completion, but I'm not
intimately familiar with the git completion script (thanks
to it working so damn well).  I'm guessing there's a way to
do that, if there's a strong desire to not complete the
remotes at all.

I don't think we should include rm in 'git remote '
completion, but I don't care much either way what 'git
remote rm ' includes.  But it should be better than
including the other subcommands.

-- 
Todd
~~
There, I've gone and soiled myself, are you happy now?!
-- Stewie Griffin



Re: [PATCH] Add shell completion for git remote rm

2017-12-29 Thread Ævar Arnfjörð Bjarmason

On Fri, Dec 29 2017, SZEDER Gábor jotted:

>> Keith Smiley wrote:
>> > It looks like that was just about preferring remove in documentation
>> > and the like, I think it would still make sense to have both for
>> > completion since rm is still supported.
>>
>> I read it as a first step in a long process to eventually
>> remove 'remote rm', but if that's never intended, then sure,
>> restoring completion for it seems reasonable.
>>
>> It would be good to hear from those who know or recall the
>> intention.
>>
>> I think we should only complete the preferred subcommand.
>> That encourages use of 'remote remove' even if 'remote rm'
>> will stay forever to avoid breaking existing scripts.
>
> Quoting from the commit message of e17dba8fe1 ("remote: prefer
> subcommand name 'remove' to 'rm'", 2012-09-06):
>
>   'rm' is still supported and used in the test suite. It's just not
>   widely advertised.

I think we made the wrong choice in standardizing on remove instead of
rm, it should be rm for consistency with git-rm, and "remote rename"
should be "remote mv" etc., just like we have git-mv.

Maybe if we didn't have the Unix legacy we'd pick rename and remove to
be consitent for both, but since that's not going to happen this bit of
inconsistency is worse.

Now with that showing of my biases out of the way...

> I think adding 'rm' to completion definitely counts as advertisement.
> It doesn't have much practical use, after all: typing 'rm' with
> completion is actually one more keystroke than without (rm vs. rm).

This is only one use of the completion interface, maybe you only use it
like that, but not everyone does.

The completion interface has two uses, one is to actually save you
typing, the other is subcommand discovery, and maybe someone who has a
use neither you or I have thought of is about to point out a third.

I'll type "git $whatever $subcommand" as *validation* that I've
found the right command, not to complete it for me. This is a thing
that's in my muscle memory for everything.

The post-hoc reason is because if you're a fast typist you don't
actually save time on typing the command (usually I just use reverse
shell search anyway), but rather on not screwing up the command itself
via a typo.

Sometimes commands take a while to fail, and even if it's immediate
re-editing them takes longer than getting it right in the first place.

Since I've been typing "git remote rm" for a while (started before
this deprecation happened) I've actually been meaning to submit
completion for "rm" since it works, not knowing about Duy's patch until
now.

Now, even if someone disagrees that we should have "rm" at all I think
that in general we should not conflate two different things, one is
whether:

git remote 

shows both "rm" and "remove" in the list, and the other is whether:

git remote rm

Should yield:

git remote rm

Or, as now happens:

git remote rm

I can see why we'd, in general, we'd like to not advertise certain
options for completion (due to deprecation, or just to avoid verbosity),
but complete them once they're unambiguously typed out.

I don't know whether the bash completion interface supports making that
distinction, but it would be useful.


Re: [PATCH] Add shell completion for git remote rm

2017-12-29 Thread Keith Smiley
The goal of this fix isn't to complete rm itself (although that is a 
side effect), it's to complete the remote names after you type rm.


Without this patch doing this:

git remote rm 

Attempts to complete the options for `git remote` instead of the remote 
names.


--
Keith Smiley

On 12/29, SZEDER Gábor wrote:

Keith Smiley wrote:
> It looks like that was just about preferring remove in documentation
> and the like, I think it would still make sense to have both for
> completion since rm is still supported.

I read it as a first step in a long process to eventually
remove 'remote rm', but if that's never intended, then sure,
restoring completion for it seems reasonable.

It would be good to hear from those who know or recall the
intention.

I think we should only complete the preferred subcommand.
That encourages use of 'remote remove' even if 'remote rm'
will stay forever to avoid breaking existing scripts.


Quoting from the commit message of e17dba8fe1 ("remote: prefer
subcommand name 'remove' to 'rm'", 2012-09-06):

 'rm' is still supported and used in the test suite. It's just not
 widely advertised.

I think adding 'rm' to completion definitely counts as advertisement.
It doesn't have much practical use, after all: typing 'rm' with
completion is actually one more keystroke than without (rm vs. rm).


Gábor



Re: [PATCH] Add shell completion for git remote rm

2017-12-29 Thread SZEDER Gábor
> Keith Smiley wrote:
> > It looks like that was just about preferring remove in documentation
> > and the like, I think it would still make sense to have both for
> > completion since rm is still supported.
> 
> I read it as a first step in a long process to eventually
> remove 'remote rm', but if that's never intended, then sure,
> restoring completion for it seems reasonable.
> 
> It would be good to hear from those who know or recall the
> intention.
> 
> I think we should only complete the preferred subcommand.
> That encourages use of 'remote remove' even if 'remote rm'
> will stay forever to avoid breaking existing scripts.

Quoting from the commit message of e17dba8fe1 ("remote: prefer
subcommand name 'remove' to 'rm'", 2012-09-06):

  'rm' is still supported and used in the test suite. It's just not
  widely advertised.

I think adding 'rm' to completion definitely counts as advertisement.
It doesn't have much practical use, after all: typing 'rm' with
completion is actually one more keystroke than without (rm vs. rm).


Gábor



Re: [PATCH] Add shell completion for git remote rm

2017-12-29 Thread Todd Zullinger
Keith Smiley wrote:
> It looks like that was just about preferring remove in documentation
> and the like, I think it would still make sense to have both for
> completion since rm is still supported.

I read it as a first step in a long process to eventually
remove 'remote rm', but if that's never intended, then sure,
restoring completion for it seems reasonable.

It would be good to hear from those who know or recall the
intention.

I think we should only complete the preferred subcommand.
That encourages use of 'remote remove' even if 'remote rm'
will stay forever to avoid breaking existing scripts.

If it does make sense to restore completion, adding a link
back to e17dba8fe1 and explaining why the completion is
being restored would be good.  Reading the commit message
now makes it sound like 'remote rm' was never present and is
being added to correct an oversight.

Maybe something like:

completion: restore 'remote rm'

e17dba8fe1 ("remote: prefer subcommand name 'remove' to
'rm'", 2012-09-06) removed the 'rm' subcommand from
completion.  The 'remote rm' subcommand is still supported
and not planned to be removed.  Offer completions for it.

I also noticed that in your original commit that you say
"list of removes as remove does." That should be "remotes"
instead of "removes" there. -- I've made that typo myself
quite often. :)

-- 
Todd
~~
There are no stupid questions, but there are a LOT of inquisitive
idiots.
-- Demotivators (www.despair.com)



Re: [PATCH] Add shell completion for git remote rm

2017-12-28 Thread Keith Smiley

Sorry about that! Patch below.


Previously git remote rm did not complete your list of removes as remove
does.

Signed-off-by: Keith Smiley 
---
contrib/completion/git-completion.bash | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 3683c772c5586..3e9044087e6ba 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2665,7 +2665,7 @@ _git_config ()
_git_remote ()
{
local subcommands="
-   add rename remove set-head set-branches
+   add rename remove rm set-head set-branches
get-url set-url show prune update
"
local subcommand="$(__git_find_on_cmdline "$subcommands")"

--
Keith Smiley

On 12/29, Kevin Daudt wrote:

On Fri, Dec 29, 2017 at 02:01:00AM +, Keith Smiley wrote:

From: Keith Smiley 

Previously git remote rm did not complete your list of removes as remove
does.


Your signed-off-by[1] is missing, could you please add that?

[1]:
https://github.com/git/git/blob/master/Documentation/SubmittingPatches#L278


---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 3683c772c5586..3e9044087e6ba 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2665,7 +2665,7 @@ _git_config ()
 _git_remote ()
 {
local subcommands="
-   add rename remove set-head set-branches
+   add rename remove rm set-head set-branches
get-url set-url show prune update
"
local subcommand="$(__git_find_on_cmdline "$subcommands")"

--
https://github.com/git/git/pull/448


Re: [PATCH] Add shell completion for git remote rm

2017-12-28 Thread Kevin Daudt
On Fri, Dec 29, 2017 at 02:01:00AM +, Keith Smiley wrote:
> From: Keith Smiley 
> 
> Previously git remote rm did not complete your list of removes as remove
> does.

Your signed-off-by[1] is missing, could you please add that?

[1]:
https://github.com/git/git/blob/master/Documentation/SubmittingPatches#L278

> ---
>  contrib/completion/git-completion.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/contrib/completion/git-completion.bash 
> b/contrib/completion/git-completion.bash
> index 3683c772c5586..3e9044087e6ba 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -2665,7 +2665,7 @@ _git_config ()
>  _git_remote ()
>  {
>   local subcommands="
> - add rename remove set-head set-branches
> + add rename remove rm set-head set-branches
>   get-url set-url show prune update
>   "
>   local subcommand="$(__git_find_on_cmdline "$subcommands")"
> 
> --
> https://github.com/git/git/pull/448


Re: [PATCH] Add shell completion for git remote rm

2017-12-28 Thread Keith Smiley
It looks like that was just about preferring remove in documentation and 
the like, I think it would still make sense to have both for completion 
since rm is still supported.


--
Keith Smiley

On 12/28, Todd Zullinger wrote:

Hi Keith,

Keith Smiley wrote:

Previously git remote rm did not complete your list of removes as remove
does.


Looking through the history, the rm subcomand completion was
explicitly removed in e17dba8fe1 ("remote: prefer subcommand
name 'remove' to 'rm'", 2012-09-06).

--
Todd
~~
Genius is 1% inspiration and 99% perspiration, which is why engineers
sometimes smell really bad.
   -- Demotivators (www.despair.com)



Re: [PATCH] Add shell completion for git remote rm

2017-12-28 Thread Todd Zullinger
Hi Keith,

Keith Smiley wrote:
> Previously git remote rm did not complete your list of removes as remove
> does.

Looking through the history, the rm subcomand completion was
explicitly removed in e17dba8fe1 ("remote: prefer subcommand
name 'remove' to 'rm'", 2012-09-06).

-- 
Todd
~~
Genius is 1% inspiration and 99% perspiration, which is why engineers
sometimes smell really bad.
-- Demotivators (www.despair.com)



[PATCH] Add shell completion for git remote rm

2017-12-28 Thread Keith Smiley
From: Keith Smiley 

Previously git remote rm did not complete your list of removes as remove
does.
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash 
b/contrib/completion/git-completion.bash
index 3683c772c5586..3e9044087e6ba 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2665,7 +2665,7 @@ _git_config ()
 _git_remote ()
 {
local subcommands="
-   add rename remove set-head set-branches
+   add rename remove rm set-head set-branches
get-url set-url show prune update
"
local subcommand="$(__git_find_on_cmdline "$subcommands")"

--
https://github.com/git/git/pull/448