All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: git@vger.kernel.org
Subject: Re: [JGIT PATCH 4/6] Add QuotedString class to handle C-style quoting rules
Date: Thu, 11 Dec 2008 00:22:03 +0100	[thread overview]
Message-ID: <200812110022.03719.robin.rosenberg@dewire.com> (raw)
In-Reply-To: <1228946751-12708-5-git-send-email-spearce@spearce.org>

onsdag 10 december 2008 23:05:49 skrev Shawn O. Pearce:
> Git patch files can contain file names which are quoted using the
> C language quoting rules.  In order to correctly create or parse

Should we maybe call this Git-style since we really do not care
about C (which version btw?).

> QuotedString itself is an abstract API so callers can be passed a
> quoting style based on the context of where their output will be
> used, and multiple styles could be supported.  This may be useful
> if jgit ever grows a "git for-each-ref" style of output where Perl,
> Python, Tcl and Bourne style quoting might be necessary.
> 
> References through the singleton QuotedString.C should be able to
> bypass the virtual function table, as the specific type is mentioned
> in the field declaration and that type is final.  A good JIT should
> be able to remove the abstraction costs when the caller has hardcoded
> the quoting style.
Making two interfaces is better. We may share the implementation initially,
but parsing file names in Git patches and parsing C strings are different
operations.

> +	public void testQuote_OctalAll() {
> +		assertQuote("\1", "\\001");
> +		assertQuote("~", "\\176");
> +		assertQuote("\u00ff", "\\303\\277"); // \u00ff in UTF-8
> +	}
What do we do with non-UTF8 names? I think we should
follow the logic we use when parsing commits and paths
in other places.
> +
> +	public void testDequote_UnknownEscapeQ() {
> +		assertDequote("\\q", "\\q");
> +	}
Would Git generate this style in a name? 

> +			quote[' '] = 0;
> +			quote['+'] = 0;
> +			quote[','] = 0;
> +			quote['-'] = 0;
> +			quote['.'] = 0;
> +			quote['/'] = 0;
> +			quote['='] = 0;
> +			quote['_'] = 0;
> +			quote['^'] = 0;
> +
> +			quote['\u0007'] = 'a';
> +			quote['\b'] = 'b';
\e = esc

> +				default:
> +					// Any other code is taken literally.
> +					//
> +					r[rPtr++] = '\\';
> +					r[rPtr++] = in[inPtr - 1];
> +					continue;
> +				}
> +			}
> +
> +			return decode(Constants.CHARSET, r, 0, rPtr);

Importing methods really obscures things. Please qualify with class name
of RawparseUtils here instead. 

-- robin

  parent reply	other threads:[~2008-12-10 23:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-10 22:05 [JGIT PATCH 0/6] RawParseUtil improvements Shawn O. Pearce
2008-12-10 22:05 ` [JGIT PATCH 1/6] Simplify RawParseUtils.nextLF invocations Shawn O. Pearce
2008-12-10 22:05   ` [JGIT PATCH 2/6] Simplify RawParseUtils next and nextLF loops Shawn O. Pearce
2008-12-10 22:05     ` [JGIT PATCH 3/6] Correct Javadoc of RawParseUtils next and nextLF methods Shawn O. Pearce
2008-12-10 22:05       ` [JGIT PATCH 4/6] Add QuotedString class to handle C-style quoting rules Shawn O. Pearce
2008-12-10 22:05         ` [JGIT PATCH 5/6] Add Bourne style quoting for TransportGitSsh Shawn O. Pearce
2008-12-10 22:05           ` [JGIT PATCH 6/6] Add ~user friendly " Shawn O. Pearce
2008-12-10 23:22         ` Robin Rosenberg [this message]
2008-12-10 23:41           ` [JGIT PATCH 4/6] Add QuotedString class to handle C-style quoting rules Shawn O. Pearce
2008-12-11  0:33             ` Robin Rosenberg
2008-12-11  0:57               ` [JGIT PATCH 4/6 v3] Add QuotedString class to handle Git path style " Shawn O. Pearce

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=200812110022.03719.robin.rosenberg@dewire.com \
    --to=robin.rosenberg@dewire.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.