diff options
author | Nicolas Pitre <nico@cam.org> | 2007-01-26 17:26:10 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-01-28 02:16:46 -0800 |
commit | 8b5157e40718a2ee1d645c342d93df4e66335479 (patch) | |
tree | 3e81ee8c1e122f82254cb8775076dad36c6fcd76 /refs.c | |
parent | 41b625b047ad5c537ca312d2f07c86bdd783a7b0 (diff) | |
download | git-8b5157e40718a2ee1d645c342d93df4e66335479.tar.gz |
add logref support to git-symbolic-ref
Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -986,18 +986,23 @@ int write_ref_sha1(struct ref_lock *lock, return 0; } -int create_symref(const char *ref_target, const char *refs_heads_master) +int create_symref(const char *ref_target, const char *refs_heads_master, + const char *logmsg) { const char *lockpath; char ref[1000]; int fd, len, written; const char *git_HEAD = git_path("%s", ref_target); + unsigned char old_sha1[20], new_sha1[20]; + + if (logmsg && read_ref(ref_target, old_sha1)) + hashclr(old_sha1); #ifndef NO_SYMLINK_HEAD if (prefer_symlink_refs) { unlink(git_HEAD); if (!symlink(refs_heads_master, git_HEAD)) - return 0; + goto done; fprintf(stderr, "no symlink - falling back to symbolic ref\n"); } #endif @@ -1030,6 +1035,11 @@ int create_symref(const char *ref_target, const char *refs_heads_master) error("Unable to fix permissions on %s", lockpath); return -4; } + + done: + if (logmsg && !read_ref(refs_heads_master, new_sha1)) + log_ref_write(ref_target, old_sha1, new_sha1, logmsg); + return 0; } |