Re: [PATCH] git-p4: Fixed handling of file names with spaces
- From
Jerzy Kozera <jerzy.kozera@gmail.com>
- Date
- Jan 14, 2011, 22:45 UTC
- Message-ID
- <A0F152FE-C659-4F9B-9625-505AA5DAF942@gmail.com>
- In-Reply-To
- <m28vyncffu.fsf@igel.home>
On 14 Jan 2011, at 22:01, Andreas Schwab wrote:
> Can those file names also include a double quote or a backquote or a > dollar sign?
Double quote and backquote get escaped by git so they are not a problem: $ git diff-tree -r HEAD^ HEAD :000000 100644 0000000000000000000000000000000000000000 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 A "\" \\ $"
But as you can see above, the dollar sign remains intact, so it needs to be handled as well - patch below takes it into account.
Thanks, Jerzy
--- contrib/fast-import/git-p4 | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 index 04ce7e3..d930908 100755 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@ -47,7 +47,7 @@ def p4_build_cmd(cmd): real_cmd += "%s" % (cmd) if verbose: print real_cmd - return real_cmd + return real_cmd.replace('$', '\\$') def chdir(dir): if os.name == 'nt': @@ -139,12 +139,12 @@ def setP4ExecBit(file, mode): if p4Type[-1] == "+": p4Type = p4Type[0:-1] - p4_system("reopen -t %s %s" % (p4Type, file)) + p4_system("reopen -t %s \"%s\"" % (p4Type, file)) def getP4OpenedType(file): # Returns the perforce file type for the given file. - result = p4_read_pipe("opened %s" % file) + result = p4_read_pipe("opened \"%s\"" % file) match = re.match(".*\((.+)\)\r?$", result) if match: return match.group(1) @@ -666,7 +666,7 @@ class P4Submit(Command): for f in editedFiles: p4_system("revert \"%s\"" % f); for f in filesToAdd: - system("rm %s" %f) + system("rm \"%s\"" % f.replace('$', '\\$')) return elif response == "a": os.system(applyPatchCmd)
-- 1.7.1