enable separate reflog for HEAD
If HEAD is tied to a branch then both logs/HEAD and logs/heads/<branch> are updated. This is also true for any symbolic refs in general, but only HEAD will see its reflog created automatically. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Nicolas Pitre committed
Jan 26, 2007 at 17:26 UTC
bd104db164d7f2a714aa0f1cdf89fd89fee6c00a
1 file changed
+5
-2
refs.c
+5
-2
@@ -940,7 +940,8 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,
940
941
if (log_all_ref_updates &&
942
(!strncmp(ref_name, "refs/heads/", 11) ||
943
- !strncmp(ref_name, "refs/remotes/", 13))) {
943
+ !strncmp(ref_name, "refs/remotes/", 13) ||
944
+ !strcmp(ref_name, "HEAD"))) {
945
if (safe_create_leading_directories(log_file) < 0)
946
return error("unable to create directory for %s",
947
log_file);
@@ -1016,7 +1017,9 @@ int write_ref_sha1(struct ref_lock *lock,
1017
return -1;
1018
}
1019
invalidate_cached_refs();
1019
- if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0) {
1020
+ if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
1021
+ (strcmp(lock->ref_name, lock->orig_ref_name) &&
1022
+ log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
1023
unlock_ref(lock);
1024
return -1;
1025
}