{"thread":{"id":"17044","subject":"[PATCH] Support ref logs for refs/*","startedAt":"2009-01-08T08:28:27Z","lastAt":"2009-01-08T16:52:40Z","messageCount":3,"participants":["Neil Macneale","Nanako Shiraishi","mac4-git@theory.org"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"99683","messageId":"20090108082827.GA6177@tesla.theory.org","threadId":"17044","inReplyTo":null,"subject":"[PATCH] Support ref logs for refs/*","fromName":"Neil Macneale","fromEmail":"mac4-git@theory.org","sentAt":"2009-01-08T08:28:27Z","receivedAt":"2009-01-08T08:28:27Z","isPatch":true,"sender":{"key":"mac4-git@theory.org","avatar":null},"body":"The documentation for git update-ref seems to imply that logging of ref\nupdates should be done for anything in refs/, though the code looks like it\nrestricts changes to heads and remotes. Any reason not so support arbitrary\nrefs?\n\nI don't see much point in logging for tags, so the patch ignores refs/tags.\n\nThanks,\nNeil\n\nSigned-off-by: Neil Macneale <mac4-git@theory.org>\n---\n refs.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 33ced65..cfff22b 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -1154,9 +1154,9 @@ static int log_ref_write(const char *ref_name, const\nunsigned char *old_sha1,\n        git_snpath(log_file, sizeof(log_file), \"logs/%s\", ref_name);\n \n        if (log_all_ref_updates &&\n-           (!prefixcmp(ref_name, \"refs/heads/\") ||\n-            !prefixcmp(ref_name, \"refs/remotes/\") ||\n-            !strcmp(ref_name, \"HEAD\"))) {\n+           (!prefixcmp(ref_name, \"refs/\") ||\n+            !strcmp(ref_name, \"HEAD\")) &&\n+           prefixcmp(ref_name, \"refs/tags/\")) {\n                if (safe_create_leading_directories(log_file) < 0)\n                        return error(\"unable to create directory for %s\",\n                                     log_file);\n-- \n1.6.1.141.gfe98e.dirty\n"},{"id":"99686","messageId":"20090108180857.6117@nanako3.lavabit.com","threadId":"17044","inReplyTo":"20090108082827.GA6177@tesla.theory.org","subject":"Re: [PATCH] Support ref logs for refs/*","fromName":"Nanako Shiraishi","fromEmail":"nanako3@lavabit.com","sentAt":"2009-01-08T09:08:57Z","receivedAt":"2009-01-08T09:08:57Z","isPatch":true,"sender":{"key":"nanako3@lavabit.com","avatar":"https://gravatar.com/avatar/3777b9e201c5883a62b1a6fdf7c53f2d712d1d80989146063ea861e33aad72a8?d=mp&s=160"},"body":"Quoting Neil Macneale <mac4-git@theory.org>:\n\n> The documentation for git update-ref seems to imply that logging of ref\n> updates should be done for anything in refs/...\n\nThe documementation for git-update-ref is part of git, and git does not use anything outside of refs/{heads,tags,remotes}/ for its normal operation. \n\nI think it is generally assumed that there is nothing of interest outside of these areas that deserves the automated creation of reflogs, and the code you are touching is about that. Once you have reflog for any ref you are interested outside of these areas, your actions will be logged regardless. \n\nMost notably, refs/stash itself is exempt from this code path and it makes sure that reflog exists without relying on log_all_ref_updates configuration. \n\nAlso the documentation for the configuration variable explicitly says it is about the branch heads.\n\ncore.logAllRefUpdates::\n\tEnable the reflog. Updates to a ref <ref> is logged to the file\n\t\"$GIT_DIR/logs/<ref>\", by appending the new and old\n\tSHA1, the date/time and the reason of the update, but\n\tonly when the file exists.  If this configuration\n\tvariable is set to true, missing \"$GIT_DIR/logs/<ref>\"\n\tfile is automatically created for branch heads.\n\n-- \nNanako Shiraishi\nhttp://ivory.ap.teacup.com/nanako3/\n"},{"id":"99715","messageId":"20090108165240.GA22815@tesla.theory.org","threadId":"17044","inReplyTo":"20090108180857.6117@nanako3.lavabit.com","subject":"Re: [PATCH] Support ref logs for refs/*","fromName":"","fromEmail":"mac4-git@theory.org","sentAt":"2009-01-08T16:52:40Z","receivedAt":"2009-01-08T16:52:40Z","isPatch":true,"sender":{"key":"mac4-git@theory.org","avatar":null},"body":"On Thursday, January 08, 2009, the wise Nanako Shiraishi wrote:\n>Quoting Neil Macneale <mac4-git@theory.org>:\n>\n>> The documentation for git update-ref seems to imply that logging of ref\n>> updates should be done for anything in refs/...\n>\n>The documementation for git-update-ref is part of git, and git does not use anything outside of refs/{heads,tags,remotes}/ for its normal operation. \n>\n>I think it is generally assumed that there is nothing of interest outside of these areas that deserves the automated creation of reflogs, and the code you are touching is about that. Once you have reflog for any ref you are interested outside of these areas, your actions will be logged regardless. \n\nWhy is that generally assumed? I can fetch to arbitrary refs and git prune\ndoesn't clean objects references from argitrary refs, so it seems like\nthere is implicit support for these references. A little extra logging\nnever hurt anyone.\n\n>Most notably, refs/stash itself is exempt from this code path and it makes sure that reflog exists without relying on log_all_ref_updates configuration. \n\nWhy not? I'd like like have logs for stash actions. Makes the case when\nsomeone runs git stash clear by mistake a little easier to recover from.\n\nThe alternative is for me to touch a file in .git/logs/refs prior to any\nuse of git update-ref.  It seems like most git commands go to great\nlengths to prevent you from ever needing to get into the .git dir, so maybe\nan alternative would be an option to force git update-ref to create a log\nfile automatically. I thought thats what the \"all\" in core.logallrefupdates\nmeant. Silly me. \n\nA command line option for git update-ref is not ideal because when I run\ngit fetch remote refs/whatever:refs/whatever, I still want a log entry. \nThus, I still need to be mucking with the .git dir when I shouldn't need\nto.\n\nWhats the harm in a little more logging? The space wasted is pretty much\nnothing. I'd much rather be able to look at a ref log in the event that I\nmess somthing up than run git fsck.\n\nCheers,\nNeil\n\n>\n>-- \n>Nanako Shiraishi\n>http://ivory.ap.teacup.com/nanako3/\n>\n>--\n>To unsubscribe from this list: send the line \"unsubscribe git\" in\n>the body of a message to majordomo@vger.kernel.org\n>More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"}]}