* [RFC/PATCH] interpolate '\n' as newline
@ 2007-07-06 20:02 Johannes Schindelin
2007-07-07 2:13 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Schindelin @ 2007-07-06 20:02 UTC (permalink / raw)
To: git, gitster
All places which call interpolate() get this interpolation for free.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
In the back of my head, I remembered that a few people
were interested in this.
Judging by the diffstat, it really escapes me why these people
did not implement it.
However, there is a chance that this change is not liked by
all places that call interpolate(). merge-recursive can live
with it, I guess. But daemon interpolates the path... However,
it seems only the command line of daemon can change the string,
so this change should be safe. There is only one other place in
git.git, the --pretty=format: stuff, and that is where the idea
was born first.
interpolate.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/interpolate.c b/interpolate.c
index 0082677..b322503 100644
--- a/interpolate.c
+++ b/interpolate.c
@@ -87,6 +87,12 @@ unsigned long interpolate(char *result, unsigned long reslen,
src += namelen;
continue;
}
+ } else if (c == '\\' && src[1] == 'n') {
+ if (newlen + 1 < reslen)
+ *dest++ = '\n';
+ src += 2;
+ newlen++;
+ continue;
}
/* Straight copy one non-interpolation character. */
if (newlen + 1 < reslen)
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [RFC/PATCH] interpolate '\n' as newline
2007-07-06 20:02 [RFC/PATCH] interpolate '\n' as newline Johannes Schindelin
@ 2007-07-07 2:13 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2007-07-07 2:13 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, gitster
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> All places which call interpolate() get this interpolation for free.
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
>
> ---
>
> In the back of my head, I remembered that a few people
> were interested in this.
>
> Judging by the diffstat, it really escapes me why these people
> did not implement it.
>
> However, there is a chance that this change is not liked by
> all places that call interpolate(). merge-recursive can live
> with it, I guess.
I actually think merge-recursive has much bigger chance of
getting broken than git-daemon, but only _if_ people are already
using custom merge programs this becomes an issue. It is much
more common to see two letter sequence '\n' as a string literal
in a script than in a pathname.
> But daemon interpolates the path... However,
> it seems only the command line of daemon can change the string,
> so this change should be safe.
The command line needs to say --interpolated-path="...\n..."
and expect that '\n' would come out as two characters backslash
and en in the _pathname_ to get broken, and it is very unlikely
that anybody is insane enough to have such a path.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-07-07 2:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-06 20:02 [RFC/PATCH] interpolate '\n' as newline Johannes Schindelin
2007-07-07 2:13 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox