{"thread":{"id":"14366","subject":"[PATCH 3/3] cherry: add cherry.cachepatchids option","startedAt":"2008-07-09T03:57:18Z","lastAt":"2008-07-09T03:57:18Z","messageCount":1,"participants":["Geoffrey Irving"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"82675","messageId":"7f9d599f0807082057s6415598fh2f37aa27432e882e@mail.gmail.com","threadId":"14366","inReplyTo":null,"subject":"[PATCH 3/3] cherry: add cherry.cachepatchids option","fromName":"Geoffrey Irving","fromEmail":"irving@naml.us","sentAt":"2008-07-09T03:57:18Z","receivedAt":"2008-07-09T03:57:18Z","isPatch":true,"sender":{"key":"irving@naml.us","avatar":"https://gravatar.com/avatar/52d7452fcd134aac0fa12f57a3bb7ef5f3f7e73ca0ab36736d06c6a6132de718?d=mp&s=160"},"body":">From 7a51a1808fb440b1aca58780ccc09ffe11d4d3d6 Mon Sep 17 00:00:00 2001\nFrom: Geoffrey Irving <irving@naml.us>\nDate: Tue, 8 Jul 2008 20:25:53 -0700\nSubject: [PATCH 3/3] cherry: add cherry.cachepatchids option\n\nThe patch-id caching optimization in git-cherry is still enabled by default,\nbut now it can be disabled by setting cherry.cachepatchids = false.\n---\n Documentation/config.txt |    5 +++++\n builtin-log.c            |   12 ++++++++++++\n patch-ids.c              |   12 +++++++++---\n patch-ids.h              |    2 ++\n 4 files changed, 28 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 838794d..02b8113 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -468,6 +468,11 @@ browser.<tool>.path::\n \tbrowse HTML help (see '-w' option in linkgit:git-help[1]) or a\n \tworking repository in gitweb (see linkgit:git-instaweb[1]).\n\n+cherry.cachepatchids::\n+\tIf true, linkgit:git-cherry will store a cache of computed patch-ids\n+\tin $GIT_DIR/patch-id-cache in order to make repeated invocations faster.\n+\tDefaults to true.\n+\n clean.requireForce::\n \tA boolean to make git-clean do nothing unless given -f\n \tor -n.   Defaults to true.\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 430d876..fbfefbd 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -1081,6 +1081,16 @@ static int add_pending_commit(const char *arg,\nstruct rev_info *revs, int flags)\n \treturn -1;\n }\n\n+static int git_cherry_config(const char *var, const char *value, void *cb)\n+{\n+\tif (!strcmp(var, \"cherry.cachepatchids\")) {\n+\t\tcache_patch_ids = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n+\n+\treturn 0;\n+}\n+\n static const char cherry_usage[] =\n \"git-cherry [-v] <upstream> [<head>] [<limit>]\";\n int cmd_cherry(int argc, const char **argv, const char *prefix)\n@@ -1094,6 +1104,8 @@ int cmd_cherry(int argc, const char **argv,\nconst char *prefix)\n \tconst char *limit = NULL;\n \tint verbose = 0;\n\n+\tgit_config(git_cherry_config, NULL);\n+\n \tif (argc > 1 && !strcmp(argv[1], \"-v\")) {\n \t\tverbose = 1;\n \t\targc--;\ndiff --git a/patch-ids.c b/patch-ids.c\nindex 36332f3..7e3a563 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -4,6 +4,7 @@\n #include \"patch-ids.h\"\n #include \"cached-sha1-map.h\"\n\n+int cache_patch_ids = 1;\n struct cached_sha1_map patch_id_cache;\n\n static int commit_patch_id(struct commit *commit, struct diff_options *options,\n@@ -11,7 +12,8 @@ static int commit_patch_id(struct commit *commit,\nstruct diff_options *options,\n {\n \t/* pull patch-id out of the cache if possible */\n \tpatch_id_cache.filename = \"patch-id-cache\";\n-\tif (!get_cached_sha1_entry(&patch_id_cache, commit->object.sha1, sha1))\n+\tif (cache_patch_ids && !get_cached_sha1_entry(&patch_id_cache,\n+\t\t\tcommit->object.sha1, sha1))\n \t\treturn 0;\n\n \tif (commit->parents)\n@@ -25,7 +27,8 @@ static int commit_patch_id(struct commit *commit,\nstruct diff_options *options,\n \t\treturn ret;\n\n \t/* record commit, patch-id pair in cache */\n-\tset_cached_sha1_entry(&patch_id_cache, commit->object.sha1, sha1);\n+\tif (cache_patch_ids)\n+\t\tset_cached_sha1_entry(&patch_id_cache, commit->object.sha1, sha1);\n \treturn 0;\n }\n\n@@ -151,7 +154,10 @@ int free_patch_ids(struct patch_ids *ids)\n \t\tfree(patches);\n \t}\n\n-\twrite_cached_sha1_map(&patch_id_cache);\n+\t/* write cached patch-ids and ignore any errors that arise\n+\t * (e.g. if the repository is write protected) */\n+\tif (cache_patch_ids)\n+\t\twrite_cached_sha1_map(&patch_id_cache);\n \treturn 0;\n }\n\ndiff --git a/patch-ids.h b/patch-ids.h\nindex c8c7ca1..c0ebdc1 100644\n--- a/patch-ids.h\n+++ b/patch-ids.h\n@@ -18,4 +18,6 @@ int free_patch_ids(struct patch_ids *);\n struct patch_id *add_commit_patch_id(struct commit *, struct patch_ids *);\n struct patch_id *has_commit_patch_id(struct commit *, struct patch_ids *);\n\n+extern int cache_patch_ids;\n+\n #endif /* PATCH_IDS_H */\n-- \n1.5.6.2.258.g7a51a\n"}]}