Re: Filename quoting / parsing problem
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jan 6, 2010, 01:08 UTC
- Message-ID
- <7viqbgniq1.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <201001022148.47841.agruen@suse.de>
Andreas Gruenbacher <agruen@suse.de> writes:
> Right now, git generates lines like "diff --git a/f a/f b/f b/f" in some > corner cases, and from such lines alone, it is not possible to tell what the > two file names are (either "a/f a/f" and "b/f b/f", or "a/f a/f b/f" and > "b/f"). I can only find that out by looking at the other header lines.
I would understand "a/f a/f b/f a/f", which would be a diff of "f a/f" between two versions.
"a/f a/f b/f b/f" could be rename from "f /a/f" to "f b/f" (or "f a/f b/f" to "f"). But you will always get "rename from" and "rename to" in that case.
So you can (and I think git-apply does) follow this simple rule:
If you see +++/---/rename from/rename to/new file/deleted file, use
the names you find there. Otherwise, because there is no rename,
"diff --git" lines has two identical names that follow a/ and b/, so
use that name.The parsing code in builtin-apply.c is not so dense; you should be able to lift it from there, I think.
Although an output of "a/f a/f b/f b/f" without "rename from/to" is possible with --no-index of two unrelated files, --no-index output is not even something that is meant to be appliable, so I wouldn't worry too much about it.