{"thread":{"id":"43242","subject":"[PATCH] rename_ref: use lstat(2) when testing for symlink","startedAt":"2006-11-29T20:44:56Z","lastAt":"2006-11-29T20:44:56Z","messageCount":1,"participants":["Lars Hjemli"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"294122","messageId":"11648330963464-git-send-email-hjemli@gmail.com","threadId":"43242","inReplyTo":null,"subject":"[PATCH] rename_ref: use lstat(2) when testing for symlink","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2006-11-29T20:44:56Z","receivedAt":"2006-11-29T20:44:56Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"The current check for symlinked reflogs was based on stat(2), which is\nutterly embarrassing.\n\nFix it, and add a matching testcase.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nThis is on top of my previous [RFC], which is kind of strange, but I hope \nit wasn't dropped on the floor...\n\n refs.c            |    2 +-\n t/t3200-branch.sh |    7 +++++++\n 2 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 479f18c..d8c19e6 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -792,7 +792,7 @@ int rename_ref(const char *oldref, const char *newref)\n \tstruct ref_lock *lock;\n \tchar msg[PATH_MAX*2 + 100];\n \tstruct stat loginfo;\n-\tint log = !stat(git_path(\"logs/%s\", oldref), &loginfo);\n+\tint log = !lstat(git_path(\"logs/%s\", oldref), &loginfo);\n \n \tif (S_ISLNK(loginfo.st_mode))\n \t\treturn error(\"reflog for %s is a symlink\", oldref);\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex afaa853..5782c30 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -104,4 +104,11 @@ test_expect_success \\\n         git-branch -m s/s s &&\n         test -f .git/logs/refs/heads/s'\n \n+test_expect_failure \\\n+    'git-branch -m u v should fail when the reflog for u is a symlink' \\\n+    'git-branch -l u &&\n+     mv .git/logs/refs/heads/u real-u &&\n+     ln -s real-u .git/logs/refs/heads/u &&\n+     git-branch -m u v'\n+\n test_done\n-- \n1.4.4.1.gf0df\n"}]}