summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 706fe6a)
raw | patch | inline | side by side (parent: 706fe6a)
author | Junio C Hamano <junkio@cox.net> | |
Sat, 26 Nov 2005 08:40:50 +0000 (00:40 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 29 Nov 2005 07:13:02 +0000 (23:13 -0800) |
This makes ls-tree to work from subdirectory. It defaults to
show the paths under the current subdirectory, and interprets
user-supplied paths as relative to the current subdirectory.
Signed-off-by: Junio C Hamano <junkio@cox.net>
show the paths under the current subdirectory, and interprets
user-supplied paths as relative to the current subdirectory.
Signed-off-by: Junio C Hamano <junkio@cox.net>
ls-tree.c | patch | blob | history |
diff --git a/ls-tree.c b/ls-tree.c
index d7c7e750fbf08363731e7bafdc6b2b1b058ccc38..cf4223f4bfd63f047d8f9d3bed3ee5fbeaeef3c4 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
return err;
}
-static int list(char **path)
+static int list(const char **path)
{
int i;
int err = 0;
static const char ls_tree_usage[] =
"git-ls-tree [-d] [-r] [-z] <tree-ish> [path...]";
-int main(int argc, char **argv)
+int main(int argc, const char **argv)
{
- static char *path0[] = { "", NULL };
- char **path;
+ static const char *path0[] = { "", NULL };
+ const char **path;
unsigned char sha1[20];
+ int nongit = 0;
+ const char *prefix = setup_git_directory_gently(&nongit);
+
+ if (prefix)
+ path0[0] = prefix;
while (1 < argc && argv[1][0] == '-') {
switch (argv[1][1]) {
if (get_sha1(argv[1], sha1) < 0)
usage(ls_tree_usage);
- path = (argc == 2) ? path0 : (argv + 2);
+ if (argc == 2)
+ path = path0;
+ else
+ path = get_pathspec(prefix, argv + 2);
+
prepare_root(sha1);
if (list(path) < 0)
die("list failed");