@@ -6,7 +6,7 @@ use std::{
66
77use anyhow:: { anyhow, bail, Context , Result } ;
88use gix:: {
9- bstr:: { BStr , ByteSlice } ,
9+ bstr:: { BStr , BString } ,
1010 objs:: commit:: SIGNATURE_FIELD_NAME ,
1111} ;
1212
@@ -49,10 +49,10 @@ pub fn verify(repo: gix::Repository, rev_spec: Option<&str>) -> Result<()> {
4949
5050pub fn sign ( repo : gix:: Repository , rev_spec : Option < & str > , mut out : impl std:: io:: Write ) -> Result < ( ) > {
5151 let rev_spec = rev_spec. unwrap_or ( "HEAD" ) ;
52- let commit = repo
52+ let object = repo
5353 . rev_parse_single ( format ! ( "{rev_spec}^{{commit}}" ) . as_str ( ) ) ?
54- . object ( ) ?
55- . into_commit ( ) ;
54+ . object ( ) ?;
55+ let mut commit_ref = object . to_commit_ref ( ) ;
5656
5757 let mut cmd: std:: process:: Command = gix:: command:: prepare ( "gpg" ) . into ( ) ;
5858 cmd. args ( [
@@ -66,11 +66,7 @@ pub fn sign(repo: gix::Repository, rev_spec: Option<&str>, mut out: impl std::io
6666 . stdout ( Stdio :: piped ( ) ) ;
6767 gix:: trace:: debug!( "About to execute {cmd:?}" ) ;
6868 let mut child = cmd. spawn ( ) ?;
69- child
70- . stdin
71- . take ( )
72- . expect ( "to be present" )
73- . write_all ( commit. data . as_ref ( ) ) ?;
69+ child. stdin . take ( ) . expect ( "to be present" ) . write_all ( & object. data ) ?;
7470
7571 if !child. wait ( ) ?. success ( ) {
7672 bail ! ( "Command {cmd:?} failed" ) ;
@@ -83,12 +79,7 @@ pub fn sign(repo: gix::Repository, rev_spec: Option<&str>, mut out: impl std::io
8379 . expect ( "to be present" )
8480 . read_to_end ( & mut signed_data) ?;
8581
86- let object = repo
87- . rev_parse_single ( format ! ( "{rev_spec}^{{commit}}" ) . as_str ( ) ) ?
88- . object ( ) ?;
89- let mut commit_ref = object. to_commit_ref ( ) ;
90-
91- let extra_header: Cow < ' _ , BStr > = Cow :: Borrowed ( signed_data. as_bstr ( ) ) ;
82+ let extra_header: Cow < ' _ , BStr > = Cow :: Owned ( BString :: new ( signed_data) ) ;
9283
9384 assert ! (
9485 !commit_ref
0 commit comments