2005-04-19 02:39:48 +08:00
|
|
|
#ifndef TREE_H
|
|
|
|
#define TREE_H
|
|
|
|
|
|
|
|
#include "object.h"
|
|
|
|
|
|
|
|
extern const char *tree_type;
|
|
|
|
|
2005-04-24 09:47:23 +08:00
|
|
|
struct tree_entry_list {
|
|
|
|
struct tree_entry_list *next;
|
|
|
|
unsigned directory : 1;
|
|
|
|
unsigned executable : 1;
|
2005-05-06 07:18:48 +08:00
|
|
|
unsigned symlink : 1;
|
|
|
|
unsigned int mode;
|
2005-04-24 09:47:23 +08:00
|
|
|
char *name;
|
|
|
|
union {
|
|
|
|
struct tree *tree;
|
|
|
|
struct blob *blob;
|
|
|
|
} item;
|
[PATCH] Rewrite ls-tree to behave more like "/bin/ls -a"
This is a complete rewrite of ls-tree to make it behave more
like what "/bin/ls -a" does in the current working directory.
Namely, the changes are:
- Unlike the old ls-tree behaviour that used paths arguments to
restrict output (not that it worked as intended---as pointed
out in the mailing list discussion, it was quite incoherent),
this rewrite uses paths arguments to specify what to show.
- Without arguments, it implicitly uses the root level as its
sole argument ("/bin/ls -a" behaves as if "." is given
without argument).
- Without -r (recursive) flag, it shows the named blob (either
file or symlink), or the named tree and its immediate
children.
- With -r flag, it shows the named path, and recursively
descends into it if it is a tree.
- With -d flag, it shows the named path and does not show its
children even if the path is a tree, nor descends into it
recursively.
This is still request-for-comments patch. There is no mailing
list consensus that this proposed new behaviour is a good one.
The patch to t/t3100-ls-tree-restrict.sh illustrates
user-visible behaviour changes. Namely:
* "git-ls-tree $tree path1 path0" lists path1 first and then
path0. It used to use paths as an output restrictor and
showed output in cache entry order (i.e. path0 first and then
path1) regardless of the order of paths arguments.
* "git-ls-tree $tree path2" lists path2 and its immediate
children but having explicit paths argument does not imply
recursive behaviour anymore, hence paths/baz is shown but not
paths/baz/b.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-05-28 15:05:38 +08:00
|
|
|
struct tree_entry_list *parent;
|
2005-04-24 09:47:23 +08:00
|
|
|
};
|
|
|
|
|
2005-04-19 02:39:48 +08:00
|
|
|
struct tree {
|
|
|
|
struct object object;
|
2005-04-24 09:47:23 +08:00
|
|
|
struct tree_entry_list *entries;
|
2005-04-19 02:39:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct tree *lookup_tree(unsigned char *sha1);
|
|
|
|
|
2005-05-07 01:48:34 +08:00
|
|
|
int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
|
|
|
|
|
2005-04-19 02:39:48 +08:00
|
|
|
int parse_tree(struct tree *tree);
|
|
|
|
|
|
|
|
#endif /* TREE_H */
|