Re: [JGIT PATCH 4/6] Add QuotedString class to handle C-style quoting rules

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux