aboutsummaryrefslogtreecommitdiff
path: root/builtin-branch.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2006-11-30 03:16:56 +0100
committerJunio C Hamano <junkio@cox.net>2006-12-05 23:50:57 -0800
commit678d0f4cbfa7a3b529c6e894f2977bef6a2d3e4c (patch)
tree0c7ce12b8e862fe96eb570d593509b3391d0fc0f /builtin-branch.c
parent16c2bfbb449a90db00a46984d7dd7f735caa1d56 (diff)
downloadgit-678d0f4cbfa7a3b529c6e894f2977bef6a2d3e4c.tar.gz
git-678d0f4cbfa7a3b529c6e894f2977bef6a2d3e4c.tar.xz
git-branch: let caller specify logmsg
This changes the signature of rename_ref() in refs.[hc] to include a logmessage for the reflogs. Also, builtin-branch.c is modified to provide a proper logmessage + call setup_ident() before any logmessages are written. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-branch.c')
-rw-r--r--builtin-branch.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/builtin-branch.c b/builtin-branch.c
index 153682601..3fc6f8477 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -247,7 +247,7 @@ static void create_branch(const char *name, const char *start,
static void rename_branch(const char *oldname, const char *newname, int force)
{
- char oldref[PATH_MAX], newref[PATH_MAX];
+ char oldref[PATH_MAX], newref[PATH_MAX], logmsg[PATH_MAX*2 + 100];
unsigned char sha1[20];
if (snprintf(oldref, sizeof(oldref), "refs/heads/%s", oldname) > sizeof(oldref))
@@ -265,7 +265,10 @@ static void rename_branch(const char *oldname, const char *newname, int force)
if (resolve_ref(newref, sha1, 1, NULL) && !force)
die("A branch named '%s' already exists.", newname);
- if (rename_ref(oldref, newref))
+ snprintf(logmsg, sizeof(logmsg), "Branch: renamed %s to %s",
+ oldref, newref);
+
+ if (rename_ref(oldref, newref, logmsg))
die("Branch rename failed");
if (!strcmp(oldname, head) && create_symref("HEAD", newref))
@@ -281,6 +284,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
int kinds = REF_LOCAL_BRANCH;
int i;
+ setup_ident();
git_config(git_default_config);
for (i = 1; i < argc; i++) {