]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/checkout.c
Merge branch 'gc/branch-recurse-submodules'
[thirdparty/git.git] / builtin / checkout.c
index 94814c37b4321ca891927d9b325ee6806c494595..2b33960e2167a8269beba1cc1d065ecab27aafe9 100644 (file)
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "diff.h"
 #include "dir.h"
+#include "hook.h"
 #include "ll-merge.h"
 #include "lockfile.h"
 #include "merge-recursive.h"
@@ -114,7 +115,7 @@ static void branch_info_release(struct branch_info *info)
 static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit,
                              int changed)
 {
-       return run_hook_le(NULL, "post-checkout",
+       return run_hooks_l("post-checkout",
                           oid_to_hex(old_commit ? &old_commit->object.oid : null_oid()),
                           oid_to_hex(new_commit ? &new_commit->object.oid : null_oid()),
                           changed ? "1" : "0", NULL);
@@ -245,6 +246,7 @@ static int checkout_merged(int pos, const struct checkout *state,
        struct cache_entry *ce = active_cache[pos];
        const char *path = ce->name;
        mmfile_t ancestor, ours, theirs;
+       enum ll_merge_result merge_status;
        int status;
        struct object_id oid;
        mmbuffer_t result_buf;
@@ -275,13 +277,16 @@ static int checkout_merged(int pos, const struct checkout *state,
        memset(&ll_opts, 0, sizeof(ll_opts));
        git_config_get_bool("merge.renormalize", &renormalize);
        ll_opts.renormalize = renormalize;
-       status = ll_merge(&result_buf, path, &ancestor, "base",
-                         &ours, "ours", &theirs, "theirs",
-                         state->istate, &ll_opts);
+       merge_status = ll_merge(&result_buf, path, &ancestor, "base",
+                               &ours, "ours", &theirs, "theirs",
+                               state->istate, &ll_opts);
        free(ancestor.ptr);
        free(ours.ptr);
        free(theirs.ptr);
-       if (status < 0 || !result_buf.ptr) {
+       if (merge_status == LL_MERGE_BINARY_CONFLICT)
+               warning("Cannot merge binary files: %s (%s vs. %s)",
+                       path, "ours", "theirs");
+       if (merge_status < 0 || !result_buf.ptr) {
                free(result_buf.ptr);
                return error(_("path '%s': cannot merge"), path);
        }
@@ -904,7 +909,8 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
                                      opts->new_branch_force ? 1 : 0,
                                      opts->new_branch_log,
                                      opts->quiet,
-                                     opts->track);
+                                     opts->track,
+                                     0);
                free(new_branch_info->name);
                free(new_branch_info->refname);
                new_branch_info->name = xstrdup(opts->new_branch);
@@ -1094,9 +1100,6 @@ static int switch_branches(const struct checkout_opts *opts,
                const char *p;
                if (skip_prefix(old_branch_info.path, prefix, &p))
                        old_branch_info.name = xstrdup(p);
-               else
-                       BUG("should be able to skip past '%s' in '%s'!",
-                           prefix, old_branch_info.path);
        }
 
        if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
@@ -1549,9 +1552,9 @@ static struct option *add_common_switch_branch_options(
 {
        struct option options[] = {
                OPT_BOOL('d', "detach", &opts->force_detach, N_("detach HEAD at named commit")),
-               OPT_CALLBACK_F('t', "track",  &opts->track, "direct|inherit",
-                       N_("set up tracking mode (see git-pull(1))"),
-                       PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP,
+               OPT_CALLBACK_F('t', "track",  &opts->track, "(direct|inherit)",
+                       N_("set branch tracking configuration"),
+                       PARSE_OPT_OPTARG,
                        parse_opt_tracking_mode),
                OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"),
                           PARSE_OPT_NOCOMPLETE),