[PATCH 2/7] lock_ref_sha1_basic(): remember the original name of a ref when resolving it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 refs.c |    2 ++
 refs.h |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/refs.c b/refs.c
index 9395677..9641fad 100644
--- a/refs.c
+++ b/refs.c
@@ -676,6 +676,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;
 
@@ -915,6 +916,7 @@ void unlock_ref(struct ref_lock *lock)
 			rollback_lock_file(lock->lk);
 	}
 	free(lock->ref_name);
+	free(lock->orig_ref_name);
 	free(lock);
 }
 
diff --git a/refs.h b/refs.h
index 2d2ba14..94a58b4 100644
--- a/refs.h
+++ b/refs.h
@@ -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;
-- 
1.5.0.rc2.g6e2c

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]