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

Re: [PATCH] gitweb: Make git_get_refs_list do work of git_get_references

From
Junio C Hamano <junkio@cox.net>
Date
Sep 17, 2006, 01:22 UTC
Message-ID
<7vodtf8eym.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200609170226.39330.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Make git_get_refs_list do also work of git_get_references, to avoid
> calling git-peek-remote twice. It now returns either list of refs as
> before in scalar context, or references hash and list of refs in list
> context.

I do not think we want to have too many functions that return different things depending on contexts. Forcing callers to remember what the function does in which context is bad. You seem to like writing:

	my $value = that_function(@args)

but I'd rather see all callers to say:

	my ($value) = that_function(@args);

even when they expect just one value from the function. One less thing to remember, and one less source of surprises.

Especially for this particular case, you are not even avoiding extra computation when you are only returning list, so I do not think making the return value depend on the calling context is buying you much.

Previous: Jakub NarebskiNext: Randal L. Schwartz
Message 3 of 10 in “gitweb: Make git_get_refs_list do work of git_get_references”
  1. gitweb: Make git_get_refs_list do work of git_get_referencesJakub Narebski, Sep 17, 2006
  2. 1/2 gitweb: Always use git-peek-remote in git_get_referencesJakub Narebski, Sep 17, 2006
  3. Junio C HamanoSep 17, 2006
  4. Randal L. SchwartzSep 17, 2006
  5. Junio C HamanoSep 17, 2006
  6. Randal L. SchwartzSep 17, 2006
  7. Junio C HamanoSep 17, 2006
  8. Jakub NarebskiSep 17, 2006
  9. Jakub NarebskiSep 17, 2006
  10. Jakub NarebskiSep 17, 2006

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.