@@ -130,8 +130,6 @@ pub(crate) struct GitDatabase {
130
130
131
131
/// A local checkout of a particular revision from a [`GitRepository`].
132
132
pub ( crate ) struct GitCheckout {
133
- /// Path to the root of the underlying Git repository on the local filesystem.
134
- path : PathBuf ,
135
133
/// The git revision this checkout is for.
136
134
revision : GitOid ,
137
135
/// Underlying Git repository instance for this checkout.
@@ -150,7 +148,7 @@ impl GitRepository {
150
148
// Make sure there is a Git repository at the specified path.
151
149
ProcessBuilder :: new ( "git" )
152
150
. arg ( "rev-parse" )
153
- . arg ( "HEAD" )
151
+ . cwd ( path )
154
152
. exec_with_streaming ( & mut silent, & mut silent, true ) ?;
155
153
156
154
Ok ( GitRepository {
@@ -293,7 +291,9 @@ impl GitDatabase {
293
291
. cwd ( & self . repo . path )
294
292
. exec_with_streaming ( & mut silent, & mut silent, true ) ?;
295
293
296
- Ok ( String :: from_utf8 ( output. stdout ) ?)
294
+ let mut result = String :: from_utf8 ( output. stdout ) ?;
295
+ result. truncate ( result. trim_end ( ) . len ( ) ) ;
296
+ Ok ( result)
297
297
}
298
298
299
299
/// Checks if the database contains the object of this `oid`.
@@ -343,11 +343,7 @@ impl GitCheckout {
343
343
///
344
344
/// * The `repo` will be the checked out Git repository.
345
345
fn new ( revision : GitOid , repo : GitRepository ) -> GitCheckout {
346
- GitCheckout {
347
- path : repo. path . clone ( ) ,
348
- revision,
349
- repo,
350
- }
346
+ GitCheckout { revision, repo }
351
347
}
352
348
353
349
/// Clone a repo for a `revision` into a local path from a `database`.
@@ -384,7 +380,7 @@ impl GitCheckout {
384
380
match self . repo . rev_parse ( "HEAD" ) {
385
381
Ok ( id) if id == self . revision => {
386
382
// See comments in reset() for why we check this
387
- self . path . join ( CHECKOUT_READY_LOCK ) . exists ( )
383
+ self . repo . path . join ( CHECKOUT_READY_LOCK ) . exists ( )
388
384
}
389
385
_ => false ,
390
386
}
@@ -404,7 +400,7 @@ impl GitCheckout {
404
400
///
405
401
/// [`.cargo-ok`]: CHECKOUT_READY_LOCK
406
402
fn reset ( & self ) -> Result < ( ) > {
407
- let ok_file = self . path . join ( CHECKOUT_READY_LOCK ) ;
403
+ let ok_file = self . repo . path . join ( CHECKOUT_READY_LOCK ) ;
408
404
let _ = paths:: remove_file ( & ok_file) ;
409
405
debug ! ( "reset {} to {}" , self . repo. path. display( ) , self . revision) ;
410
406
@@ -419,7 +415,7 @@ impl GitCheckout {
419
415
. arg ( "reset" )
420
416
. arg ( "--hard" )
421
417
. arg ( self . revision . as_str ( ) )
422
- . cwd ( & self . path )
418
+ . cwd ( & self . repo . path )
423
419
. exec_with_streaming ( & mut silent, & mut silent, true ) ?;
424
420
425
421
paths:: create ( ok_file) ?;
@@ -433,7 +429,7 @@ impl GitCheckout {
433
429
. arg ( "update" )
434
430
. arg ( "--recursive" )
435
431
. arg ( "--init" )
436
- . cwd ( & self . path )
432
+ . cwd ( & self . repo . path )
437
433
. exec_with_streaming ( & mut silent, & mut silent, true )
438
434
. map ( drop)
439
435
}
0 commit comments