File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -325,10 +325,6 @@ extern char *gitdirname(char *);
325325#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
326326#endif
327327
328- #ifndef STRIP_EXTENSION
329- #define STRIP_EXTENSION ""
330- #endif
331-
332328#ifndef has_dos_drive_prefix
333329static inline int git_has_dos_drive_prefix (const char * path )
334330{
Original file line number Diff line number Diff line change @@ -513,21 +513,25 @@ int is_builtin(const char *s)
513513 return !!get_builtin (s );
514514}
515515
516+ #ifdef STRIP_EXTENSION
517+ static void strip_extension (const char * * argv )
518+ {
519+ size_t len ;
520+
521+ if (strip_suffix (argv [0 ], STRIP_EXTENSION , & len ))
522+ argv [0 ] = xmemdupz (argv [0 ], len );
523+ }
524+ #else
525+ #define strip_extension (cmd )
526+ #endif
527+
516528static void handle_builtin (int argc , const char * * argv )
517529{
518- const char * cmd = argv [0 ];
519- int i ;
520- static const char ext [] = STRIP_EXTENSION ;
530+ const char * cmd ;
521531 struct cmd_struct * builtin ;
522532
523- if (sizeof (ext ) > 1 ) {
524- i = strlen (argv [0 ]) - strlen (ext );
525- if (i > 0 && !strcmp (argv [0 ] + i , ext )) {
526- char * argv0 = xstrdup (argv [0 ]);
527- argv [0 ] = cmd = argv0 ;
528- argv0 [i ] = '\0' ;
529- }
530- }
533+ strip_extension (argv );
534+ cmd = argv [0 ];
531535
532536 /* Turn "git cmd --help" into "git help cmd" */
533537 if (argc > 1 && !strcmp (argv [1 ], "--help" )) {
You can’t perform that action at this time.
0 commit comments