From: Teng Long <dyroneteng@gmail.com>
To: git@vger.kernel.org
Cc: tenglong.tl@alibaba-inc.com, Teng Long <dyroneteng@gmail.com>
Subject: [RFC PATCH v1 0/1] ls-remote: inconsistency from the order of args and opts
Date: Fri, 14 Jan 2022 12:24:22 +0800 [thread overview]
Message-ID: <cover.1642129840.git.dyroneteng@gmail.com> (raw)
It has a different results by executing "git ls-remote -heads origin"
and "git ls-remote origin --heads". A test for reproduction is as
follows:
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+test_description='test ls-tree for reproduction'
+
+. ./test-lib.sh
+
+
+test_must_fail 'Exchange the order of "--heads" and <remote>' '
+ git --version &&
+ git init "test.git" &&
+ test_commit -C "test.git" one &&
+ git -C "test.git" ls-remote --heads ./. > result.1 &&
+ git -C "test.git" ls-remote ./. --heads > result.2 &&
+ test_cmp result.1 result.2
+'
+
+test_done
--
2.34.1.391.g9ef3d6f133
"git -C "test.git" ls-remote ./. --heads" returns nothing here because
"ls-remote" supports to treat args as patterns to filter the refs list
, and "--heads" here as the pattern does not match any.
If a repo exists a ref which is named as "refs/heads/--heads", execute
`mgit ls-remote origin --heads` will return ("mgit" is a alias means
the git binary that is built by "master" in my env):
0319b78d7c31e5203d79157fe82960db88cc4a54 refs/heads/--heads
If we execute again in terms of this patch by `git ls-remote origin --heads`:
0319b78d7c31e5203d79157fe82960db88cc4a54 refs/heads/--heads
0319b78d7c31e5203d79157fe82960db88cc4a54 refs/heads/master
And if we hope to let "--heads" to be treated as a "pattern", we can execute
`git ls-remote origin --heads -- "--heads"`:
0319b78d7c31e5203d79157fe82960db88cc4a54 refs/heads/--heads
Personally, I think the second option is probably a little better, but there
are also possible backward compatibility issues, such as users ending branch
names with "-heads" and so on.
So I sent this patch to try to figure out if this was a requirement of the
original design, or if it was something that could really be improved, or if
we can find a better way to deal this issue with compatibility.
Thanks.
Teng Long (1):
ls-remote: Make the output independent of the order of opts and
<remote>
builtin/ls-remote.c | 3 +--
t/t5512-ls-remote.sh | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
Range-diff against v0:
-: ---------- > 1: 9ef3d6f133 ls-remote: Make the output independent of the order of opts and <remote>
--
2.34.1.391.g9ef3d6f133
next reply other threads:[~2022-01-14 4:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-14 4:24 Teng Long [this message]
2022-01-14 4:24 ` [RFC PATCH v1 1/1] ls-remote: Make the output independent of the order of opts and <remote> Teng Long
2022-01-14 5:47 ` [RFC PATCH v1 0/1] ls-remote: inconsistency from the order of args and opts Junio C Hamano
2022-01-14 6:27 ` Junio C Hamano
2022-01-14 6:42 ` Teng Long
2022-01-15 0:25 ` Junio C Hamano
2022-01-14 19:57 ` Ævar Arnfjörð Bjarmason
2022-01-14 20:42 ` Junio C Hamano
2022-01-14 20:57 ` Ævar Arnfjörð Bjarmason
2022-01-14 21:52 ` Junio C Hamano
2022-01-15 0:34 ` Ævar Arnfjörð Bjarmason
2022-01-15 1:01 ` Junio C Hamano
2022-01-14 21:12 ` brian m. carlson
2022-01-15 0:13 ` Ævar Arnfjörð Bjarmason
2022-01-15 0:50 ` Junio C Hamano
2022-01-15 1:02 ` Ævar Arnfjörð Bjarmason
2022-01-15 1:19 ` Junio C Hamano
2022-01-17 6:27 ` Teng Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1642129840.git.dyroneteng@gmail.com \
--to=dyroneteng@gmail.com \
--cc=git@vger.kernel.org \
--cc=tenglong.tl@alibaba-inc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).