merge: add scissors line on merge conflict
[gitweb.git] / builtin / checkout.c
index bea08ef959189cff99e34170a2999a52953a3020..f95e7975f7e970cf205c9e97c25296324477f249 100644 (file)
@@ -325,6 +325,8 @@ static int checkout_paths(const struct checkout_opts *opts,
        struct lock_file lock_file = LOCK_INIT;
        int nr_checkouts = 0, nr_unmerged = 0;
 
+       trace2_cmd_mode(opts->patch_mode ? "patch" : "path");
+
        if (opts->track != BRANCH_TRACK_UNSPECIFIED)
                die(_("'%s' cannot be used with updating paths"), "--track");
 
@@ -724,6 +726,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
                        struct tree *result;
                        struct tree *work;
                        struct merge_options o;
+                       struct strbuf sb = STRBUF_INIT;
+
                        if (!opts->merge)
                                return 1;
 
@@ -734,6 +738,13 @@ static int merge_working_tree(const struct checkout_opts *opts,
                        if (!old_branch_info->commit)
                                return 1;
 
+                       if (repo_index_has_changes(the_repository,
+                                                  get_commit_tree(old_branch_info->commit),
+                                                  &sb))
+                               warning(_("staged changes in the following files may be lost: %s"),
+                                       sb.buf);
+                       strbuf_release(&sb);
+
                        /* Do more real merge */
 
                        /*
@@ -1014,6 +1025,9 @@ static int switch_branches(const struct checkout_opts *opts,
        void *path_to_free;
        struct object_id rev;
        int flag, writeout_error = 0;
+
+       trace2_cmd_mode("branch");
+
        memset(&old_branch_info, 0, sizeof(old_branch_info));
        old_branch_info.path = path_to_free = resolve_refdup("HEAD", 0, &rev, &flag);
        if (old_branch_info.path)
@@ -1251,6 +1265,8 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts)
        int status;
        struct strbuf branch_ref = STRBUF_INIT;
 
+       trace2_cmd_mode("unborn");
+
        if (!opts->new_branch)
                die(_("You are on a branch yet to be born"));
        strbuf_addf(&branch_ref, "refs/heads/%s", opts->new_branch);