Buggy code:
public class GitSiteWagon extends AbstractWagon { private ScmManager scmManager ; private String siteBranch ; private File checkoutDirectory ; public ScmManager getScmManager ( ) { } public void setScmManager ( ScmManager scmManager ) { } public String getSiteBranch ( ) { } public void setSiteBranch ( String siteBranch ) { } public File getCheckoutDirectory ( ) { } public void setCheckoutDirectory ( File checkoutDirectory ) { } public ScmProvider getScmProvider ( String scmType ) throws NoSuchScmProviderException { } public void openConnectionInternal ( ) throws ConnectionException { } private File createCheckoutDirectory ( ) { } private void removeCheckoutDirectory ( ) throws ConnectionException { } private ScmRepository getScmRepository ( String url ) throws NoSuchScmProviderException , ScmRepositoryException { } private void checkIn ( ScmProvider scmProvider , ScmRepository scmRepository , String msg ) throws ScmException { } private String checkOut ( ScmProvider scmProvider , ScmRepository scmRepository , String targetName , Resource resource ) throws TransferFailedException { } private int addFiles ( ScmProvider scmProvider , ScmRepository scmRepository , File basedir , String scmFilePath ) throws ScmException { } public boolean supportsDirectoryCopy ( ) { } public void connect ( Repository repository , AuthenticationInfo authenticationInfo , ProxyInfoProvider proxyInfoProvider ) throws ConnectionException , AuthenticationException { } public void put ( File source , String destination ) throws TransferFailedException { } public void putDirectory ( File sourceDirectory , String destinationDirectory ) throws ResourceDoesNotExistException , TransferFailedException , AuthorizationException { } private void putResource ( File sourceDirectory , String destinationDirectory ) throws TransferFailedException { Resource target = new Resource ( destinationDirectory ) ; firePutInitiated ( target , sourceDirectory ) ; try { ScmRepository scmRepository = getScmRepository ( getRepository ( ) . getUrl ( ) ) ; target . setContentLength ( sourceDirectory . length ( ) ) ; target . setLastModified ( sourceDirectory . lastModified ( ) ) ; firePutStarted ( target , sourceDirectory ) ; String msg = ( "Wagon:<seq2seq4repair_space>Deploying<seq2seq4repair_space>" + ( sourceDirectory . getName ( ) ) ) + "<seq2seq4repair_space>to<seq2seq4repair_space>repository" ; ScmProvider scmProvider = getScmProvider ( scmRepository . getProvider ( ) ) ; String checkoutTargetName = ( sourceDirectory . isDirectory ( ) ) ? destinationDirectory : getDirname ( destinationDirectory ) ; String relPath = checkOut ( scmProvider , scmRepository , checkoutTargetName , target ) ; File newCheckoutDirectory = new File ( checkoutDirectory , relPath ) ; File scmFile = new File ( newCheckoutDirectory , ( sourceDirectory . isDirectory ( ) ? "" : getFilename ( destinationDirectory ) ) ) ; boolean fileAlreadyInScm = scmFile . exists ( ) ; if ( ! ( scmFile . equals ( sourceDirectory ) ) ) { if ( sourceDirectory . isDirectory ( ) ) { FileUtils . copyDirectoryStructure ( sourceDirectory , scmFile ) ; } else { FileUtils . copyFile ( sourceDirectory , scmFile ) ; } } if ( ( ! fileAlreadyInScm ) || ( scmFile . isDirectory ( ) ) ) { int addedFiles = addFiles ( scmProvider , scmRepository , newCheckoutDirectory , ( sourceDirectory . isDirectory ( ) ? "" : scmFile . getName ( ) ) ) ; <START_BUG> if ( ( ! fileAlreadyInScm ) && ( addedFiles == 0 ) ) { <END_BUG> throw new ScmException ( ( ( "Unable<seq2seq4repair_space>to<seq2seq4repair_space>add<seq2seq4repair_space>file<seq2seq4repair_space>to<seq2seq4repair_space>SCM:<seq2seq4repair_space>" + scmFile ) + ";<seq2seq4repair_space>see<seq2seq4repair_space>error<seq2seq4repair_space>messages<seq2seq4repair_space>above<seq2seq4repair_space>for<seq2seq4repair_space>more<seq2seq4repair_space>information" ) ) ; } } checkIn ( scmProvider , scmRepository , msg ) ; } catch ( ScmException e ) { e . printStackTrace ( ) ; fireTransferError ( target , e , REQUEST_GET ) ; System . exit ( 1 ) ; throw new TransferFailedException ( ( "Error<seq2seq4repair_space>interacting<seq2seq4repair_space>with<seq2seq4repair_space>SCM:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) , e ) ; } catch ( IOException e ) { fireTransferError ( target , e , REQUEST_GET ) ; throw new TransferFailedException ( ( "Error<seq2seq4repair_space>interacting<seq2seq4repair_space>with<seq2seq4repair_space>SCM:<seq2seq4repair_space>" + ( e . getMessage ( ) ) ) , e ) ; } if ( sourceDirectory . isFile ( ) ) { postProcessListeners ( target , sourceDirectory , REQUEST_PUT ) ; } firePutCompleted ( target , sourceDirectory ) ; } private void checkScmResult ( ScmResult result ) throws ScmException { } public void closeConnection ( ) throws ConnectionException { } public boolean getIfNewer ( String resourceName , File destination , long timestamp ) throws ResourceDoesNotExistException , TransferFailedException , AuthorizationException { } public void get ( String resourceName , File destination ) throws ResourceDoesNotExistException , TransferFailedException , AuthorizationException { } public List < String > getFileList ( String resourcePath ) throws ResourceDoesNotExistException , TransferFailedException , AuthorizationException { } @ SuppressWarnings ( "unchecked" ) private List < ScmFile > getListScmResultFiles ( ListScmResult result ) { } public boolean resourceExists ( String resourceName ) throws TransferFailedException , AuthorizationException { } private String getFilename ( String filename ) { } private String getDirname ( String filename ) { } protected ScmResult executeCommand ( GitExeScmProvider scmProvider , GitCommand command , ScmProviderRepository repository , ScmFileSet fileSet , CommandParameters parameters ) throws ScmException { } }

Fix:
if ( ! fileAlreadyInScm ) {