summaryrefslogtreecommitdiff
path: root/refs.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2006-11-30 02:16:56 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-12-06 07:50:57 (GMT)
commit678d0f4cbfa7a3b529c6e894f2977bef6a2d3e4c (patch)
tree0c7ce12b8e862fe96eb570d593509b3391d0fc0f /refs.c
parent16c2bfbb449a90db00a46984d7dd7f735caa1d56 (diff)
downloadgit-678d0f4cbfa7a3b529c6e894f2977bef6a2d3e4c.zip
git-678d0f4cbfa7a3b529c6e894f2977bef6a2d3e4c.tar.gz
git-678d0f4cbfa7a3b529c6e894f2977bef6a2d3e4c.tar.bz2
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 'refs.c')
-rw-r--r--refs.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/refs.c b/refs.c
index c23561e..2ac8273 100644
--- a/refs.c
+++ b/refs.c
@@ -784,13 +784,12 @@ int delete_ref(const char *refname, unsigned char *sha1)
return ret;
}
-int rename_ref(const char *oldref, const char *newref)
+int rename_ref(const char *oldref, const char *newref, const char *logmsg)
{
static const char renamed_ref[] = "RENAMED-REF";
unsigned char sha1[20], orig_sha1[20];
int flag = 0, logmoved = 0;
struct ref_lock *lock;
- char msg[PATH_MAX*2 + 100];
struct stat loginfo;
int log = !lstat(git_path("logs/%s", oldref), &loginfo);
@@ -806,14 +805,11 @@ int rename_ref(const char *oldref, const char *newref)
if (!is_refname_available(newref, oldref, get_loose_refs(), 0))
return 1;
- if (snprintf(msg, sizeof(msg), "renamed %s to %s", oldref, newref) > sizeof(msg))
- return error("Refnames to long");
-
lock = lock_ref_sha1_basic(renamed_ref, NULL, NULL);
if (!lock)
return error("unable to lock %s", renamed_ref);
lock->force_write = 1;
- if (write_ref_sha1(lock, orig_sha1, msg))
+ if (write_ref_sha1(lock, orig_sha1, logmsg))
return error("unable to save current sha1 in %s", renamed_ref);
if (log && rename(git_path("logs/%s", oldref), git_path("tmp-renamed-log")))
@@ -866,7 +862,7 @@ int rename_ref(const char *oldref, const char *newref)
lock->force_write = 1;
hashcpy(lock->old_sha1, orig_sha1);
- if (write_ref_sha1(lock, orig_sha1, msg)) {
+ if (write_ref_sha1(lock, orig_sha1, logmsg)) {
error("unable to write current sha1 into %s", newref);
goto rollback;
}