Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public class GeneratePatchFile {
*/
private static final String PATCH_TXT = "patch.txt";

/**
* GIT_ADD_INTENT_TO_ADD_COMMAND.
*/
private static final String GIT_ADD_INTENT_TO_ADD_COMMAND = "git add -N .";

/**
* Git instance.
*/
Expand Down Expand Up @@ -261,6 +266,9 @@ private void generateTwoCommitDiffPatch(RevCommit commitOld,
final File destDirFile = createDestDirName(subDirName);
final boolean succ = destDirFile.mkdirs();
if (succ) {
checkout(commitNew.getName());
runShellCommand(GIT_ADD_INTENT_TO_ADD_COMMAND);

final File patchFile = new File(diffReportDirName, PATCH_TXT);
final PrintStream ps =
new PrintStream(new FileOutputStream(patchFile));
Expand All @@ -278,7 +286,6 @@ private void generateTwoCommitDiffPatch(RevCommit commitOld,
diffFormatter.format(entries);
diffFormatter.close();

checkout(commitNew.getName());
final File reportDir = generate();
Utils.copyDir(reportDir, destDirFile);

Expand Down Expand Up @@ -308,7 +315,8 @@ private void generateDiffPatchWithGitCommand(int headNum, String patchFormat)
runShellCommand("git show > show.patch");
}
else if ("diff".equals(patchFormat)) {
runShellCommand("git diff HEAD~1 HEAD > show.patch");
runShellCommand(GIT_ADD_INTENT_TO_ADD_COMMAND);
runShellCommand("git diff HEAD~0 > show.patch");
}
else if ("format".equals(patchFormat)) {
runShellCommand("git format-patch -1");
Expand Down
Loading