git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 6/6] completion: clarify ls-tree, archive, show completion

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 3, 2013, 17:33 UTC
Message-ID
<7vehcjgkuq.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1370181822-23450-7-git-send-email-artagnon@gmail.com>
Ramkumar Ramachandra <artagnon@gmail.com> writes:
Show 34 quoted lines
> Currently, the 'git ls-tree', 'git archive', and 'git show' completions
> use __git_complete_file (aliased to __git_complete_revlist_file).
>
> In the case of 'git ls-tree' and 'git archive', they necessarily require
> a tree-ish argument (and optionally a pathspec filter, or "file
> argument"):
>
>   $ git ls-tree hot-branch git.c
>   $ git archive HEAD~4 git.c
>
> So, __git_complete_file is a misleading name.
>
> In the case of 'git show', it can take a pathspec and default the
> revision to HEAD like:
>
>   $ git show git.c
>
> (which is useful if git.c was modified in HEAD)
>
> However, this usage is not idiomatic at all.  The more common usage is
> like:
>
>   $ git show HEAD~1
>   $ git show origin/pu:git.c
>
> So, __git_complete_file is again a poor name.
>
> Replace these three instances of __git_complete_file with
> __git_complete_revlist_file, without making any functional changes.
>
> Remove __git_complete_file, as it has no other callers.
>
> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
> ---

I think this is the same as 5/6 and better explained in a single patch, as the rationale is the same: these commands can all take the usual revs and then paths, so using misnamed complete_FILE helper is wrong.

Mind if I squashed them together?
Show 46 quoted lines
>  contrib/completion/git-completion.bash | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 8d70c30..84d1548 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -592,11 +592,6 @@ __git_complete_diff_index_file ()
>  	esac
>  }
>  
> -__git_complete_file ()
> -{
> -	__git_complete_revlist_file
> -}
> -
>  __git_complete_revlist ()
>  {
>  	__git_complete_revlist_file
> @@ -1007,7 +1002,7 @@ _git_archive ()
>  		return
>  		;;
>  	esac
> -	__git_complete_file
> +	__git_complete_revlist_file
>  }
>  
>  _git_bisect ()
> @@ -1476,7 +1471,7 @@ _git_ls_remote ()
>  
>  _git_ls_tree ()
>  {
> -	__git_complete_file
> +	__git_complete_revlist_file
>  }
>  
>  # Options that go well for log, shortlog and gitk
> @@ -2382,7 +2377,7 @@ _git_show ()
>  		return
>  		;;
>  	esac
> -	__git_complete_file
> +	__git_complete_revlist_file
>  }
>  
>  _git_show_branch ()
Previous: Ramkumar RamachandraNext: Ramkumar Ramachandra
Message 25 of 33 in “Minor prompt, completion cleanups”
  1. 0/6 Minor prompt, completion cleanupsRamkumar Ramachandra, Jun 2, 2013
  2. 1/6 prompt: don't scream continuation stateRamkumar Ramachandra, Jun 2, 2013
  3. Thomas RastJun 3, 2013
  4. Ramkumar RamachandraJun 3, 2013
  5. Jeff KingJun 3, 2013
  6. Ramkumar RamachandraJun 4, 2013
  7. Jeff KingJun 4, 2013
  8. Junio C HamanoJun 4, 2013
  9. Junio C HamanoJun 3, 2013
  10. 2/6 completion: add common options for rev-parseRamkumar Ramachandra, Jun 2, 2013
  11. Ramkumar RamachandraJun 7, 2013
  12. 3/6 completion: add common options for blameRamkumar Ramachandra, Jun 2, 2013
  13. Thomas RastJun 3, 2013
  14. Ramkumar RamachandraJun 3, 2013
  15. SZEDER GáborJun 3, 2013
  16. Junio C HamanoJun 3, 2013
  17. Peter KreftingJun 6, 2013
  18. Junio C HamanoJun 3, 2013
  19. 4/6 completion: correct completion for format-patchRamkumar Ramachandra, Jun 2, 2013
  20. Felipe ContrerasJun 2, 2013
  21. Ramkumar RamachandraJun 2, 2013
  22. 5/6 completion: clarify difftool completionRamkumar Ramachandra, Jun 2, 2013
  23. Junio C HamanoJun 3, 2013
  24. 6/6 completion: clarify ls-tree, archive, show completionRamkumar Ramachandra, Jun 2, 2013
  25. Junio C HamanoJun 3, 2013
  26. Ramkumar RamachandraJun 4, 2013
  27. Junio C HamanoJun 4, 2013
  28. Junio C HamanoJun 3, 2013
  29. SZEDER GáborJun 3, 2013
  30. Ramkumar RamachandraJun 7, 2013
  31. Junio C HamanoJun 7, 2013
  32. SZEDER GáborJun 7, 2013
  33. Junio C HamanoJun 9, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.