From: Robin Rosenberg Date: Tue, 7 Aug 2012 14:49:45 +0000 (+0200) Subject: Allow JGit to read C Git rebase state X-Git-Tag: v2.1.0.201209190230-r~36^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fchanges%2F18%2F7118%2F2;p=jgit.git Allow JGit to read C Git rebase state C Git prefixes the time stamp in the author script with a "@" Change-Id: I140b29519acc101da78296eef562368fc6b61135 --- diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java index 4a7a45e8f7..edb36b81fe 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/RebaseCommandTest.java @@ -975,7 +975,7 @@ public class RebaseCommandTest extends RepositoryTestCase { String[] lines = convertedAuthor.split("\n"); assertEquals("GIT_AUTHOR_NAME='Author name'", lines[0]); assertEquals("GIT_AUTHOR_EMAIL='a.mail@some.com'", lines[1]); - assertEquals("GIT_AUTHOR_DATE='123456789 -0100'", lines[2]); + assertEquals("GIT_AUTHOR_DATE='@123456789 -0100'", lines[2]); PersonIdent parsedIdent = git.rebase().parseAuthor( convertedAuthor.getBytes("UTF-8")); @@ -992,7 +992,7 @@ public class RebaseCommandTest extends RepositoryTestCase { lines = convertedAuthor.split("\n"); assertEquals("GIT_AUTHOR_NAME='Author name'", lines[0]); assertEquals("GIT_AUTHOR_EMAIL='a.mail@some.com'", lines[1]); - assertEquals("GIT_AUTHOR_DATE='123456789 +0930'", lines[2]); + assertEquals("GIT_AUTHOR_DATE='@123456789 +0930'", lines[2]); parsedIdent = git.rebase().parseAuthor( convertedAuthor.getBytes("UTF-8")); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java index 6f0c3eb0f4..9f8aa7bfb2 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java @@ -439,6 +439,7 @@ public class RebaseCommand extends GitCommand { // representation for date and timezone sb.append(GIT_AUTHOR_DATE); sb.append("='"); + sb.append("@"); // @ for time in seconds since 1970 String externalString = author.toExternalString(); sb .append(externalString.substring(externalString @@ -1013,7 +1014,13 @@ public class RebaseCommand extends GitCommand { String time = keyValueMap.get(GIT_AUTHOR_DATE); // the time is saved as - long when = Long.parseLong(time.substring(0, time.indexOf(' '))) * 1000; + int timeStart = 0; + if (time.startsWith("@")) + timeStart = 1; + else + timeStart = 0; + long when = Long + .parseLong(time.substring(timeStart, time.indexOf(' '))) * 1000; String tzOffsetString = time.substring(time.indexOf(' ') + 1); int multiplier = -1; if (tzOffsetString.charAt(0) == '+')