diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-02-27 13:57:18 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-02-27 13:57:18 -0800 |
commit | c13c783c9d3d7d3eff937b7bf3642d2a7fe32644 (patch) | |
tree | c650be76225f1b73aa5df51bcba519c532ebf437 /builtin/branch.c | |
parent | Merge branch 'jk/tempfile-ferror-fclose-confusion' (diff) | |
parent | branch: record creation of renamed branch in HEAD's log (diff) | |
download | tgif-c13c783c9d3d7d3eff937b7bf3642d2a7fe32644.tar.xz |
Merge branch 'km/delete-ref-reflog-message'
"git update-ref -d" and other operations to delete references did
not leave any entry in HEAD's reflog when the reference being
deleted was the current branch. This is not a problem in practice
because you do not want to delete the branch you are currently on,
but caused renaming of the current branch to something else not to
be logged in a useful way.
* km/delete-ref-reflog-message:
branch: record creation of renamed branch in HEAD's log
rename_ref: replace empty message in HEAD's log
update-ref: pass reflog message to delete_ref()
delete_ref: accept a reflog message argument
Diffstat (limited to 'builtin/branch.c')
-rw-r--r-- | builtin/branch.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/builtin/branch.c b/builtin/branch.c index cbaa6d03c0..94f7de7fa5 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -252,7 +252,7 @@ static int delete_branches(int argc, const char **argv, int force, int kinds, goto next; } - if (delete_ref(name, is_null_sha1(sha1) ? NULL : sha1, + if (delete_ref(NULL, name, is_null_sha1(sha1) ? NULL : sha1, REF_NODEREF)) { error(remote_branch ? _("Error deleting remote-tracking branch '%s'") @@ -471,14 +471,15 @@ static void rename_branch(const char *oldname, const char *newname, int force) if (rename_ref(oldref.buf, newref.buf, logmsg.buf)) die(_("Branch rename failed")); - strbuf_release(&logmsg); if (recovery) warning(_("Renamed a misnamed branch '%s' away"), oldref.buf + 11); - if (replace_each_worktree_head_symref(oldref.buf, newref.buf)) + if (replace_each_worktree_head_symref(oldref.buf, newref.buf, logmsg.buf)) die(_("Branch renamed to %s, but HEAD is not updated!"), newname); + strbuf_release(&logmsg); + strbuf_addf(&oldsection, "branch.%s", oldref.buf + 11); strbuf_release(&oldref); strbuf_addf(&newsection, "branch.%s", newref.buf + 11); |