From: Robert Fitzsimons <robfitz@273k.net>
To: Junio C Hamano <junkio@cox.net>
Cc: Alex Riesen <raa.lkml@gmail.com>,
git@vger.kernel.org, Kai Ruemmler <kai.ruemmler@gmx.net>
Subject: [PATCH] Try URI quoting for embedded TAB and LF in pathnames
Date: Sat, 8 Oct 2005 13:30:32 +0000 [thread overview]
Message-ID: <20051008133032.GA32079@localhost> (raw)
In-Reply-To: <7vachks7aq.fsf@assigned-by-dhcp.cox.net>
Instead of using //{LF}// and //{TAG}// to quote embedded tab and
linefeed characters in pathnames use URI quoting.
'\t' becomes %09
'\n' becomes %10
'%' becomes %25
Signed-off-by: Robert Fitzsimons <robfitz@273k.net>
---
> I am not married to this quoting syntax -- I think it *is* ugly,
> but as I said before, I'd prefer to have something ugly here.
>
> I would easily be persuaded otherwise, though. A working patch
> would probably be the most effective way of persuasion, but a
> mock output without the code to produce and/or parse it would
> also be fine as a starting point for discussion.
Using URI encoding might be an option it's not a ugly and more peopel
should under stand what it means. Heres a posible patch against pu.
Robert
apply.c | 19 ++++++++++++-------
diff.c | 26 +++++++++++++++++---------
git-status.sh | 10 ++++++----
3 files changed, 35 insertions(+), 20 deletions(-)
applies-to: a9332b0c2bd80a182f946d22d4ec7511c32c55f4
8029a957cab1a912562696fdce8beea5fc2c11c4
diff --git a/apply.c b/apply.c
--- a/apply.c
+++ b/apply.c
@@ -75,21 +75,26 @@ static char *unmunge_name(char *name)
if (!name)
return name;
- cp = strstr(name, "//");
+ cp = strstr(name, "%");
if (!cp)
return name;
ret_name = strdup(name);
for (cp = dp = ret_name; (ch = *cp); cp++) {
- if (ch == '/' && cp[1] == '/' && cp[2] == '{') {
- /* //{TAB}// or //{LF}// */
- if (!strncmp(cp + 3, "TAB}//", 6)) {
+ if (ch == '%') {
+ /* %09 or %10 or %25 */
+ if (!strncmp(cp + 1, "09", 2)) {
*dp++ = '\t';
- cp += 8;
+ cp += 2;
continue;
}
- else if (!strncmp(cp + 3, "LF}//", 5)) {
+ else if (!strncmp(cp + 1, "10", 2)) {
*dp++ = '\n';
- cp += 7;
+ cp += 2;
+ continue;
+ }
+ else if (!strncmp(cp + 1, "25", 2)) {
+ *dp++ = '%';
+ cp += 2;
continue;
}
error("malformed munged name '%s' (looking at %s)",
diff --git a/diff.c b/diff.c
--- a/diff.c
+++ b/diff.c
@@ -13,7 +13,7 @@ static const char *path_munge(const char
{
const char *cp;
char *retpath, *dp;
- int ch, munge_inter_name = 0, munge_line_term = 0;
+ int ch, munge_inter_name = 0, munge_line_term = 0, munge_quote = 0;
if (!path)
return path;
@@ -23,23 +23,31 @@ static const char *path_munge(const char
munge_inter_name++;
if (line_term && ch == '\n')
munge_line_term++;
+ if (ch == '%')
+ munge_quote++;
}
- if (!(munge_inter_name + munge_line_term))
+ if (!(munge_inter_name + munge_line_term + munge_quote))
return path;
- /* need //{TAB}// and //{LF}// */
+ /* need %09 and %10 and %25 */
retpath = xmalloc(cp - path +
- munge_inter_name * 8 +
- munge_line_term * 7 + 1);
+ munge_inter_name * 3 +
+ munge_line_term * 3 +
+ munge_quote * 3 + 1);
for (cp = path, dp = retpath; (ch = *cp); cp++, dp++) {
if (inter_name && ch == '\t') {
- memcpy(dp, "//{TAB}//", 9);
- dp += 8;
+ memcpy(dp, "%09", 3);
+ dp += 2;
continue;
}
if (line_term && ch == '\n') {
- memcpy(dp, "//{LF}//", 8);
- dp += 7;
+ memcpy(dp, "%10", 3);
+ dp += 2;
+ continue;
+ }
+ if (ch == '%') {
+ memcpy(dp, "%25", 3);
+ dp += 2;
continue;
}
*dp = ch;
diff --git a/git-status.sh b/git-status.sh
--- a/git-status.sh
+++ b/git-status.sh
@@ -54,8 +54,9 @@ else
perl -e '$/ = "\0";
while (<>) {
chomp;
- s|\t|//{TAB}//|g;
- s|\n|//{LF}//|g;
+ s|%([^021][^059])|%25\1|g;
+ s|\t|%09|g;
+ s|\n|%10|g;
s/ /\\ /g;
s/^/A /;
print "$_\n";
@@ -84,8 +85,9 @@ perl -e '$/ = "\0";
my $shown = 0;
while (<>) {
chomp;
- s|\t|//{TAB}//|g;
- s|\n|//{LF}//|g;
+ s|%([^01][^09])|%25\1|g;
+ s|\t|%09|g;
+ s|\n|%10|g;
s/^/# /;
if (!$shown) {
print "#\n# Ignored files:\n";
---
0.99.8.GIT
next prev parent reply other threads:[~2005-10-08 13:21 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-07 19:35 [RFC] embedded TAB and LF in pathnames Junio C Hamano
2005-10-07 23:29 ` Alex Riesen
2005-10-07 23:44 ` Junio C Hamano
2005-10-08 6:45 ` Alex Riesen
2005-10-08 9:10 ` Junio C Hamano
2005-10-08 13:30 ` Robert Fitzsimons [this message]
2005-10-08 18:30 ` [PATCH] Try URI quoting for " Junio C Hamano
2005-10-08 20:19 ` Junio C Hamano
2005-10-11 6:20 ` Paul Eggert
2005-10-11 7:37 ` Junio C Hamano
2005-10-11 15:17 ` Linus Torvalds
2005-10-11 18:03 ` Paul Eggert
2005-10-11 18:37 ` Linus Torvalds
2005-10-11 19:42 ` Paul Eggert
2005-10-11 20:56 ` Linus Torvalds
2005-10-12 6:51 ` Paul Eggert
2005-10-12 14:59 ` Linus Torvalds
2005-10-12 19:07 ` Daniel Barkalow
2005-10-12 19:52 ` Linus Torvalds
2005-10-12 20:21 ` H. Peter Anvin
[not found] ` <87vf02qy79.fsf@penguin.cs.ucla.edu>
2005-10-12 21:02 ` Junio C Hamano
2005-10-12 21:05 ` Linus Torvalds
2005-10-12 21:09 ` H. Peter Anvin
2005-10-12 21:15 ` Johannes Schindelin
2005-10-12 21:33 ` Junio C Hamano
2005-10-14 0:57 ` Paul Eggert
2005-10-14 5:43 ` Linus Torvalds
2005-10-12 21:24 ` Linus Torvalds
2005-10-14 0:16 ` Paul Eggert
2005-10-14 5:20 ` Linus Torvalds
2005-10-14 17:18 ` H. Peter Anvin
2005-10-14 6:59 ` Junio C Hamano
2005-10-09 10:42 ` 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=20051008133032.GA32079@localhost \
--to=robfitz@273k.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=kai.ruemmler@gmx.net \
--cc=raa.lkml@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).