+static void handle_internal_command(int argc, const char **argv, char **envp)
+{
+ const char *cmd = argv[0];
+ static struct cmd_struct {
+ const char *cmd;
+ int (*fn)(int, const char **, char **);
+ } commands[] = {
+ { "version", cmd_version },
+ { "help", cmd_help },
+ { "log", cmd_log },
+ { "whatchanged", cmd_whatchanged },
+ { "show", cmd_show },
+ { "push", cmd_push },
+ { "format-patch", cmd_format_patch },
+ { "count-objects", cmd_count_objects },
+ { "diff", cmd_diff },
+ { "grep", cmd_grep },
+ { "rm", cmd_rm },
+ { "add", cmd_add },
+ { "rev-list", cmd_rev_list },
+ { "init-db", cmd_init_db },
+ { "get-tar-commit-id", cmd_get_tar_commit_id },
+ { "upload-tar", cmd_upload_tar },
+ { "check-ref-format", cmd_check_ref_format },
+ { "ls-files", cmd_ls_files },
+ { "ls-tree", cmd_ls_tree },
+ { "tar-tree", cmd_tar_tree },
+ { "read-tree", cmd_read_tree },
+ { "commit-tree", cmd_commit_tree },
+ { "apply", cmd_apply },
+ { "show-branch", cmd_show_branch },
+ { "diff-files", cmd_diff_files },
+ { "diff-index", cmd_diff_index },
+ { "diff-stages", cmd_diff_stages },
+ { "diff-tree", cmd_diff_tree },
+ { "cat-file", cmd_cat_file },
+ { "rev-parse", cmd_rev_parse }
+ };
+ int i;
+
+ /* Turn "git cmd --help" into "git help cmd" */
+ if (argc > 1 && !strcmp(argv[1], "--help")) {
+ argv[1] = argv[0];
+ argv[0] = cmd = "help";