@@ -20,40 +20,43 @@ pub(in crate::command::release_impl) fn commit_changes<'a>(
2020 // `git commit -am` only stages tracked files, so we need to explicitly add new ones.
2121 if !changelog_paths. is_empty ( ) {
2222 let index = ctx. repo . open_index ( ) ?;
23- let worktree = ctx. repo . workdir ( ) . expect ( "this is a worktree repository" ) ;
24-
23+ let workdir = ctx. repo . workdir ( ) . context ( "Can only work in non-bare repositories" ) ? ;
24+
2525 let untracked_paths: Vec < _ > = changelog_paths
2626 . iter ( )
2727 . filter ( |path| {
2828 // Convert absolute path to worktree-relative path with forward slashes
29- path. as_ref ( )
30- . strip_prefix ( worktree)
31- . ok ( )
32- . map ( |relative_path| {
33- let relative_path_unix =
34- gix:: path:: to_unix_separators ( gix:: path:: into_bstr ( relative_path) ) ;
35- // Check if the path is NOT tracked in the git index
36- index. entry_by_path ( relative_path_unix. as_bstr ( ) ) . is_none ( )
37- } )
38- . unwrap_or ( false )
29+ path. as_ref ( ) . strip_prefix ( workdir) . ok ( ) . is_some_and ( |relative_path| {
30+ let relative_path_unix = gix:: path:: to_unix_separators ( gix:: path:: into_bstr ( relative_path) ) ;
31+ // Check if the path is NOT tracked in the git index
32+ index. entry_by_path ( relative_path_unix. as_bstr ( ) ) . is_none ( )
33+ } )
3934 } )
4035 . collect ( ) ;
4136
4237 if !untracked_paths. is_empty ( ) {
43- let mut add_cmd = Command :: new ( "git" ) ;
44- add_cmd . arg ( "add" ) . arg ( "--" ) ;
38+ let mut git_add = Command :: new ( gix :: path :: env :: exe_invocation ( ) ) ;
39+ git_add . args ( [ "add" , "--" ] ) ;
4540 for path in & untracked_paths {
46- add_cmd . arg ( path. as_ref ( ) ) ;
41+ git_add . arg ( path. as_ref ( ) ) ;
4742 }
48- log:: trace!( "{} run {:?}" , will( dry_run) , add_cmd) ;
49- if !dry_run && !add_cmd. status ( ) ?. success ( ) {
50- let paths: Vec < _ > = untracked_paths. iter ( ) . map ( |p| p. as_ref ( ) . display ( ) . to_string ( ) ) . collect ( ) ;
51- bail ! ( "Failed to add new changelog files to git: {}" , paths. join( ", " ) ) ;
43+ log:: trace!( "{} run {:?}" , will( dry_run) , git_add) ;
44+ let output = git_add. output ( ) ?;
45+ if !dry_run && !output. status . success ( ) {
46+ let paths: Vec < _ > = untracked_paths
47+ . iter ( )
48+ . map ( |p| p. as_ref ( ) . display ( ) . to_string ( ) )
49+ . collect ( ) ;
50+ bail ! (
51+ "Failed to add new changelog files to git: {}: {err}" ,
52+ paths. join( ", " ) ,
53+ err = output. stderr. to_str_lossy( )
54+ ) ;
5255 }
5356 }
5457 }
5558
56- let mut cmd = Command :: new ( "git" ) ;
59+ let mut cmd = Command :: new ( gix :: path :: env :: exe_invocation ( ) ) ;
5760 cmd. arg ( "commit" ) . arg ( "-am" ) . arg ( message. as_ref ( ) ) ;
5861 if empty_commit_possible {
5962 cmd. arg ( "--allow-empty" ) ;
@@ -134,7 +137,7 @@ pub fn push_tags_and_head(
134137 return Ok ( ( ) ) ;
135138 }
136139
137- let mut cmd = Command :: new ( "git" ) ;
140+ let mut cmd = Command :: new ( gix :: path :: env :: exe_invocation ( ) ) ;
138141 cmd. arg ( "push" )
139142 . arg ( {
140143 let remote = repo
0 commit comments