ls-tree: resurrect '-d' to mean 'show trees only'
[gitweb.git] / git.c
diff --git a/git.c b/git.c
index b9b8c62f47cc54ef03161e61569dcd0d7b259828..0b10b6e781fdf76a3822b15cfa304352aee812cc 100644 (file)
--- a/git.c
+++ b/git.c
@@ -59,7 +59,8 @@ static void add_cmdname(const char *name, int len)
        if (!ent)
                oom();
        ent->len = len;
-       memcpy(ent->name, name, len+1);
+       memcpy(ent->name, name, len);
+       ent->name[len] = 0;
        cmdname[cmdname_cnt++] = ent;
 }
 
@@ -132,6 +133,8 @@ static void list_commands(const char *exec_path, const char *pattern)
                        continue;
 
                entlen = strlen(de->d_name);
+               if (4 < entlen && !strcmp(de->d_name + entlen - 4, ".exe"))
+                       entlen -= 4;
 
                if (longest < entlen)
                        longest = entlen;
@@ -270,7 +273,7 @@ int main(int argc, char **argv, char **envp)
                while (!strncmp(exec_path, "./", 2)) {
                        exec_path += 2;
                        while (*exec_path == '/')
-                               *exec_path++;
+                               exec_path++;
                }
                snprintf(git_command + len, sizeof(git_command) - len,
                         "/%s", exec_path);