@@ -85,7 +85,7 @@ public override void Execute()
8585 this . ValidatePathParameter ( this . EnlistmentRootPathParameter ) ;
8686 this . ValidatePathParameter ( this . LocalCacheRoot ) ;
8787
88- string fullEnlistmentRootPathParameter ;
88+ string fullEnlistmentRootPathParameter ;
8989 string normalizedEnlistmentRootPath = this . GetCloneRoot ( out fullEnlistmentRootPathParameter ) ;
9090
9191 if ( ! string . IsNullOrWhiteSpace ( this . LocalCacheRoot ) )
@@ -144,8 +144,8 @@ public override void Execute()
144144 { "NamedPipeName" , enlistment . NamedPipeName } ,
145145 { nameof ( this . EnlistmentRootPathParameter ) , this . EnlistmentRootPathParameter } ,
146146 { nameof ( fullEnlistmentRootPathParameter ) , fullEnlistmentRootPathParameter } ,
147- } ) ;
148-
147+ } ) ;
148+
149149 CacheServerResolver cacheServerResolver = new CacheServerResolver ( tracer , enlistment ) ;
150150 cacheServer = cacheServerResolver . ParseUrlOrFriendlyName ( this . CacheServerUrl ) ;
151151
@@ -177,8 +177,8 @@ public override void Execute()
177177
178178 cacheServer = this . ResolveCacheServer ( tracer , cacheServer , cacheServerResolver , serverGVFSConfig ) ;
179179
180- this . ValidateClientVersions ( tracer , enlistment , serverGVFSConfig , showWarnings : true ) ;
181-
180+ this . ValidateClientVersions ( tracer , enlistment , serverGVFSConfig , showWarnings : true ) ;
181+
182182 this . ShowStatusWhileRunning (
183183 ( ) =>
184184 {
@@ -276,7 +276,7 @@ private static bool IsForceCheckoutErrorCloneFailure(string checkoutError)
276276
277277 private Result TryCreateEnlistment (
278278 string fullEnlistmentRootPathParameter ,
279- string normalizedEnlistementRootPath ,
279+ string normalizedEnlistementRootPath ,
280280 out GVFSEnlistment enlistment )
281281 {
282282 enlistment = null ;
@@ -297,25 +297,35 @@ private Result TryCreateEnlistment(
297297 if ( string . IsNullOrWhiteSpace ( gitBinPath ) )
298298 {
299299 return new Result ( GVFSConstants . GitIsNotInstalledError ) ;
300- }
301-
300+ }
301+
302302 string hooksPath = this . GetGVFSHooksPathAndCheckVersion ( tracer : null , hooksVersion : out _ ) ;
303303
304- enlistment = new GVFSEnlistment (
305- normalizedEnlistementRootPath ,
306- this . RepositoryURL ,
307- gitBinPath ,
308- hooksPath ,
309- authentication : null ) ;
310-
304+ try
305+ {
306+ enlistment = new GVFSEnlistment (
307+ normalizedEnlistementRootPath ,
308+ this . RepositoryURL ,
309+ gitBinPath ,
310+ hooksPath ,
311+ authentication : null ) ;
312+ }
313+ catch ( InvalidRepoException e )
314+ {
315+ this . ReportErrorAndExit (
316+ "Error when creating a new GVFS enlistment at '{0}'. {1}" ,
317+ normalizedEnlistementRootPath ,
318+ e . Message ) ;
319+ }
320+
311321 return new Result ( true ) ;
312- }
313-
322+ }
323+
314324 private Result TryClone (
315- JsonTracer tracer ,
316- GVFSEnlistment enlistment ,
317- CacheServerInfo cacheServer ,
318- RetryConfig retryConfig ,
325+ JsonTracer tracer ,
326+ GVFSEnlistment enlistment ,
327+ CacheServerInfo cacheServer ,
328+ RetryConfig retryConfig ,
319329 ServerGVFSConfig serverGVFSConfig ,
320330 string resolvedLocalCacheRoot )
321331 {
@@ -325,8 +335,8 @@ private Result TryClone(
325335 if ( ! pipeResult . Success )
326336 {
327337 return pipeResult ;
328- }
329-
338+ }
339+
330340 using ( GitObjectsHttpRequestor objectRequestor = new GitObjectsHttpRequestor ( tracer , enlistment , cacheServer , retryConfig ) )
331341 {
332342 GitRefs refs = objectRequestor . QueryInfoRefs ( this . SingleBranch ? this . Branch : null ) ;
@@ -445,7 +455,7 @@ private void CheckNotInsideExistingRepo(string normalizedEnlistmentRootPath)
445455 string errorMessage ;
446456 string existingEnlistmentRoot ;
447457 if ( GVFSPlatform . Instance . TryGetGVFSEnlistmentRoot ( normalizedEnlistmentRootPath , out existingEnlistmentRoot , out errorMessage ) )
448- {
458+ {
449459 this . ReportErrorAndExit ( "Error: You can't clone inside an existing GVFS repo ({0})" , existingEnlistmentRoot ) ;
450460 }
451461 }
@@ -504,8 +514,8 @@ private Result CreateClone(
504514 if ( ! this . TryCreateAlternatesFile ( fileSystem , enlistment , out errorMessage ) )
505515 {
506516 return new Result ( "Error configuring alternate: " + errorMessage ) ;
507- }
508-
517+ }
518+
509519 GitRepo gitRepo = new GitRepo ( tracer , enlistment , fileSystem ) ;
510520 GVFSContext context = new GVFSContext ( tracer , fileSystem , gitRepo , enlistment ) ;
511521 GVFSGitObjects gitObjects = new GVFSGitObjects ( context , objectRequestor ) ;
0 commit comments