git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/3] rename_ref(): handle the case when the reflog of a ref does not exist

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Oct 27, 2008, 19:50 UTC
Message-ID
<5eea93aa5f6d35405eafee4fd022dc9f0b5d75b6.1225136865.git.vmiklos@frugalware.org>
In-Reply-To
<a18363084130c4c23279667f6f0bd26d585a061d.1225136865.git.vmiklos@frugalware.org>

We tried to check if a reflog of a ref is a symlink without first checking if it exists, which is a bug.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 refs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/refs.c b/refs.c
index 31a2057..116eb59 100644
--- a/refs.c
+++ b/refs.c
@@ -974,7 +974,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
 	int log = !lstat(git_path("logs/%s", oldref), &loginfo);
 	const char *symref = NULL;
 
-	if (S_ISLNK(loginfo.st_mode))
+	if (log && S_ISLNK(loginfo.st_mode))
 		return error("reflog for %s is a symlink", oldref);
 
 	symref = resolve_ref(oldref, orig_sha1, 1, &flag);
-- 
1.6.0.2
Previous: Miklos VajnaNext: Miklos Vajna
Message 3 of 6 in “symref rename/delete fixes”
  1. 0/3 symref rename/delete fixesMiklos Vajna, Oct 27, 2008
  2. 1/3 Disallow git branch -m for symrefs.Miklos Vajna, Oct 27, 2008
  3. 2/3 rename_ref(): handle the case when the reflog of a ref does not existMiklos Vajna, Oct 27, 2008
  4. 3/3 Fix git update-ref --no-deref -d.Miklos Vajna, Oct 27, 2008
  5. Miklos VajnaOct 28, 2008
  6. git branch -m: forbid renaming of a symrefMiklos Vajna, Oct 29, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.