File tree Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Expand file tree Collapse file tree 2 files changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -333,10 +333,6 @@ extern char *gitdirname(char *);
333
333
#define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin"
334
334
#endif
335
335
336
- #ifndef STRIP_EXTENSION
337
- #define STRIP_EXTENSION ""
338
- #endif
339
-
340
336
#ifndef has_dos_drive_prefix
341
337
static inline int git_has_dos_drive_prefix (const char * path )
342
338
{
Original file line number Diff line number Diff line change @@ -502,21 +502,25 @@ int is_builtin(const char *s)
502
502
return !!get_builtin (s );
503
503
}
504
504
505
+ #ifdef STRIP_EXTENSION
506
+ static void strip_extension (const char * * argv )
507
+ {
508
+ size_t len ;
509
+
510
+ if (strip_suffix (argv [0 ], STRIP_EXTENSION , & len ))
511
+ argv [0 ] = xmemdupz (argv [0 ], len );
512
+ }
513
+ #else
514
+ #define strip_extension (cmd )
515
+ #endif
516
+
505
517
static void handle_builtin (int argc , const char * * argv )
506
518
{
507
- const char * cmd = argv [0 ];
508
- int i ;
509
- static const char ext [] = STRIP_EXTENSION ;
519
+ const char * cmd ;
510
520
struct cmd_struct * builtin ;
511
521
512
- if (sizeof (ext ) > 1 ) {
513
- i = strlen (argv [0 ]) - strlen (ext );
514
- if (i > 0 && !strcmp (argv [0 ] + i , ext )) {
515
- char * argv0 = xstrdup (argv [0 ]);
516
- argv [0 ] = cmd = argv0 ;
517
- argv0 [i ] = '\0' ;
518
- }
519
- }
522
+ strip_extension (argv );
523
+ cmd = argv [0 ];
520
524
521
525
/* Turn "git cmd --help" into "git help cmd" */
522
526
if (argc > 1 && !strcmp (argv [1 ], "--help" )) {
You can’t perform that action at this time.
0 commit comments