{"thread":{"id":"6686","subject":"[PATCH 2/2] Use cache_sha1_file() in git-blame and git-merge-recursive.","startedAt":"2007-02-05T05:51:26Z","lastAt":"2007-02-05T05:56:59Z","messageCount":2,"participants":["Junio C Hamano","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"33609","messageId":"7v7iuxp2xt.fsf@assigned-by-dhcp.cox.net","threadId":"6686","inReplyTo":null,"subject":"[PATCH 2/2] Use cache_sha1_file() in git-blame and git-merge-recursive.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-05T05:51:26Z","receivedAt":"2007-02-05T05:51:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"git-merge-recursive wants an null tree as the fake merge base\nwhile producing the merge result tree.  The null tree does not\nhave to be written out in the object store as it won't be part\nof the result, and it is a prime example for using the new\ncache_sha1_file() function.\n\ngit-blame needs to register an arbitrary data to in-core index\nwhile annotating a working tree file (or standard input), but\ngit-blame is a read-only application and the user of it could\neven lack the privilege to write into the object store; it is\nanother good example for cache_sha1_file().\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n builtin-blame.c   |    2 +-\n merge-recursive.c |    2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-blame.c b/builtin-blame.c\nindex 897323a..15d0707 100644\n--- a/builtin-blame.c\n+++ b/builtin-blame.c\n@@ -2005,7 +2005,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con\n \tbuf[fin_size] = 0;\n \torigin->file.ptr = buf;\n \torigin->file.size = fin_size;\n-\twrite_sha1_file(buf, fin_size, blob_type, origin->blob_sha1);\n+\tcache_sha1_file(buf, fin_size, blob_type, origin->blob_sha1);\n \tcommit->util = origin;\n \n \t/*\ndiff --git a/merge-recursive.c b/merge-recursive.c\nindex a68fcc6..d4e2460 100644\n--- a/merge-recursive.c\n+++ b/merge-recursive.c\n@@ -1213,7 +1213,7 @@ static int merge(struct commit *h1,\n \n \t\ttree->object.parsed = 1;\n \t\ttree->object.type = OBJ_TREE;\n-\t\twrite_sha1_file(NULL, 0, tree_type, tree->object.sha1);\n+\t\tcache_sha1_file(NULL, 0, tree_type, tree->object.sha1);\n \t\tmerged_common_ancestors = make_virtual_commit(tree, \"ancestor\");\n \t}\n \n-- \n1.5.0.rc3.58.g79812\n"},{"id":"33610","messageId":"20070205055659.GA13472@spearce.org","threadId":"6686","inReplyTo":"7v7iuxp2xt.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/2] Use cache_sha1_file() in git-blame and git-merge-recursive.","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-02-05T05:56:59Z","receivedAt":"2007-02-05T05:56:59Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> git-blame needs to register an arbitrary data to in-core index\n> while annotating a working tree file (or standard input), but\n> git-blame is a read-only application and the user of it could\n> even lack the privilege to write into the object store; it is\n> another good example for cache_sha1_file().\n\n*Excellent* reason for this.\n\nBut what about pretend_sha1_file() instead?\n\nThe term 'cache' suggests to me (on first glance) that its loading\nan existing object and caching it in memory for faster, frequent\naccess, when compared to other non-cached objects.\n\n-- \nShawn.\n"}]}