Merge branch 'rs/xdiff-merge-overlapping-hunks-for-W-context' into maint
[gitweb.git] / builtin / branch.c
index 2ecde53bf838777e191926557c0c8190cdc7d09a..7df05437f11f76fb3a6c2c879fbb88fb63e71eac 100644 (file)
@@ -212,7 +212,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                        die(_("Couldn't look up commit object for HEAD"));
        }
        for (i = 0; i < argc; i++, strbuf_release(&bname)) {
-               const char *target;
+               char *target = NULL;
                int flags = 0;
 
                strbuf_branchname(&bname, argv[i]);
@@ -231,11 +231,11 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                        }
                }
 
-               target = resolve_ref_unsafe(name,
-                                           RESOLVE_REF_READING
-                                           | RESOLVE_REF_NO_RECURSE
-                                           | RESOLVE_REF_ALLOW_BAD_NAME,
-                                           sha1, &flags);
+               target = resolve_refdup(name,
+                                       RESOLVE_REF_READING
+                                       | RESOLVE_REF_NO_RECURSE
+                                       | RESOLVE_REF_ALLOW_BAD_NAME,
+                                       sha1, &flags);
                if (!target) {
                        error(remote_branch
                              ? _("remote-tracking branch '%s' not found.")
@@ -248,7 +248,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                    check_branch_commit(bname.buf, name, sha1, head_rev, kinds,
                                        force)) {
                        ret = 1;
-                       continue;
+                       goto next;
                }
 
                if (delete_ref(name, is_null_sha1(sha1) ? NULL : sha1,
@@ -258,7 +258,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                              : _("Error deleting branch '%s'"),
                              bname.buf);
                        ret = 1;
-                       continue;
+                       goto next;
                }
                if (!quiet) {
                        printf(remote_branch
@@ -270,6 +270,9 @@ static int delete_branches(int argc, const char **argv, int force, int kinds,
                               : find_unique_abbrev(sha1, DEFAULT_ABBREV));
                }
                delete_branch_config(bname.buf);
+
+       next:
+               free(target);
        }
 
        free(name);
@@ -614,14 +617,11 @@ static int edit_branch_description(const char *branch_name)
        if (!buf.len || buf.buf[buf.len-1] != '\n')
                strbuf_addch(&buf, '\n');
        strbuf_commented_addf(&buf,
-                   "Please edit the description for the branch\n"
-                   "  %s\n"
-                   "Lines starting with '%c' will be stripped.\n",
+                   _("Please edit the description for the branch\n"
+                     "  %s\n"
+                     "Lines starting with '%c' will be stripped.\n"),
                    branch_name, comment_line_char);
-       if (write_file_gently(git_path(edit_description), "%s", buf.buf)) {
-               strbuf_release(&buf);
-               return error_errno(_("could not write branch description template"));
-       }
+       write_file_buf(git_path(edit_description), buf.buf, buf.len);
        strbuf_reset(&buf);
        if (launch_editor(git_path(edit_description), &buf, NULL)) {
                strbuf_release(&buf);