git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-p4: Fixed handling of file names with spaces

From
PWPete Wyckoff <pw@padd.com>
Date
Jan 15, 2011, 14:35 UTC
Message-ID
<20110115143532.GB31622@arf.padd.com>
In-Reply-To
<A0F152FE-C659-4F9B-9625-505AA5DAF942@gmail.com>
jerzy.kozera@gmail.com wrote on Fri, 14 Jan 2011 22:45 +0000:
Show 10 quoted lines
> 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.
[..]
> -    p4_system("reopen -t %s %s" % (p4Type, file))
> +    p4_system("reopen -t %s \"%s\"" % (p4Type, file))

These changes are important for correctness. Thanks for fixing them.

It is kind of ugly to have to do file escaping all over the source. I'd rather see all the os.system() calls go away, in favor of subprocess.Popen(). You can use the latter without going through the shell at all, hence no escapes are needed. If you feel ambitious, this would be a nice fix.

Spaces can happen in depot paths too. That isn't handled current. All the p4Cmd and p4CmdList calls that work on depotPaths should avoid going through the shell too.

But at least what you have done already should go in. If you feel adventurous, addressing these other space-related issues would be nice too.

		-- Pete
Previous: Jerzy Kozera
Message 8 of 8 in “git-p4: Fix 'p4 opened' in git-p4 for names with spaces”
  1. git-p4: Fix 'p4 opened' in git-p4 for names with spacesJerzy Kozera, Dec 14, 2010
  2. git-p4: Fix 'p4 opened' in git-p4 for names with spacesJerzy Kozera, Dec 14, 2010
  3. Junio C HamanoDec 14, 2010
  4. Reece DunnDec 14, 2010
  5. git-p4: Fixed handling of file names with spacesJerzy Kozera, Jan 13, 2011
  6. Andreas SchwabJan 14, 2011
  7. Jerzy KozeraJan 14, 2011
  8. Pete WyckoffJan 15, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.