{"thread":{"id":"17034","subject":"[RFC/PATCH 1/3] refs: add a \"for_each_replace_ref\" function","startedAt":"2009-01-07T07:43:07Z","lastAt":"2009-01-07T07:43:07Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"99554","messageId":"20090107084307.21100bb5.chriscool@tuxfamily.org","threadId":"17034","inReplyTo":null,"subject":"[RFC/PATCH 1/3] refs: add a \"for_each_replace_ref\" function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-01-07T07:43:07Z","receivedAt":"2009-01-07T07:43:07Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This is some preparation work for the following patches that are using\nthe \"refs/replace/\" ref namespace.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n refs.c |    5 +++++\n refs.h |    1 +\n 2 files changed, 6 insertions(+), 0 deletions(-)\n\n\tJunio wrote:\n\n\t> What I thought we\n\t> discussed during GitTogether was to write out the object name of the\n\t> replacement object in refs/replace/<sha1>.\n\t>\n\t> When the caller asks read_sha1_file() for an object whose object name is\n\t> <sha1>, you see if there is refs/replace/<sha1> in the repository, and\n\t> read the ref to learn the object name of the object that replaces it. \n\t> And you return that as if it is the original object.\n\t\n\tPatch 2/3 in this series implements the new mechanism. As you can see I\n\tprefered it to be called when reading parent commits than from\n\t\"read_sha1_file\", because it seems to simplify things. I hope you still like\n\tit.\n\n\tRegards,\n\tChristian.\n\ndiff --git a/refs.c b/refs.c\nindex 33ced65..042106d 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -632,6 +632,11 @@ int for_each_remote_ref(each_ref_fn fn, void *cb_data)\n \treturn do_for_each_ref(\"refs/remotes/\", fn, 13, cb_data);\n }\n \n+int for_each_replace_ref(each_ref_fn fn, void *cb_data)\n+{\n+\treturn do_for_each_ref(\"refs/replace/\", fn, 13, cb_data);\n+}\n+\n /*\n  * Make sure \"ref\" is something reasonable to have under \".git/refs/\";\n  * We do not like it if:\ndiff --git a/refs.h b/refs.h\nindex 06ad260..8d2ee5a 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -23,6 +23,7 @@ extern int for_each_ref(each_ref_fn, void *);\n extern int for_each_tag_ref(each_ref_fn, void *);\n extern int for_each_branch_ref(each_ref_fn, void *);\n extern int for_each_remote_ref(each_ref_fn, void *);\n+extern int for_each_replace_ref(each_ref_fn, void *);\n \n /*\n  * Extra refs will be listed by for_each_ref() before any actual refs\n-- \n1.6.1.162.g1cd53\n"}]}