From patchwork Tue Oct 30 18:40:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 10661419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 67DD417DF for ; Tue, 30 Oct 2018 18:40:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D3342AA7D for ; Tue, 30 Oct 2018 18:40:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 618562AA89; Tue, 30 Oct 2018 18:40:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0774C2AA7D for ; Tue, 30 Oct 2018 18:40:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727759AbeJaDem (ORCPT ); Tue, 30 Oct 2018 23:34:42 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46174 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbeJaDem (ORCPT ); Tue, 30 Oct 2018 23:34:42 -0400 Received: by mail-pf1-f194.google.com with SMTP id r64-v6so6276884pfb.13 for ; Tue, 30 Oct 2018 11:40:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=iiUzv0lMqbt2nDoL0o1L/u53ukaVjLHG406q+XaliHY=; b=G0GqRsWXUsUUJkvSTt9aizW2X5MT94xRuWA1YpGAQwXIfIUbPutPU6hG/V7zHuFsDM asrwzFQGExWwOYgf6eSAjWqPa3yDUzXITrmueAldHB3hy8xL2I+paFo5I80VwQVVSleD AMtT7sRjJl74qEKGBqFAfQLveaK9TM+2I3x+cngKprtkMt6nhMzvweIuvNWRoOpPFA/6 rERyIh0fMIPiS3WIBqc3M3xCNWR4i+IHbB8KmXzZPHljgD5qGTp+eLU6e5pB+kyOjZB7 hCxfjCymwHUdnJCDQ1TsDEwpwIt2I8CDP4phBG/TAo95XmKuRviN6rEYD0iABg8bACll X1HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=iiUzv0lMqbt2nDoL0o1L/u53ukaVjLHG406q+XaliHY=; b=EgSp6pgu9en8i+TrVnCesnKg3fRHBTuWatGeM66tL91r4pvrY8Qx46yANx+p+ovEcd kWTCzZa606T8ab58UPoibRM6sh+NiAzQLuE8FvtUpfFJRUaS8N9ywOHmEooo3f1y7HPq l5hwiPDZIMiAohsxV1K3Z2d/Odtx7O+j4tfpFGfY96SFHmoHbTsH5PuuE6EvZvDyRCL9 YMGwIrZyQMJp+REQ1ZU/EjopJ//jgJX2t/qm+D+ZEtsG0oSj1Nktl4MsOEObSxcqefmY 4S3bIwqABraW6UIn3sjSGSpS/QRyxvYr6xL/zhF+bkd+o9XDjYSQ9w1aiY64FY4J5DAf lYLQ== X-Gm-Message-State: AGRZ1gJypDsZlEh42BrNqJoUINXKgemN1MNhehtdPqbL2YaHBRwEK0vq M8R/Mlwt2RWu/l3SuMiha/Y0M0J/ X-Google-Smtp-Source: AJdET5eyyUzlstzC9sFIth5vAV+TVHW7s0WYQ/PfNcObL6+8K8sGybQCKeMS+NyAAiE+9+Zs07PTQg== X-Received: by 2002:a62:5a47:: with SMTP id o68-v6mr4155330pfb.31.1540924804274; Tue, 30 Oct 2018 11:40:04 -0700 (PDT) Received: from [127.0.0.1] ([40.112.137.127]) by smtp.gmail.com with ESMTPSA id t26-v6sm32448621pfa.158.2018.10.30.11.40.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 11:40:03 -0700 (PDT) Date: Tue, 30 Oct 2018 11:40:03 -0700 (PDT) X-Google-Original-Date: Tue, 30 Oct 2018 18:39:56 GMT Message-Id: <660c740fbc190274e1e124672d87abdada97ec2b.1540924800.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 1/4] config: rename `dummy` parameter to `cb` in git_default_config() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin This is the convention elsewhere (and prepares for the case where we may need to pass callback data). Signed-off-by: Johannes Schindelin --- config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index 4051e3882..3687c6783 100644 --- a/config.c +++ b/config.c @@ -1448,13 +1448,13 @@ static int git_default_mailmap_config(const char *var, const char *value) return 0; } -int git_default_config(const char *var, const char *value, void *dummy) +int git_default_config(const char *var, const char *value, void *cb) { if (starts_with(var, "core.")) return git_default_core_config(var, value); if (starts_with(var, "user.")) - return git_ident_config(var, value, dummy); + return git_ident_config(var, value, cb); if (starts_with(var, "i18n.")) return git_default_i18n_config(var, value); From patchwork Tue Oct 30 18:40:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 10661423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB2E03CF1 for ; Tue, 30 Oct 2018 18:40:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1F932AA7D for ; Tue, 30 Oct 2018 18:40:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C68A42AA86; Tue, 30 Oct 2018 18:40:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BCED2AA7D for ; Tue, 30 Oct 2018 18:40:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727814AbeJaDeo (ORCPT ); Tue, 30 Oct 2018 23:34:44 -0400 Received: from mail-pf1-f175.google.com ([209.85.210.175]:40931 "EHLO mail-pf1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726376AbeJaDen (ORCPT ); Tue, 30 Oct 2018 23:34:43 -0400 Received: by mail-pf1-f175.google.com with SMTP id g21-v6so6284787pfi.7 for ; Tue, 30 Oct 2018 11:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=mbgw8hWhS1sFl5zl1zaPv5luAHpmILd/F1As+gfv2aw=; b=WeJ1TbbmpT5P7ivrIiwruac/OpQ+a4UKpIQeDH830lD0aWHrRRRLbQXFQBbl59+iBY 9qdmbL7+itHd91uy8z5uSo2Fk2ELjsP+Q9j7NqzFcSQj4F5+ozcT2H/X28NLT/d1ujsR SgJgKSxoM0fxd3DJNk9uOIqHPxmxfdPBzIBnnZUPEDXPpkqWkVOtkUtIgqKKslHgPivY vMr8P3txGkvLTDHFHpV7dl9DW9ieQgR8Uansli3151RQS6PSG/wpoasoXBkiXZ9LVG88 yjnrExPVED0LAC37ygKybbORG1obY8yDhAARvY3seWf4EnuGMI7dzIrQUHDA09Xj5gtt VlKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=mbgw8hWhS1sFl5zl1zaPv5luAHpmILd/F1As+gfv2aw=; b=YbzigLPx5ldScE8ZY9TnAzmP9/1x+GqnkFKqWdsZbQkUUGTfIE+0F2J/kCVOsd1uvy uqO0+DbiEV8ie9DNqvi1Xjstj1ev+PFznbDuqOx4oaGGcE8884JXtFCy8SWYeCDnQrAf 1DPmnyfbyC+q/AQe2tGmrrTfY4yF9TpbTqD5oWdgooprGvC3kRctodUu34xlzslSFjgZ AHlRj2xCQ3Z2yahY8o+UBJ7aM/4sgDOizhNYfhgIaH9HiZ6bsZSAEkq2gPT4oX4x5C+Y 1LT/HLx9XfCX6OErqFFwBJdo3zc9sI25cWSH8TxcJZmnALZBEW7MwFUhz7dkzjgbK1gc cK5A== X-Gm-Message-State: AGRZ1gJUvAldVej7JPo51A3rNZGm6lZbnOPZXQgtP6AGW1/2S2B6G0K6 WBd20QXUe6/y4ytdr8g1nRfSCA6i X-Google-Smtp-Source: AJdET5dNSOzqN2CSzIYpbqaamjM8+paciy56z7dL3WD7kohnCPl7ouSDeHTEjCVBThRHYXec+uvd/A== X-Received: by 2002:a63:9304:: with SMTP id b4-v6mr45712pge.36.1540924805639; Tue, 30 Oct 2018 11:40:05 -0700 (PDT) Received: from [127.0.0.1] ([40.112.137.127]) by smtp.gmail.com with ESMTPSA id k13-v6sm25430234pff.30.2018.10.30.11.40.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 11:40:04 -0700 (PDT) Date: Tue, 30 Oct 2018 11:40:04 -0700 (PDT) X-Google-Original-Date: Tue, 30 Oct 2018 18:39:57 GMT Message-Id: In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 2/4] Allow for platform-specific core.* config settings Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin In the Git for Windows project, we have ample precendent for config settings that apply to Windows, and to Windows only. Let's formalize this concept by introducing a platform_core_config() function that can be #define'd in a platform-specific manner. This will allow us to contain platform-specific code better, as the corresponding variables no longer need to be exported so that they can be defined in environment.c and be set in config.c Signed-off-by: Johannes Schindelin --- compat/mingw.c | 5 +++++ compat/mingw.h | 3 +++ config.c | 6 +++--- git-compat-util.h | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 81ef24286..293f286af 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -203,6 +203,11 @@ static int ask_yes_no_if_possible(const char *format, ...) } } +int mingw_core_config(const char *var, const char *value, void *cb) +{ + return 0; +} + /* Normalizes NT paths as returned by some low-level APIs. */ static wchar_t *normalize_ntpath(wchar_t *wbuf) { diff --git a/compat/mingw.h b/compat/mingw.h index f31dcff2b..e9d2b9cdd 100644 --- a/compat/mingw.h +++ b/compat/mingw.h @@ -11,6 +11,9 @@ typedef _sigset_t sigset_t; #undef _POSIX_THREAD_SAFE_FUNCTIONS #endif +extern int mingw_core_config(const char *var, const char *value, void *cb); +#define platform_core_config mingw_core_config + /* * things that are not available in header files */ diff --git a/config.c b/config.c index 3687c6783..646b6cca9 100644 --- a/config.c +++ b/config.c @@ -1093,7 +1093,7 @@ int git_config_color(char *dest, const char *var, const char *value) return 0; } -static int git_default_core_config(const char *var, const char *value) +static int git_default_core_config(const char *var, const char *value, void *cb) { /* This needs a better name */ if (!strcmp(var, "core.filemode")) { @@ -1363,7 +1363,7 @@ static int git_default_core_config(const char *var, const char *value) } /* Add other config variables here and to Documentation/config.txt. */ - return 0; + return platform_core_config(var, value, cb); } static int git_default_i18n_config(const char *var, const char *value) @@ -1451,7 +1451,7 @@ static int git_default_mailmap_config(const char *var, const char *value) int git_default_config(const char *var, const char *value, void *cb) { if (starts_with(var, "core.")) - return git_default_core_config(var, value); + return git_default_core_config(var, value, cb); if (starts_with(var, "user.")) return git_ident_config(var, value, cb); diff --git a/git-compat-util.h b/git-compat-util.h index 96a3f86d8..3a08d9916 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -342,6 +342,14 @@ typedef uintmax_t timestamp_t; #define _PATH_DEFPATH "/usr/local/bin:/usr/bin:/bin" #endif +#ifndef platform_core_config +static inline int noop_core_config(const char *var, const char *value, void *cb) +{ + return 0; +} +#define platform_core_config noop_core_config +#endif + #ifndef has_dos_drive_prefix static inline int git_has_dos_drive_prefix(const char *path) { From patchwork Tue Oct 30 18:40:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 10661425 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91BAD17DF for ; Tue, 30 Oct 2018 18:40:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 985D42AA7D for ; Tue, 30 Oct 2018 18:40:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CB5F2AA86; Tue, 30 Oct 2018 18:40:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 104C72AA7D for ; Tue, 30 Oct 2018 18:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbeJaDeq (ORCPT ); Tue, 30 Oct 2018 23:34:46 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:39000 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727516AbeJaDep (ORCPT ); Tue, 30 Oct 2018 23:34:45 -0400 Received: by mail-pf1-f193.google.com with SMTP id c25-v6so6287957pfe.6 for ; Tue, 30 Oct 2018 11:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=mm/rC6j88f54TRGCwwoMvP7x5ICF1CI+JKNsFJPW7iw=; b=Pa4jKJ2JmTXJ2c7roCL8r+My3QM/iC7dr3bJK7OzmLa3Ddc6JKWqLyRpESHLSHA/fp qckTLJe0Nv/19Lj98pzQxRqFWwc6sOCksqxloTvaq+MjNeSZgCdkB3sV7zUZ9wLJ91vq eecwQZBAR9ionTvJiIjsJXNVguYc0p0/let63TPxPyJTOGTkdX+ifWPKVUXCk4Tqtajy QA5cXbp7PGO4d3C2Pr5yDhfPd45/pV0Rpma3uPb+TnMwdcPiEDMcni/rs7n6/8l/SOs9 5J7MLK/swhaO4H0AL065fN2Fk4Ho5BMg8aCS4UlVu5KSz/pgjyg7JMazGGACSf9gT6F0 2QVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=mm/rC6j88f54TRGCwwoMvP7x5ICF1CI+JKNsFJPW7iw=; b=A3yxxNMfw5Eqfo9+izIVXFtIy6bbDXJUPHB33vb9m87A+nrW9v05O8eDUGUTSussTT b+YwD/7Ptq+oAFcHbTZ8RSaRACffRkLuvwqyf+PtDTBc4wWbqsBjz8k7LMI7b4YgGFH0 JFlNn7HLnW1NLwZ3lB8RbAZJhh14WGeLRdm1nntX0fFyEjH+k5mq+mFM6AqkpCsdaSOg uAil34nNfsEmoVp8/onPxmIf0pcCG+yHMi5xO8gaZBsTykkWPfW9HkyeNhEQFHmc2DPn raJIhy8b5FF/Ypu4tyIFicHLlBsRnbmPpDe+7B9m7OFt2H9ZL89TwVStodwNOCwJSkg3 gk1w== X-Gm-Message-State: AGRZ1gLLQQxhP6d0Ytb/AKkK+W46onJ8c+5Q1Dp0ol4vv7PFyMi9luiN QbNfeNdY9HD+DKa/cm/QG2nmWDa7 X-Google-Smtp-Source: AJdET5ckJh79yJuA597e89d0ifambz7HKpwC/PIVydUA2EnNSHXqEcfEQ+N6XKxV+cGhCWwhxuYmuQ== X-Received: by 2002:a62:ee03:: with SMTP id e3-v6mr3494553pfi.2.1540924807104; Tue, 30 Oct 2018 11:40:07 -0700 (PDT) Received: from [127.0.0.1] ([40.112.137.127]) by smtp.gmail.com with ESMTPSA id c17-v6sm4421319pgk.85.2018.10.30.11.40.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 11:40:06 -0700 (PDT) Date: Tue, 30 Oct 2018 11:40:06 -0700 (PDT) X-Google-Original-Date: Tue, 30 Oct 2018 18:39:58 GMT Message-Id: <62813ef54647bb224a20208124d7d763bd9789d5.1540924800.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 3/4] Move Windows-specific config settings into compat/mingw.c Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin Signed-off-by: Johannes Schindelin --- cache.h | 8 -------- compat/mingw.c | 18 ++++++++++++++++++ config.c | 8 -------- environment.c | 1 - 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/cache.h b/cache.h index f7fabdde8..0ce95c5a8 100644 --- a/cache.h +++ b/cache.h @@ -906,14 +906,6 @@ int use_optional_locks(void); extern char comment_line_char; extern int auto_comment_line_char; -/* Windows only */ -enum hide_dotfiles_type { - HIDE_DOTFILES_FALSE = 0, - HIDE_DOTFILES_TRUE, - HIDE_DOTFILES_DOTGITONLY -}; -extern enum hide_dotfiles_type hide_dotfiles; - enum log_refs_config { LOG_REFS_UNSET = -1, LOG_REFS_NONE = 0, diff --git a/compat/mingw.c b/compat/mingw.c index 293f286af..272d5e11e 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -6,6 +6,7 @@ #include "../run-command.h" #include "../cache.h" #include "win32/lazyload.h" +#include "../config.h" #define HCAST(type, handle) ((type)(intptr_t)handle) @@ -203,8 +204,25 @@ static int ask_yes_no_if_possible(const char *format, ...) } } +/* Windows only */ +enum hide_dotfiles_type { + HIDE_DOTFILES_FALSE = 0, + HIDE_DOTFILES_TRUE, + HIDE_DOTFILES_DOTGITONLY +}; + +static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY; + int mingw_core_config(const char *var, const char *value, void *cb) { + if (!strcmp(var, "core.hidedotfiles")) { + if (value && !strcasecmp(value, "dotgitonly")) + hide_dotfiles = HIDE_DOTFILES_DOTGITONLY; + else + hide_dotfiles = git_config_bool(var, value); + return 0; + } + return 0; } diff --git a/config.c b/config.c index 646b6cca9..5bf19a23c 100644 --- a/config.c +++ b/config.c @@ -1344,14 +1344,6 @@ static int git_default_core_config(const char *var, const char *value, void *cb) return 0; } - if (!strcmp(var, "core.hidedotfiles")) { - if (value && !strcasecmp(value, "dotgitonly")) - hide_dotfiles = HIDE_DOTFILES_DOTGITONLY; - else - hide_dotfiles = git_config_bool(var, value); - return 0; - } - if (!strcmp(var, "core.partialclonefilter")) { return git_config_string(&core_partial_clone_filter_default, var, value); diff --git a/environment.c b/environment.c index 3f3c8746c..30ecd4e78 100644 --- a/environment.c +++ b/environment.c @@ -71,7 +71,6 @@ int core_apply_sparse_checkout; int merge_log_config = -1; int precomposed_unicode = -1; /* see probe_utf8_pathname_composition() */ unsigned long pack_size_limit_cfg; -enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY; enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET; #ifndef PROTECT_HFS_DEFAULT From patchwork Tue Oct 30 18:40:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Arver via GitGitGadget X-Patchwork-Id: 10661427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D73473CF1 for ; Tue, 30 Oct 2018 18:40:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD3412AA7D for ; Tue, 30 Oct 2018 18:40:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D19062AA86; Tue, 30 Oct 2018 18:40:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A71052AA7D for ; Tue, 30 Oct 2018 18:40:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbeJaDer (ORCPT ); Tue, 30 Oct 2018 23:34:47 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39005 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727516AbeJaDer (ORCPT ); Tue, 30 Oct 2018 23:34:47 -0400 Received: by mail-pf1-f196.google.com with SMTP id c25-v6so6287983pfe.6 for ; Tue, 30 Oct 2018 11:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=54Dapt86JCXujLphP/Ru7u119YJCTK1QsvRp3uYzSfQ=; b=B4Yd3b1io5yiexag11wwqi36/VoOslK2KMQx40FN8DcTf8AGTPr1sG1ptczzdLeB17 ECfq9C+iRXme4QSqaAqIRjfrR93Pg4F21T6oLB+iJ7DcMRmXIscxfm4L7flXeg6pMgB5 16ZSv+P84QH/9TuDzA4BE5SxyP3beLOyGywZJb9hbmg00AKcxa3l2k4hz6DPikF6lChv QqfN1IYflBfKzRcX4/Mfs2+3Kpppv5j1IQlG4tnpfKzyZnB+7TBvN0oy25NBYCHWYFyj NUt0FyCL1mMwIQMiNluGLZMSuF8/ixVRj8bApTNHp+11l+C2Ym9eD2u/L00f7RCm2xc4 v36g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=54Dapt86JCXujLphP/Ru7u119YJCTK1QsvRp3uYzSfQ=; b=hlx2bKCQ8hyGArCVcCR+DTWDAUL33c5NeO2HHmaboHEEQEb2yjPLMOxTf8KLv8oVFd d/8xET4TxNReOtrrhDjgIWmWxJBqPET4tMOKP6cGOSceUgBmHi4KnrEN/lZG77H5ojys VPZumArdrzrMBl3wxswFw2bGZR19AN0hqjwMSB5UoUCwTnkOyaliBWMKRzMksrTzFG8O kCWwToEH45B+h/g3bqIh6/Ff0GN5+2HdLtAm/oV3Dp+py4jtRMl85Imor7zEdGVqAZ1D dhsIXKbC9SOAQK1bqSc+GLLpQLz/J4rED3VwrqV1eFGn5aSYYpJ7UX36/bF62Vp/0H+o RZEw== X-Gm-Message-State: AGRZ1gIslv81LFKo1Kz1RXHTpkrleRv5FhwgRqs2nePahYW89HPi/Tb9 Fr3ebS0v6lhyvbmSBvaMPMC3cyZi X-Google-Smtp-Source: AJdET5cjd2UzsiXhcSbBAptu4K7FjVtUc3S+HnGSqRGCZr0+8ZKJSwENgWF83foQ7PF16CZ+/czU1Q== X-Received: by 2002:a62:642:: with SMTP id 63-v6mr4079540pfg.190.1540924808506; Tue, 30 Oct 2018 11:40:08 -0700 (PDT) Received: from [127.0.0.1] ([40.112.137.127]) by smtp.gmail.com with ESMTPSA id v8-v6sm19308650pgk.54.2018.10.30.11.40.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 11:40:07 -0700 (PDT) Date: Tue, 30 Oct 2018 11:40:07 -0700 (PDT) X-Google-Original-Date: Tue, 30 Oct 2018 18:39:59 GMT Message-Id: <567701fc798fec58e7401bdf88ee3b8dbbfe390d.1540924800.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 4/4] mingw: unset PERL5LIB by default Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin Git for Windows ships with its own Perl interpreter, and insists on using it, so it will most likely wreak havoc if PERL5LIB is set before launching Git. Let's just unset that environment variables when spawning processes. To make this feature extensible (and overrideable), there is a new config setting `core.unsetenvvars` that allows specifying a comma-separated list of names to unset before spawning processes. Reported by Gabriel Fuhrmann. Signed-off-by: Johannes Schindelin --- Documentation/config.txt | 6 ++++++ compat/mingw.c | 35 ++++++++++++++++++++++++++++++++++- t/t0029-core-unsetenvvars.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 t/t0029-core-unsetenvvars.sh diff --git a/Documentation/config.txt b/Documentation/config.txt index 09e95e9e9..f338f0b2c 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -921,6 +921,12 @@ relatively high IO latencies. When enabled, Git will do the index comparison to the filesystem data in parallel, allowing overlapping IO's. Defaults to true. +core.unsetenvvars:: + Windows-only: comma-separated list of environment variables' + names that need to be unset before spawning any other process. + Defaults to `PERL5LIB` to account for the fact that Git for + Windows insists on using its own Perl interpreter. + core.createObject:: You can set this to 'link', in which case a hardlink followed by a delete of the source are used to make sure that object creation diff --git a/compat/mingw.c b/compat/mingw.c index 272d5e11e..181e74c23 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -212,6 +212,7 @@ enum hide_dotfiles_type { }; static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY; +static char *unset_environment_variables; int mingw_core_config(const char *var, const char *value, void *cb) { @@ -223,6 +224,12 @@ int mingw_core_config(const char *var, const char *value, void *cb) return 0; } + if (!strcmp(var, "core.unsetenvvars")) { + free(unset_environment_variables); + unset_environment_variables = xstrdup(value); + return 0; + } + return 0; } @@ -1180,6 +1187,27 @@ static wchar_t *make_environment_block(char **deltaenv) return wenvblk; } +static void do_unset_environment_variables(void) +{ + static int done; + char *p = unset_environment_variables; + + if (done || !p) + return; + done = 1; + + for (;;) { + char *comma = strchr(p, ','); + + if (comma) + *comma = '\0'; + unsetenv(p); + if (!comma) + break; + p = comma + 1; + } +} + struct pinfo_t { struct pinfo_t *next; pid_t pid; @@ -1198,9 +1226,12 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen wchar_t wcmd[MAX_PATH], wdir[MAX_PATH], *wargs, *wenvblk = NULL; unsigned flags = CREATE_UNICODE_ENVIRONMENT; BOOL ret; + HANDLE cons; + + do_unset_environment_variables(); /* Determine whether or not we are associated to a console */ - HANDLE cons = CreateFile("CONOUT$", GENERIC_WRITE, + cons = CreateFile("CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (cons == INVALID_HANDLE_VALUE) { @@ -2437,6 +2468,8 @@ void mingw_startup(void) /* fix Windows specific environment settings */ setup_windows_environment(); + unset_environment_variables = xstrdup("PERL5LIB"); + /* initialize critical section for waitpid pinfo_t list */ InitializeCriticalSection(&pinfo_cs); diff --git a/t/t0029-core-unsetenvvars.sh b/t/t0029-core-unsetenvvars.sh new file mode 100755 index 000000000..24ce46a6e --- /dev/null +++ b/t/t0029-core-unsetenvvars.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +test_description='test the Windows-only core.unsetenvvars setting' + +. ./test-lib.sh + +if ! test_have_prereq MINGW +then + skip_all='skipping Windows-specific tests' + test_done +fi + +test_expect_success 'setup' ' + mkdir -p "$TRASH_DIRECTORY/.git/hooks" && + write_script "$TRASH_DIRECTORY/.git/hooks/pre-commit" <<-\EOF + echo $HOBBES >&2 + EOF +' + +test_expect_success 'core.unsetenvvars works' ' + HOBBES=Calvin && + export HOBBES && + git commit --allow-empty -m with 2>err && + grep Calvin err && + git -c core.unsetenvvars=FINDUS,HOBBES,CALVIN \ + commit --allow-empty -m without 2>err && + ! grep Calvin err +' + +test_done