File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -1018,8 +1018,7 @@ int cmd_rev_parse(int argc,
10181018 if (!strcmp (arg , "--git-dir" ) ||
10191019 !strcmp (arg , "--absolute-git-dir" )) {
10201020 const char * gitdir = getenv (GIT_DIR_ENVIRONMENT );
1021- char * cwd ;
1022- int len ;
1021+ struct strbuf path = STRBUF_INIT ;
10231022 enum format_type wanted = format ;
10241023 if (arg [2 ] == 'g' ) { /* --git-dir */
10251024 if (gitdir ) {
@@ -1042,12 +1041,12 @@ int cmd_rev_parse(int argc,
10421041 continue ;
10431042 }
10441043 }
1045- cwd = xgetcwd ();
1046- len = strlen ( cwd );
1047- strbuf_reset ( & buf );
1048- strbuf_addf ( & buf , "%s%s .git" , cwd , len && cwd [ len - 1 ] != '/' ? "/" : " " );
1049- free ( cwd );
1050- print_path ( buf . buf , prefix , wanted , DEFAULT_CANONICAL );
1044+ if ( strbuf_getcwd ( & path ))
1045+ die_errno ( _ ( "unable to get current working directory" ) );
1046+ strbuf_complete ( & path , '/' );
1047+ strbuf_addstr ( & path , ".git" );
1048+ print_path ( path . buf , prefix , wanted , DEFAULT_CANONICAL );
1049+ strbuf_release ( & path );
10511050 continue ;
10521051 }
10531052 if (!strcmp (arg , "--git-common-dir" )) {
You can’t perform that action at this time.
0 commit comments