From: Michael Haggerty <mhagger@alum.mit.edu>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, cmn@elego.de,
A Large Angry SCM <gitzilla@gmail.com>
Subject: Re: [PATCH v2 0/7] Improved infrastructure for refname normalization
Date: Tue, 13 Sep 2011 06:16:13 +0200 [thread overview]
Message-ID: <4E6ED90D.1090704@alum.mit.edu> (raw)
In-Reply-To: <7vwrdd90df.fsf@alter.siamese.dyndns.org>
On 09/12/2011 06:44 PM, Junio C Hamano wrote:
> Michael Haggerty <mhagger@alum.mit.edu> writes:
>> OTOH I am again having serious doubts that trying to support
>> unnormalized refnames is a good idea.
>
> Sorry, I am confused. I thought the way you are planning forward is to
> leave unnormalized ones unchecked as the current code does (and mark the
> places that do so with _unsafe()), with the eventual goal of fixing the
> caller to pass only normalized ones to make call to the "safe" version?
That was the plan, but after my experience trying to fix this problem I
have come to doubt that it is doable within a reasonable amount of work
or even that support for unnormalized refnames is desirable. The
problem is that the API provided by refs.{c,h} is far from waterproof,
and I keep finding more code elsewhere that manipulates and parses
refnames and makes implicit assumptions (sometimes spread over many
functions) about their form.
Consistency of the UI should be the goal. Supporting unnormalized
refnames some places, but not others, will just confuse and frustrate
users. The only two consistent alternatives are
1. Unnormalized refnames are supported everywhere in the UI that
refnames are accepted, including clients like gitweb, gitk, egit, etc.
2. Only normalized refnames are supported; unnormalized refnames are
errors that we report on a best-effort basis.
Option (1) has a number of problems:
* Claiming to support unnormalized refnames is far from the current
situation; therefore lots of current code would have to be considered
broken.
* Fixing the code requires many new unit tests and fixes to many areas
of the code, including clients outside of the main git project. I have
tried fixing a couple of examples ("git branch", "git rev-parse", and
the first argument of "git update-ref") and it is pretty messy.
* Some of the needed changes seem like they might conflict with other
forms of DWIM; for example, the ambiguous_path() kludge.
* The extra copying needed for normalization has a runtime cost and
complicates memory management.
* Unnormalized refnames are *themselves* a form of UI inconsistency and
therefore not a very noble goal. It is better that people learn that
each reference has a single name, and unlearn that references were once
1:1 with files under .git/refs.
What is the benefit of (2) that justifies all of this work? To enable
sloppy script writers to throw slashes around carelessly?
Option (1) would be far easier. Then code only needs to treat
unnormalized refnames like any other kind of invalid refname rather than
making sure that unnormalized refnames work properly in combination with
all other features.
So I propose the following:
* Institute a policy that refnames in the UI must always be normalized
* On a best-effort basis, emit errors whenever unnormalized refnames are
encountered
* Continue to support "git check-ref-format --print", which script
writers can use to normalize refnames if they need to.
The only disadvantage of a stricter policy is that some of today's
sloppy scripts, which today might sometimes work (but not reliably),
break in a pretty obvious way that can be fixed with a single call to
"git check-ref-format --print".
I'd rather get beyond this swamp and start working on the hierarchical
reference cache, which will bring some real benefits. (The hierarchical
reference cache requires some sanity in refname handling, which is why I
got into this mess in the first place.)
What do people think?
Michael
--
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
next prev parent reply other threads:[~2011-09-13 4:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-10 6:50 [PATCH v2 0/7] Improved infrastructure for refname normalization Michael Haggerty
2011-09-10 6:50 ` [PATCH v2 1/7] t1402: add some more tests Michael Haggerty
2011-09-10 6:50 ` [PATCH v2 2/7] Change bad_ref_char() to return a boolean value Michael Haggerty
2011-09-10 6:50 ` [PATCH v2 3/7] git check-ref-format: add options --allow-onelevel and --refspec-pattern Michael Haggerty
2011-09-10 6:50 ` [PATCH v2 4/7] Change check_ref_format() to take a flags argument Michael Haggerty
2011-09-10 6:50 ` [PATCH v2 5/7] Add a library function normalize_refname() Michael Haggerty
2011-09-10 6:50 ` [PATCH v2 6/7] Do not allow ".lock" at the end of any refname component Michael Haggerty
2011-09-10 6:50 ` [PATCH v2 7/7] Add tools to avoid the use of unnormalized refnames Michael Haggerty
2011-09-12 4:28 ` [PATCH v2 0/7] Improved infrastructure for refname normalization Junio C Hamano
2011-09-12 15:11 ` Michael Haggerty
2011-09-12 16:44 ` Junio C Hamano
2011-09-13 4:16 ` Michael Haggerty [this message]
2011-09-13 17:43 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E6ED90D.1090704@alum.mit.edu \
--to=mhagger@alum.mit.edu \
--cc=cmn@elego.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=gitzilla@gmail.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.
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 NNTP newsgroup(s).