I am writing a front-end for git fast-import
. I have to use java (more specifically Java 7) as the system I am extracting from really only has a java api. I have everything working the way I think it should except when I pipe my stdout over to fast-import
I am getting this error:
fatal: Branch name doesn't conform to GIT standards: refs/heads/master
When I look at the line endings I see that there is a cr
lf
versus the lf
that should be there. I tried using a StringBuilder
to build an output string inserting \n
:
StringBuilder sb = new Stringbuilder("commit ref/heads/master\n");
that didnt work....
So thinking it was something with StringBuilder
I tried just writing to stdout
using print()
leaving the sepcified line endings as \n
.
System.out.print("commit refs/heads/master\n");
That did not seem to do the trick....
as a last ditch effort I tried:
System.setProperty("line.seperator","\n");
System.out.println("commit refs/heads/master");
that also failed failed...
So is there a way to write a simple lf
in place of the standard cr
lf
in in a windows console?
UPDATE:
System.out.print("some text\n")
still yields a cr
lf
.
for more reference here is the code snippet:
if(!isdevPath)
System.out.print("commit refs/heads/master\n");
else
System.out.print("commit refs/heads/devpath/" + devPathName + "\n");
System.out.print("mark " + rev.getRevision() + "\n");
System.out.print("committer " + rev.getAuthor() + " <> " + convertDate(rev.date) + "\n");
System.out.print(exportData(rev.getDescription()) + " \n" );
I ran this in powershell like this: Java -jar >> text.txt
and I am still getting the same error when I pipe to git fast-import
and here is a snap shot from notepad++ where you can see line endings
Solution
The answer to this is simply you can't do it in a windows based shell. If I run this through bash in a windows system it retains the line feeds from a print()
statement. So the answer is use print()
statements with a \n
where you want your line feeds. Then run the jar and pipe to git fast-import from bash.