]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin-ls-tree.c
Fix a "pointer type missmatch" warning.
[thirdparty/git.git] / builtin-ls-tree.c
index 48385d59f6097258b83ebbf0156e1913043b6928..201defd9344a25e16066dc7d0a0a8f5707a930cb 100644 (file)
@@ -14,11 +14,11 @@ static int line_termination = '\n';
 #define LS_TREE_ONLY 2
 #define LS_SHOW_TREES 4
 #define LS_NAME_ONLY 8
-static int abbrev = 0;
-static int ls_options = 0;
+static int abbrev;
+static int ls_options;
 static const char **pathspec;
-static int chomp_prefix = 0;
-static const char *prefix;
+static int chomp_prefix;
+static const char *ls_tree_prefix;
 
 static const char ls_tree_usage[] =
        "git-ls-tree [-d] [-r] [-t] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
@@ -53,7 +53,7 @@ static int show_recursive(const char *base, int baselen, const char *pathname)
        }
 }
 
-static int show_tree(unsigned char *sha1, const char *base, int baselen,
+static int show_tree(const unsigned char *sha1, const char *base, int baselen,
                     const char *pathname, unsigned mode, int stage)
 {
        int retval = 0;
@@ -71,7 +71,7 @@ static int show_tree(unsigned char *sha1, const char *base, int baselen,
                return 0;
 
        if (chomp_prefix &&
-           (baselen < chomp_prefix || memcmp(prefix, base, chomp_prefix)))
+           (baselen < chomp_prefix || memcmp(ls_tree_prefix, base, chomp_prefix)))
                return 0;
 
        if (!(ls_options & LS_NAME_ONLY))
@@ -85,13 +85,13 @@ static int show_tree(unsigned char *sha1, const char *base, int baselen,
        return retval;
 }
 
-int cmd_ls_tree(int argc, const char **argv, char **envp)
+int cmd_ls_tree(int argc, const char **argv, const char *prefix)
 {
        unsigned char sha1[20];
        struct tree *tree;
 
-       prefix = setup_git_directory();
        git_config(git_default_config);
+       ls_tree_prefix = prefix;
        if (prefix && *prefix)
                chomp_prefix = strlen(prefix);
        while (1 < argc && argv[1][0] == '-') {