These commands' monitor fields can never be null unless someone passes null to setProgressMonitor. Anyone passing null probably meant to disable the ProgressMonitor, so do that (by falling back to NullProgressMonitor.INSTANCE) instead of saving a null and eventually producing NullPointerException. Change-Id: I63ad93ea8ad669fd333a5fd40880e7583ba24827 Signed-off-by: Jonathan Nieder <jrn@google.com>tags/v4.1.0.201509280440-r
* @return {@code this} | * @return {@code this} | ||||
*/ | */ | ||||
public CloneCommand setProgressMonitor(ProgressMonitor monitor) { | public CloneCommand setProgressMonitor(ProgressMonitor monitor) { | ||||
if (monitor == null) { | |||||
monitor = NullProgressMonitor.INSTANCE; | |||||
} | |||||
this.monitor = monitor; | this.monitor = monitor; | ||||
return this; | return this; | ||||
} | } |
* @return this instance | * @return this instance | ||||
*/ | */ | ||||
public DiffCommand setProgressMonitor(ProgressMonitor monitor) { | public DiffCommand setProgressMonitor(ProgressMonitor monitor) { | ||||
if (monitor == null) { | |||||
monitor = NullProgressMonitor.INSTANCE; | |||||
} | |||||
this.monitor = monitor; | this.monitor = monitor; | ||||
return this; | return this; | ||||
} | } | ||||
} | |||||
} |
*/ | */ | ||||
public FetchCommand setProgressMonitor(ProgressMonitor monitor) { | public FetchCommand setProgressMonitor(ProgressMonitor monitor) { | ||||
checkCallable(); | checkCallable(); | ||||
if (monitor == null) { | |||||
monitor = NullProgressMonitor.INSTANCE; | |||||
} | |||||
this.monitor = monitor; | this.monitor = monitor; | ||||
return this; | return this; | ||||
} | } |
* @return this instance | * @return this instance | ||||
*/ | */ | ||||
public PullCommand setProgressMonitor(ProgressMonitor monitor) { | public PullCommand setProgressMonitor(ProgressMonitor monitor) { | ||||
if (monitor == null) { | |||||
monitor = NullProgressMonitor.INSTANCE; | |||||
} | |||||
this.monitor = monitor; | this.monitor = monitor; | ||||
return this; | return this; | ||||
} | } |
*/ | */ | ||||
public PushCommand setProgressMonitor(ProgressMonitor monitor) { | public PushCommand setProgressMonitor(ProgressMonitor monitor) { | ||||
checkCallable(); | checkCallable(); | ||||
if (monitor == null) { | |||||
monitor = NullProgressMonitor.INSTANCE; | |||||
} | |||||
this.monitor = monitor; | this.monitor = monitor; | ||||
return this; | return this; | ||||
} | } |
* @return this instance | * @return this instance | ||||
*/ | */ | ||||
public RebaseCommand setProgressMonitor(ProgressMonitor monitor) { | public RebaseCommand setProgressMonitor(ProgressMonitor monitor) { | ||||
if (monitor == null) { | |||||
monitor = NullProgressMonitor.INSTANCE; | |||||
} | |||||
this.monitor = monitor; | this.monitor = monitor; | ||||
return this; | return this; | ||||
} | } |