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

Re: [PATCH] Allow git-mergetool to handle paths with a leading space

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 7, 2008, 09:09 UTC
Message-ID
<7v8x320zom.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<4781D6C2.9060305@dawes.za.net>
Rogan Dawes <rogan@dawes.za.net> writes:
> Yes, you are right. Maybe setting IFS to the empty string is better?

Yes. POSIX XCU "2.6.5 Field Splitting" is quite clear about this. Empty IFS tells read not to split the fields, and such an IFS does not have IFS white space in it so the SP at the beginning of the input will not be stripped.

My limited test indicates that bash, dash and ksh do behave as specified, so I think it is a reasonably safe thing to do. Although I usually would say "I do not care about Solaris default /bin/sh", I know even that shell at least gets this right.

I think the patch is Ok as long as the user does not care any character outside the portable filename character set (POSIX XBD 3.276) other than SP. Because the rest of the mergetool is written in such a way that it does not handle many characters outside the portable filename character set well anyway, I think the filename limitation that still remains after your patch may be acceptable.

I did not however apply your patch to my tree tonight, as Ted as the original and the primary author of the script may have better ideas, and/or future directions for the patch. He can simply just Ack your patch if he chooses to.

I'd however write that overly long pipeline indented a bit more sanely, like this, though:

	git ls-files -u |
        sed -e 's/^[^	]*	//' |
        sort -u |
        while IFS="" read i
	do
        	printf "\n"
                merge_file "$i" </dev/tty >/dev/tty
                ...

In the longer term, I'd probably suggest redoing the entire command in a NUL safe scripting language (or even C, especially if pressed by mingw or msys folks) to eliminate the issue altogether, though. But that would definitely be a post 1.5.4 item.

[Reference]
http://www.opengroup.org/onlinepubs/000095399/toc.htm
Previous: Rogan DawesNext: Theodore Tso
Message 6 of 7 in “Allow git-mergetool to handle paths with a leading space”
  1. Allow git-mergetool to handle paths with a leading spaceRogan Dawes, Jan 6, 2008
  2. Junio C HamanoJan 6, 2008
  3. Rogan DawesJan 6, 2008
  4. Junio C HamanoJan 6, 2008
  5. Allow git-mergetool to handle paths with a leading spaceRogan Dawes, Jan 7, 2008
  6. Junio C HamanoJan 7, 2008
  7. Theodore TsoJan 8, 2008

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.