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

Re: [PATCH 3/4] remote: actually check if remote exits

From
Jeff King <peff@peff.net>
Date
Feb 15, 2016, 18:23 UTC
Message-ID
<20160215182324.GG26443@sigill.intra.peff.net>
In-Reply-To
<1455558150-30267-4-git-send-email-t.gummerer@gmail.com>
On Mon, Feb 15, 2016 at 06:42:29PM +0100, Thomas Gummerer wrote:
Show 25 quoted lines
> When converting the git remote command to a builtin in 211c89 ("Make
> git-remote a builtin"), a few calls to check if a remote exists were
> converted from:
>        if (!exists $remote->{$name}) {
>        	  [...]
> to:
>        remote = remote_get(argv[1]);
>        if (!remote)
>           [...]
> 
> The new check is not quite correct, because remote_get() never returns
> NULL if a name is given.  This leaves us with the somewhat cryptic error
> message "error: Could not remove config section 'remote.test'", if we
> are trying to remove a remote that does not exist, or a similar error if
> we try to rename a remote.
> 
> Use the remote_is_configured() function to check whether the remote
> actually exists, and die with a more sensible error message ("No such
> remote: $remotename") instead if it doesn't.
> 
> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
> ---
>  builtin/remote.c  |  4 ++--
>  t/t5505-remote.sh | 18 ++++++++++++++++++
>  2 files changed, 20 insertions(+), 2 deletions(-)
Nice. Very cleanly explained and implemented.
-Peff
Previous: Thomas GummererNext: Thomas Gummerer
Message 12 of 18 in “git remote improvements”
  1. 0/4 git remote improvementsThomas Gummerer, Feb 15, 2016
  2. 1/4 remote: use skip_prefixThomas Gummerer, Feb 15, 2016
  3. Jeff KingFeb 15, 2016
  4. Eric SunshineFeb 15, 2016
  5. Jeff KingFeb 15, 2016
  6. Thomas GummererFeb 15, 2016
  7. 2/4 remote: simplify remote_is_configured()Thomas Gummerer, Feb 15, 2016
  8. Jeff KingFeb 15, 2016
  9. Thomas GummererFeb 15, 2016
  10. Junio C HamanoFeb 15, 2016
  11. 3/4 remote: actually check if remote exitsThomas Gummerer, Feb 15, 2016
  12. Jeff KingFeb 15, 2016
  13. 4/4 remote: use remote_is_configured() for add and renameThomas Gummerer, Feb 15, 2016
  14. Jeff KingFeb 15, 2016
  15. Thomas GummererFeb 15, 2016
  16. Johannes SchindelinFeb 17, 2016
  17. Thomas GummererFeb 17, 2016
  18. Johannes SchindelinFeb 17, 2016

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.