2

I am using git svn to access a SVN server. I am trying to write a script that converts and copy all SVN tags into git tags.

I found this: http://gitready.com/advanced/2009/02/16/convert-git-svn-tag-branches-to-real-tags.html

And this: https://stackoverflow.com/a/3357357/882697

To create that:

git for-each-ref refs/remotes/origin/tags | cut -d / -f 5- |
while read ref
do
    msg=`git log --format=%B -n 1 origin/tags/"$ref"`
    echo $msg
done

The git log command works well in the mingw bash (from git install). But when launching the script from the same mingw bash, the line endings are stripped. I tried to added \r:

msg=`echo $msg | sed 's/\n/\r\n/'`

But it doesn't work either...

Could someone help me please? Thanks!

Community
  • 1
  • 1
Plouff
  • 3,290
  • 2
  • 27
  • 45

1 Answers1

1

Try at least putting double-quotes:

echo "${msg}"

(see "how do I preserve newlines in a quoted string in bash?")

That will avoid echo interpreting the output of $msg content (doing field splitting or pathname expansion).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you so much for your answer and for the useful links. Not only did I learn a trickery about bash but now I also have http://www.shellcheck.net/ in my bookmarks! Thanks again! – Plouff Mar 18 '16 at 12:55
  • 1
    @Plouff you are most welcome! Regarding spellcheck, here this is about https://github.com/koalaman/shellcheck/wiki/SC2086. – VonC Mar 18 '16 at 13:00
  • I haven't noticed that the output of spellcheck provides links to the documentation. Thanks again for this hint :)! – Plouff Mar 18 '16 at 13:15