Skip to content

Commit

Permalink
lock_ref_sha1_basic(): remember the original name of a ref when resol…
Browse files Browse the repository at this point in the history
…ving it

A ref might be pointing to another ref but only the name of the last ref
is remembered.  Let's remember about the first name as well.

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 9a13f0b commit 1655707
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *ref, const unsigned char
lock->lk = xcalloc(1, sizeof(struct lock_file));

lock->ref_name = xstrdup(ref);
lock->orig_ref_name = xstrdup(orig_ref);
ref_file = git_path("%s", ref);
lock->force_write = lstat(ref_file, &st) && errno == ENOENT;

Expand Down Expand Up @@ -919,6 +920,7 @@ void unlock_ref(struct ref_lock *lock)
rollback_lock_file(lock->lk);
}
free(lock->ref_name);
free(lock->orig_ref_name);
free(lock);
}

Expand Down
1 change: 1 addition & 0 deletions refs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

struct ref_lock {
char *ref_name;
char *orig_ref_name;
struct lock_file *lk;
unsigned char old_sha1[20];
int lock_fd;
Expand Down

0 comments on commit 1655707

Please sign in to comment.