summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 16c2bfb)
raw | patch | inline | side by side (parent: 16c2bfb)
author | Lars Hjemli <hjemli@gmail.com> | |
Thu, 30 Nov 2006 02:16:56 +0000 (03:16 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 6 Dec 2006 07:50:57 +0000 (23:50 -0800) |
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>
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>
builtin-branch.c | patch | blob | history | |
refs.c | patch | blob | history | |
refs.h | patch | blob | history |
diff --git a/builtin-branch.c b/builtin-branch.c
index 153682601e2f77514edab0e6ba9d3077cd3114e7..3fc6f84773268379d355c69c0a32d4d9c4b0f630 100644 (file)
--- a/builtin-branch.c
+++ b/builtin-branch.c
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))
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))
int kinds = REF_LOCAL_BRANCH;
int i;
+ setup_ident();
git_config(git_default_config);
for (i = 1; i < argc; i++) {
index c23561e1582980e01c827540de0e0a43bf2547d3..2ac8273ea475ebf169f86840587d48bf1e1b8a91 100644 (file)
--- a/refs.c
+++ b/refs.c
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);
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")))
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;
}
index ce73d5c7ae394c012f828536dd4df8b143819718..51aab1e6bf592ed6412289695d6fe33e5140fab2 100644 (file)
--- a/refs.h
+++ b/refs.h
extern int check_ref_format(const char *target);
/** rename ref, return 0 on success **/
-extern int rename_ref(const char *oldref, const char *newref);
+extern int rename_ref(const char *oldref, const char *newref, const char *logmsg);
#endif /* REFS_H */