Skip to content

Commit

Permalink
enable separate reflog for HEAD
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nicolas Pitre authored and Junio C Hamano committed Jan 28, 2007
1 parent 1655707 commit bd104db
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,8 @@ static int log_ref_write(const char *ref_name, const unsigned char *old_sha1,

if (log_all_ref_updates &&
(!strncmp(ref_name, "refs/heads/", 11) ||
!strncmp(ref_name, "refs/remotes/", 13))) {
!strncmp(ref_name, "refs/remotes/", 13) ||
!strcmp(ref_name, "HEAD"))) {
if (safe_create_leading_directories(log_file) < 0)
return error("unable to create directory for %s",
log_file);
Expand Down Expand Up @@ -1016,7 +1017,9 @@ int write_ref_sha1(struct ref_lock *lock,
return -1;
}
invalidate_cached_refs();
if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0) {
if (log_ref_write(lock->ref_name, lock->old_sha1, sha1, logmsg) < 0 ||
(strcmp(lock->ref_name, lock->orig_ref_name) &&
log_ref_write(lock->orig_ref_name, lock->old_sha1, sha1, logmsg) < 0)) {
unlock_ref(lock);
return -1;
}
Expand Down

0 comments on commit bd104db

Please sign in to comment.