diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 53087faf7a63e6268ffff5239142a00c120dcf8f..e47715538bd1ff81d1a91e0a43cd9bdbe1cb0d3f 100644 (file)
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
#include "tree-walk.h"
#include "cache-tree.h"
#include "unpack-trees.h"
#include "tree-walk.h"
#include "cache-tree.h"
#include "unpack-trees.h"
+#include "dir.h"
#include "builtin.h"
static struct object_list *trees;
#include "builtin.h"
static struct object_list *trees;
struct name_entry entry;
int cnt;
struct name_entry entry;
int cnt;
- memcpy(it->sha1, tree->object.sha1, 20);
+ hashcpy(it->sha1, tree->object.sha1);
desc.buf = tree->buffer;
desc.size = tree->size;
cnt = 0;
desc.buf = tree->buffer;
desc.size = tree->size;
cnt = 0;
}
}
-static const char read_tree_usage[] = "git-read-tree (<sha> | [[-m [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] <sha1> [<sha2> [<sha3>]])";
+static const char read_tree_usage[] = "git-read-tree (<sha> | [[-m [--aggressive] | --reset | --prefix=<prefix>] [-u | -i]] [--exclude-per-directory=<gitignore>] <sha1> [<sha2> [<sha3>]])";
static struct lock_file lock_file;
static struct lock_file lock_file;
* entries and put the entries from the tree under the
* given subdirectory.
*/
* entries and put the entries from the tree under the
* given subdirectory.
*/
- if (!strncmp(arg, "--prefix=", 9)) {
+ if (!prefixcmp(arg, "--prefix=")) {
if (stage || opts.merge || opts.prefix)
usage(read_tree_usage);
opts.prefix = arg + 9;
if (stage || opts.merge || opts.prefix)
usage(read_tree_usage);
opts.prefix = arg + 9;
continue;
}
continue;
}
+ if (!prefixcmp(arg, "--exclude-per-directory=")) {
+ struct dir_struct *dir;
+
+ if (opts.dir)
+ die("more than one --exclude-per-directory are given.");
+
+ dir = calloc(1, sizeof(*opts.dir));
+ dir->show_ignored = 1;
+ dir->exclude_per_dir = arg + 24;
+ opts.dir = dir;
+ /* We do not need to nor want to do read-directory
+ * here; we are merely interested in reusing the
+ * per directory ignore stack mechanism.
+ */
+ continue;
+ }
+
/* using -u and -i at the same time makes no sense */
if (1 < opts.index_only + opts.update)
usage(read_tree_usage);
/* using -u and -i at the same time makes no sense */
if (1 < opts.index_only + opts.update)
usage(read_tree_usage);
}
if ((opts.update||opts.index_only) && !opts.merge)
usage(read_tree_usage);
}
if ((opts.update||opts.index_only) && !opts.merge)
usage(read_tree_usage);
+ if ((opts.dir && !opts.update))
+ die("--exclude-per-directory is meaningless unless -u");
if (opts.prefix) {
int pfxlen = strlen(opts.prefix);
if (opts.prefix) {
int pfxlen = strlen(opts.prefix);