l10n: git.pot: v2.7.0 round 2 (2 new, 2 removed)
[gitweb.git] / branch.c
index e283683d9d2c5a587f6c3fc54256d67cc9c6c36b..7ff3f204964127374ae2a337819ce0bce7be9ab2 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -4,6 +4,7 @@
 #include "refs.h"
 #include "remote.h"
 #include "commit.h"
+#include "worktree.h"
 
 struct tracking {
        struct refspec spec;
@@ -266,7 +267,7 @@ void create_branch(const char *head,
 
        if ((commit = lookup_commit_reference(sha1)) == NULL)
                die(_("Not a valid branch point: '%s'."), start_name);
-       hashcpy(sha1, commit->object.sha1);
+       hashcpy(sha1, commit->object.oid.hash);
 
        if (forcing)
                snprintf(msg, sizeof msg, "branch: Reset to %s",
@@ -310,3 +311,14 @@ void remove_branch_state(void)
        unlink(git_path_merge_mode());
        unlink(git_path_squash_msg());
 }
+
+void die_if_checked_out(const char *branch)
+{
+       char *existing;
+
+       existing = find_shared_symref("HEAD", branch);
+       if (existing) {
+               skip_prefix(branch, "refs/heads/", &branch);
+               die(_("'%s' is already checked out at '%s'"), branch, existing);
+       }
+}