From: Rogan Dawes <rogan@dawes.za.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH] Allow git-mergetool to handle paths with a leading space
Date: Mon, 07 Jan 2008 09:37:38 +0200 [thread overview]
Message-ID: <4781D6C2.9060305@dawes.za.net> (raw)
In-Reply-To: <7v3atb5g5o.fsf@gitster.siamese.dyndns.org>
[-- Attachment #1: Type: text/plain, Size: 2190 bytes --]
Signed-off-by: Rogan Dawes <rogan@dawes.za.net>
---
Junio C Hamano wrote:
> Rogan Dawes <rogan@dawes.za.net> writes:
>
>>>> I am working on a project which has the root directory constructed
>>>> with a leading space. i.e. ./ dir/. "read" skips the leading space
>>>> char, and ends up with an incorrect filename, which can then not be
>>>> found. Setting IFS=\n solves this problem.
>>> Does the project have a file that has letter 'n' (en) in its name?
>>> Have you tested your patch while having a conflict in that file?
>> Yes, it works correctly.
>
> I am curious and puzzled...
>
> $ echo 'ann1' | (IFS=\n read i; echo "<$i>")
> <ann1>
> $ echo 'ann1' | (IFS=\n read i j; echo "<$i>")
> <a>
> $ echo 'n1' | (IFS=\n read i j; echo "<$i>")
> <>
>
> Ok, "\n" is a funny way to say IFS does not matter as long as it
> is set to a non whitespace letter.
>
> It is VERY misleading as it looks as if the issue is fixed by
> setting IFS to a single LF alone (excluding SP and HT from the
> usual set), but that is not the patch is doing. It is setting
> it to a single 'n'.
Yes, you are right. Maybe setting IFS to the empty string is better?
$ printf " ann 1\n ann 2\n" | while IFS="" read i j k ; do echo "<$i>
<$j> <$k>"; done
< ann 1> <> <>
< ann 2> <> <>
$
Admittedly, there are still problems with my version, as you say,
backslashes and newlines will not be handled correctly. My Perl-fu is
weak, however, and my revised solution (IFS="") works for me :-)
Rogan
P.S. Quoting "$files" stops the spaces from being eaten in the preceding
echo line.
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 2f31fa2..facfbc8 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -393,8 +393,8 @@ if test $# -eq 0 ; then
echo "No files need merging"
exit 0
fi
- echo Merging the files: $files
- git ls-files -u | sed -e 's/^[^ ]* //' | sort -u | while read i
+ echo Merging the files: "$files"
+ git ls-files -u | sed -e 's/^[^ ]* //' | sort -u | while
IFS="" read i
do
printf "\n"
merge_file "$i" < /dev/tty > /dev/tty
[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 484 bytes --]
diff --git a/git-mergetool.sh b/git-mergetool.sh
index 2f31fa2..facfbc8 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -393,8 +393,8 @@ if test $# -eq 0 ; then
echo "No files need merging"
exit 0
fi
- echo Merging the files: $files
- git ls-files -u | sed -e 's/^[^ ]* //' | sort -u | while read i
+ echo Merging the files: "$files"
+ git ls-files -u | sed -e 's/^[^ ]* //' | sort -u | while IFS="" read i
do
printf "\n"
merge_file "$i" < /dev/tty > /dev/tty
next prev parent reply other threads:[~2008-01-07 7:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-06 9:25 [PATCH] Allow git-mergetool to handle paths with a leading space Rogan Dawes
2008-01-06 10:18 ` Junio C Hamano
2008-01-06 10:51 ` Rogan Dawes
2008-01-06 11:48 ` Junio C Hamano
2008-01-07 7:37 ` Rogan Dawes [this message]
2008-01-07 9:09 ` Junio C Hamano
2008-01-08 1:19 ` Theodore Tso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4781D6C2.9060305@dawes.za.net \
--to=rogan@dawes.za.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).