Code

Merge branch 'cb/ignored-paths-are-precious' into pu
[git.git] / builtin / checkout.c
index d3cfaf0f45cea2c27dd8d7caf47ac43cd499c79e..0ca8f6a2061b177410136fb89b988806a05eb16e 100644 (file)
@@ -399,9 +399,11 @@ static int merge_working_tree(struct checkout_opts *opts,
                topts.gently = opts->merge && old->commit;
                topts.verbose_update = !opts->quiet;
                topts.fn = twoway_merge;
-               topts.dir = xcalloc(1, sizeof(*topts.dir));
-               topts.dir->flags |= DIR_SHOW_IGNORED;
-               topts.dir->exclude_per_dir = ".gitignore";
+               if (!ignored_are_precious) {
+                       topts.dir = xcalloc(1, sizeof(*topts.dir));
+                       topts.dir->flags |= DIR_SHOW_IGNORED;
+                       topts.dir->exclude_per_dir = ".gitignore";
+               }
                tree = parse_tree_indirect(old->commit ?
                                           old->commit->object.sha1 :
                                           (unsigned char *)EMPTY_TREE_SHA1_BIN);
@@ -700,6 +702,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
                OPT_SET_INT('3', "theirs", &opts.writeout_stage, "checkout their version for unmerged files",
                            3),
                OPT__FORCE(&opts.force, "force checkout (throw away local modifications)"),
+               OPT_BOOLEAN('i', "ignored-are-precious", &ignored_are_precious,
+                 "fail when an ignored file needs to be overwritten"),
                OPT_BOOLEAN('m', "merge", &opts.merge, "perform a 3-way merge with the new branch"),
                OPT_STRING(0, "conflict", &conflict_style, "style",
                           "conflict style (merge or diff3)"),