{"thread":{"id":"52544","subject":"[PATCH 0/1] sparse-checkout: use extern for global variables","startedAt":"2019-12-31T13:17:53Z","lastAt":"2020-01-02T18:17:30Z","messageCount":3,"participants":["Derrick Stolee via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"389134","messageId":"pull.506.git.1577798268.gitgitgadget@gmail.com","threadId":"52544","inReplyTo":null,"subject":"[PATCH 0/1] sparse-checkout: use extern for global variables","fromName":"Derrick Stolee via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-31T13:17:47Z","receivedAt":"2019-12-31T13:17:53Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"I noticed this issue when resolving conflicts with our VFS for Git-enabled\nbranch in microsoft/git.\n\nWhen I moved the global for core.sparseCheckout along with creating the\nglobal for core.sparseCheckoutCone, I dropped the \"extern\" by habit. (We are\ndropping these from function declarations, usually.) However, this means\nsomething different for variables, and could lead to bugs. I haven't found\nany, but it's better to be safe, right?\n\nThanks, -Stolee\n\nDerrick Stolee (1):\n  sparse-checkout: use extern for global variables\n\n cache.h | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\n\nbase-commit: 99c33bed562b41de6ce9bd3fd561303d39645048\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-506%2Fderrickstolee%2Fsparse-extern-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-506/derrickstolee/sparse-extern-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/506\n-- \ngitgitgadget\n"},{"id":"389135","messageId":"c704cb554e1897278913520f266d95a4b04f9639.1577798268.git.gitgitgadget@gmail.com","threadId":"52544","inReplyTo":"pull.506.git.1577798268.gitgitgadget@gmail.com","subject":"[PATCH 1/1] sparse-checkout: use extern for global variables","fromName":"Derrick Stolee via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-31T13:17:48Z","receivedAt":"2019-12-31T13:18:01Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"From: Derrick Stolee <dstolee@microsoft.com>\n\nWhen the core.sparseCheckoutCone config setting was added in\n879321eb0b (\"sparse-checkout: add 'cone' mode\" 2019-11-21), the\nvariables storing the config values for core.sparseCheckout and\ncore.sparseCheckoutCone were rearranged in cache.h, but in doing\nso the \"extern\" keyword was dropped.\n\nWhile we are tending to drop the \"extern\" keyword for function\ndeclarations, it is still necessary for global variables used\nacross multiple *.c files. The impact of not having the extern\nkeyword may be unpredictable.\n\nSigned-off-by: Derrick Stolee <dstolee@microsoft.com>\n---\n cache.h | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 1554488d66..cbfaead23a 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -958,8 +958,8 @@ extern int protect_hfs;\n extern int protect_ntfs;\n extern const char *core_fsmonitor;\n \n-int core_apply_sparse_checkout;\n-int core_sparse_checkout_cone;\n+extern int core_apply_sparse_checkout;\n+extern int core_sparse_checkout_cone;\n \n /*\n  * Include broken refs in all ref iterations, which will\n-- \ngitgitgadget\n"},{"id":"389167","messageId":"xmqq36cxg1u5.fsf@gitster-ct.c.googlers.com","threadId":"52544","inReplyTo":"c704cb554e1897278913520f266d95a4b04f9639.1577798268.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] sparse-checkout: use extern for global variables","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2020-01-02T18:17:22Z","receivedAt":"2020-01-02T18:17:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Derrick Stolee via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Derrick Stolee <dstolee@microsoft.com>\n>\n> When the core.sparseCheckoutCone config setting was added in\n> 879321eb0b (\"sparse-checkout: add 'cone' mode\" 2019-11-21), the\n> variables storing the config values for core.sparseCheckout and\n> core.sparseCheckoutCone were rearranged in cache.h, but in doing\n> so the \"extern\" keyword was dropped.\n>\n> While we are tending to drop the \"extern\" keyword for function\n> declarations, it is still necessary for global variables used\n> across multiple *.c files. The impact of not having the extern\n> keyword may be unpredictable.\n\n\"May be unpredictable\" might be a bit too strong, but I agree that\nit is better not to rely on the \"common extension\" these days, and\ninstead make sure variable decls have \"extern\" in front.\n\nWill queue.  Thanks.\n\n> Signed-off-by: Derrick Stolee <dstolee@microsoft.com>\n> ---\n>  cache.h | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/cache.h b/cache.h\n> index 1554488d66..cbfaead23a 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -958,8 +958,8 @@ extern int protect_hfs;\n>  extern int protect_ntfs;\n>  extern const char *core_fsmonitor;\n>  \n> -int core_apply_sparse_checkout;\n> -int core_sparse_checkout_cone;\n> +extern int core_apply_sparse_checkout;\n> +extern int core_sparse_checkout_cone;\n>  \n>  /*\n>   * Include broken refs in all ref iterations, which will\n"}]}