@ -113,6 +113,7 @@ public class RepoCommand extends GitCommand<RevCommit> {
private String targetBranch = Constants . HEAD ;
private String targetBranch = Constants . HEAD ;
private boolean recordRemoteBranch = false ;
private boolean recordRemoteBranch = false ;
private boolean recordSubmoduleLabels = false ;
private boolean recordSubmoduleLabels = false ;
private boolean recordShallowSubmodules = false ;
private PersonIdent author ;
private PersonIdent author ;
private RemoteReader callback ;
private RemoteReader callback ;
private InputStream inputStream ;
private InputStream inputStream ;
@ -362,6 +363,21 @@ public class RepoCommand extends GitCommand<RevCommit> {
return this ;
return this ;
}
}
/ * *
* Set whether the clone - depth field should be recorded as a shallow
* recommendation in . gitmodules .
* < p >
* Not implemented for non - bare repositories .
*
* @param enable Whether to record the shallow recommendation .
* @return this command
* @since 4 . 4
* /
public RepoCommand setRecommendShallow ( boolean enable ) {
this . recordShallowSubmodules = enable ;
return this ;
}
/ * *
/ * *
* The progress monitor associated with the clone operation . By default ,
* The progress monitor associated with the clone operation . By default ,
* this is set to < code > NullProgressMonitor < / code >
* this is set to < code > NullProgressMonitor < / code >
@ -471,7 +487,8 @@ public class RepoCommand extends GitCommand<RevCommit> {
proj . getPath ( ) ,
proj . getPath ( ) ,
proj . getRevision ( ) ,
proj . getRevision ( ) ,
proj . getCopyFiles ( ) ,
proj . getCopyFiles ( ) ,
proj . getGroups ( ) ) ;
proj . getGroups ( ) ,
proj . getRecommendShallow ( ) ) ;
}
}
} catch ( GitAPIException | IOException e ) {
} catch ( GitAPIException | IOException e ) {
throw new ManifestErrorException ( e ) ;
throw new ManifestErrorException ( e ) ;
@ -512,6 +529,16 @@ public class RepoCommand extends GitCommand<RevCommit> {
cfg . setString ( "submodule" , name , "branch" , //$NON-NLS-1$ //$NON-NLS-2$
cfg . setString ( "submodule" , name , "branch" , //$NON-NLS-1$ //$NON-NLS-2$
proj . getRevision ( ) ) ;
proj . getRevision ( ) ) ;
}
}
if ( recordShallowSubmodules & & proj . getRecommendShallow ( ) ! = null ) {
// The shallow recommendation is losing information.
// As the repo manifests stores the recommended
// depth in the 'clone-depth' field, while
// git core only uses a binary 'shallow = true/false'
// hint, we'll map any depth to 'shallow = true'
cfg . setBoolean ( "submodule" , name , "shallow" , //$NON-NLS-1$ //$NON-NLS-2$
true ) ;
}
}
}
if ( recordSubmoduleLabels ) {
if ( recordSubmoduleLabels ) {
StringBuilder rec = new StringBuilder ( ) ;
StringBuilder rec = new StringBuilder ( ) ;
@ -616,10 +643,10 @@ public class RepoCommand extends GitCommand<RevCommit> {
}
}
private void addSubmodule ( String url , String name , String revision ,
private void addSubmodule ( String url , String name , String revision ,
List < CopyFile > copyfiles , Set < String > groups )
List < CopyFile > copyfiles , Set < String > groups , String recommendShallow )
throws GitAPIException , IOException {
throws GitAPIException , IOException {
if ( repo . isBare ( ) ) {
if ( repo . isBare ( ) ) {
RepoProject proj = new RepoProject ( url , name , revision , null , groups ) ;
RepoProject proj = new RepoProject ( url , name , revision , null , groups , recommendShallow ) ;
proj . addCopyFiles ( copyfiles ) ;
proj . addCopyFiles ( copyfiles ) ;
bareProjects . add ( proj ) ;
bareProjects . add ( proj ) ;
} else {
} else {