@ -64,16 +64,15 @@ import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.diff.RawText ;
import org.eclipse.jgit.diff.RawText ;
import org.eclipse.jgit.diff.RawTextComparator ;
import org.eclipse.jgit.diff.RawTextComparator ;
import org.eclipse.jgit.diff.RenameDetector ;
import org.eclipse.jgit.diff.RenameDetector ;
import org.eclipse.jgit.errors.LargeObjectException ;
import org.eclipse.jgit.lib.AnyObjectId ;
import org.eclipse.jgit.lib.AnyObjectId ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.Constants ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectId ;
import org.eclipse.jgit.lib.ObjectReader ;
import org.eclipse.jgit.lib.PersonIdent ;
import org.eclipse.jgit.lib.PersonIdent ;
import org.eclipse.jgit.lib.Ref ;
import org.eclipse.jgit.lib.Ref ;
import org.eclipse.jgit.notes.NoteMap ;
import org.eclipse.jgit.notes.NoteMap ;
import org.eclipse.jgit.revwalk.RevCommit ;
import org.eclipse.jgit.revwalk.RevCommit ;
import org.eclipse.jgit.revwalk.RevTree ;
import org.eclipse.jgit.revwalk.RevTree ;
import org.eclipse.jgit.revwalk.RevWalk ;
import org.kohsuke.args4j.Option ;
import org.kohsuke.args4j.Option ;
@Command ( common = true , usage = "usage_viewCommitHistory" )
@Command ( common = true , usage = "usage_viewCommitHistory" )
@ -89,10 +88,6 @@ class Log extends RevWalkTextBuiltin {
private Map < String , NoteMap > noteMaps ;
private Map < String , NoteMap > noteMaps ;
private ObjectReader reader ;
private RevWalk revWalk ;
@Option ( name = "--decorate" , usage = "usage_showRefNamesMatchingCommits" )
@Option ( name = "--decorate" , usage = "usage_showRefNamesMatchingCommits" )
private boolean decorate ;
private boolean decorate ;
@ -182,14 +177,6 @@ class Log extends RevWalkTextBuiltin {
fmt = new SimpleDateFormat ( "EEE MMM dd HH:mm:ss yyyy ZZZZZ" , Locale . US ) ;
fmt = new SimpleDateFormat ( "EEE MMM dd HH:mm:ss yyyy ZZZZZ" , Locale . US ) ;
}
}
@Override
protected RevWalk createWalk ( ) {
RevWalk ret = super . createWalk ( ) ;
if ( decorate )
allRefsByPeeledObjectId = getRepository ( ) . getAllRefsByPeeledObjectId ( ) ;
return ret ;
}
@Override
@Override
protected void run ( ) throws Exception {
protected void run ( ) throws Exception {
diffFmt . setRepository ( db ) ;
diffFmt . setRepository ( db ) ;
@ -202,40 +189,39 @@ class Log extends RevWalkTextBuiltin {
rd . setRenameLimit ( renameLimit . intValue ( ) ) ;
rd . setRenameLimit ( renameLimit . intValue ( ) ) ;
}
}
if ( ! noStandardNotes | | additionalNoteRefs ! = null ) {
if ( ! noStandardNotes | | ! additionalNoteRefs . isEmpty ( ) ) {
reader = db . newObjectReader ( ) ;
createWalk ( ) ;
revWalk = new RevWalk ( db ) ;
noteMaps = new LinkedHashMap < String , NoteMap > ( ) ;
noteMaps = new LinkedHashMap < String , NoteMap > ( ) ;
if ( ! noStandardNotes ) {
if ( ! noStandardNotes ) {
noteMaps . put ( Constants . R_NOTES_COMMITS ,
addNoteMap ( Constants . R_NOTES_COMMITS ) ;
getNoteMap ( Constants . R_NOTES_COMMITS ) ) ;
}
}
if ( additionalNoteRefs ! = null ) {
if ( ! additionalNoteRefs . isEmpty ( ) ) {
for ( String notesRef : additionalNoteRefs ) {
for ( String notesRef : additionalNoteRefs ) {
if ( ! notesRef . startsWith ( Constants . R_NOTES ) ) {
if ( ! notesRef . startsWith ( Constants . R_NOTES ) ) {
notesRef = Constants . R_NOTES + notesRef ;
notesRef = Constants . R_NOTES + notesRef ;
}
}
noteMaps . put ( notesRef , get NoteMap( notesRef ) ) ;
add NoteMap( notesRef ) ;
}
}
}
}
}
}
if ( decorate )
allRefsByPeeledObjectId = getRepository ( )
. getAllRefsByPeeledObjectId ( ) ;
super . run ( ) ;
super . run ( ) ;
} finally {
} finally {
diffFmt . release ( ) ;
diffFmt . release ( ) ;
if ( reader ! = null )
reader . release ( ) ;
if ( revWalk ! = null )
revWalk . release ( ) ;
}
}
}
}
private NoteMap get NoteMap( String notesRef ) throws IOException {
private void addNoteMap ( String notesRef ) throws IOException {
Ref notes = db . getRef ( notesRef ) ;
Ref notes = db . getRef ( notesRef ) ;
if ( notes = = null )
if ( notes = = null )
return null ;
return ;
RevCommit notesCommit = revWalk . parseCommit ( notes . getObjectId ( ) ) ;
RevCommit notesCommit = argWalk . parseCommit ( notes . getObjectId ( ) ) ;
return NoteMap . read ( reader , notesCommit ) ;
noteMaps . put ( notesRef ,
NoteMap . read ( argWalk . getObjectReader ( ) , notesCommit ) ) ;
}
}
@Override
@Override
@ -304,7 +290,7 @@ class Log extends RevWalkTextBuiltin {
}
}
boolean printedNote = showNotes ( c , e . getValue ( ) , label ,
boolean printedNote = showNotes ( c , e . getValue ( ) , label ,
printEmptyLine ) ;
printEmptyLine ) ;
atLeastOnePrinted = atLeastOnePrinted | | printedNote ;
atLeastOnePrinted | = printedNote ;
printEmptyLine = printedNote ;
printEmptyLine = printedNote ;
}
}
return atLeastOnePrinted ;
return atLeastOnePrinted ;
@ -334,12 +320,16 @@ class Log extends RevWalkTextBuiltin {
out . print ( ")" ) ;
out . print ( ")" ) ;
}
}
out . println ( ":" ) ;
out . println ( ":" ) ;
RawText rawText = new RawText ( reader . open ( blobId ) . getBytes ( ) ) ;
try {
String s = rawText . getString ( 0 , rawText . size ( ) , false ) ;
RawText rawText = new RawText ( argWalk . getObjectReader ( )
final String [ ] lines = s . split ( "\n" ) ;
. open ( blobId ) . getCachedBytes ( Integer . MAX_VALUE ) ) ;
for ( final String l : lines ) {
for ( int i = 0 ; i < rawText . size ( ) ; i + + ) {
out . print ( " " ) ;
out . print ( " " ) ;
out . println ( l ) ;
out . println ( rawText . getString ( i ) ) ;
}
} catch ( LargeObjectException e ) {
out . println ( MessageFormat . format (
CLIText . get ( ) . noteObjectTooLargeToPrint , blobId . name ( ) ) ) ;
}
}
return true ;
return true ;
}
}