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

Re: [PATCH] ls-remote: a lone "-h" is asking for help

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 16, 2011, 20:31 UTC
Message-ID
<7v1uvgfcur.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAGdFq_hug3zNwvDZ3c8iG-F8jJSuxsuFghMWtWTmUTdfTrWiqg@mail.gmail.com>
Sverre Rabbelier <srabbelier@gmail.com> writes:
Show 6 quoted lines
> On Fri, Sep 16, 2011 at 21:35, Junio C Hamano <gitster@pobox.com> wrote:
>> Sverre Rabbelier <srabbelier@gmail.com> writes:
>>> Should we really have "-h" as a short for anything other than "--help"
>>> in the first place?
> ...
> Does git 2.0 count?

I am not opposed to. We should do the usual "start from warning and then deprecate" dance, but I do not think we would want to have a "I want the old behaviour, please keep it" configuration, especially if we are talking about a big version bump like 2.0.

The first step would look something like this, on top of the previous patch.

 builtin/ls-remote.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 41c88a9..dabe21e 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -28,6 +28,12 @@ static int tail_match(const char **pattern, const char *path)
 	return 0;
 }
 
+static void warn_h_deprecation(void)
+{
+	warning("Using -h as synonym for --heads is deprecated");
+	warning("and will be removed in future versions of Git.");
+}
+
 int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 {
 	int i;
@@ -64,6 +70,8 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
 			}
 			if (!strcmp("--heads", arg) || !strcmp("-h", arg)) {
 				flags |= REF_HEADS;
+				if (!arg[2])
+					warn_h_deprecation();
 				continue;
 			}
 			if (!strcmp("--refs", arg)) {
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 5 of 7 in “ls-remote: a lone "-h" is asking for help”
  1. ls-remote: a lone "-h" is asking for helpJunio C Hamano, Sep 16, 2011
  2. Sverre RabbelierSep 16, 2011
  3. Junio C HamanoSep 16, 2011
  4. Sverre RabbelierSep 16, 2011
  5. Junio C HamanoSep 16, 2011
  6. Sverre RabbelierSep 16, 2011
  7. Junio C HamanoSep 16, 2011

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.