summaryrefslogtreecommitdiff
path: root/builtin-read-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2006-12-04 16:00:46 -0800
committerJunio C Hamano <junkio@cox.net>2006-12-05 23:25:52 -0800
commitf8a9d4287277ed15d3f0d61004f4510c59f1f392 (patch)
treeb3a75baf61f97d601d2e4d7cf79c8399b902d9bf /builtin-read-tree.c
parent8ebe185bbf3f1f4f59bcc61e3d1849a76f6af983 (diff)
downloadgit-f8a9d4287277ed15d3f0d61004f4510c59f1f392.tar.gz
read-tree: further loosen "working file will be lost" check.
This follows up commit ed93b449 where we removed overcautious "working file will be lost" check. A new option "--exclude-per-directory=.gitignore" can be used to tell the "git-read-tree" command that the user does not mind losing contents in untracked files in the working tree, if they need to be overwritten by a merge (either a two-way "switch branches" merge, or a three-way merge). Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-read-tree.c')
-rw-r--r--builtin-read-tree.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index c1867d2a00..3f6cae36ce 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -10,6 +10,7 @@
#include "tree-walk.h"
#include "cache-tree.h"
#include "unpack-trees.h"
+#include "dir.h"
#include "builtin.h"
static struct object_list *trees;
@@ -178,6 +179,23 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
continue;
}
+ if (!strncmp(arg, "--exclude-per-directory=", 24)) {
+ 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);
@@ -190,6 +208,8 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix)
}
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);