Skip to content

Commit 89e4fcb

Browse files
committed
Merge branches 'bp/reset-quiet' and 'js/mingw-http-ssl' into nd/config-split
* bp/reset-quiet: reset: warn when refresh_index() takes more than 2 seconds reset: add new reset.quiet config setting reset: don't compute unstaged changes after reset when --quiet * js/mingw-http-ssl: http: when using Secure Channel, ignore sslCAInfo by default http: add support for disabling SSL revocation checks in cURL http: add support for selecting SSL backends at runtime
3 parents c670b1f + 649bf3a + b67d40a commit 89e4fcb

File tree

6 files changed

+119
-3
lines changed

6 files changed

+119
-3
lines changed

Documentation/config.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,10 @@ advice.*::
333333
commitBeforeMerge::
334334
Advice shown when linkgit:git-merge[1] refuses to
335335
merge to avoid overwriting local changes.
336+
resetQuiet::
337+
Advice to consider using the `--quiet` option to linkgit:git-reset[1]
338+
when the command takes more than 2 seconds to enumerate unstaged
339+
changes after reset.
336340
resolveConflict::
337341
Advice shown by various commands when conflicts
338342
prevent the operation from being performed.
@@ -2003,6 +2007,27 @@ http.sslCAPath::
20032007
with when fetching or pushing over HTTPS. Can be overridden
20042008
by the `GIT_SSL_CAPATH` environment variable.
20052009

2010+
http.sslBackend::
2011+
Name of the SSL backend to use (e.g. "openssl" or "schannel").
2012+
This option is ignored if cURL lacks support for choosing the SSL
2013+
backend at runtime.
2014+
2015+
http.schannelCheckRevoke::
2016+
Used to enforce or disable certificate revocation checks in cURL
2017+
when http.sslBackend is set to "schannel". Defaults to `true` if
2018+
unset. Only necessary to disable this if Git consistently errors
2019+
and the message is about checking the revocation status of a
2020+
certificate. This option is ignored if cURL lacks support for
2021+
setting the relevant SSL option at runtime.
2022+
2023+
http.schannelUseSSLCAInfo::
2024+
As of cURL v7.60.0, the Secure Channel backend can use the
2025+
certificate bundle provided via `http.sslCAInfo`, but that would
2026+
override the Windows Certificate Store. Since this is not desirable
2027+
by default, Git will tell cURL not to use that bundle by default
2028+
when the `schannel` backend was configured via `http.sslBackend`,
2029+
unless `http.schannelUseSSLCAInfo` overrides this behavior.
2030+
20062031
http.pinnedpubkey::
20072032
Public key of the https service. It may either be the filename of
20082033
a PEM or DER encoded public key file or a string starting with
@@ -2753,6 +2778,9 @@ rerere.enabled::
27532778
`$GIT_DIR`, e.g. if "rerere" was previously used in the
27542779
repository.
27552780

2781+
reset.quiet::
2782+
When set to true, 'git reset' will default to the '--quiet' option.
2783+
27562784
include::sendemail-config.txt[]
27572785

27582786
sequence.editor::

Documentation/git-reset.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ OPTIONS
9595

9696
-q::
9797
--quiet::
98-
Be quiet, only report errors.
98+
--no-quiet::
99+
Be quiet, only report errors. The default behavior is set by the
100+
`reset.quiet` config option. `--quiet` and `--no-quiet` will
101+
override the default behavior.
99102

100103

101104
EXAMPLES

advice.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ int advice_push_needs_force = 1;
1212
int advice_status_hints = 1;
1313
int advice_status_u_option = 1;
1414
int advice_commit_before_merge = 1;
15+
int advice_reset_quiet_warning = 1;
1516
int advice_resolve_conflict = 1;
1617
int advice_implicit_identity = 1;
1718
int advice_detached_head = 1;
@@ -65,6 +66,7 @@ static struct {
6566
{ "statusHints", &advice_status_hints },
6667
{ "statusUoption", &advice_status_u_option },
6768
{ "commitBeforeMerge", &advice_commit_before_merge },
69+
{ "resetQuiet", &advice_reset_quiet_warning },
6870
{ "resolveConflict", &advice_resolve_conflict },
6971
{ "implicitIdentity", &advice_implicit_identity },
7072
{ "detachedHead", &advice_detached_head },

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ extern int advice_push_needs_force;
1212
extern int advice_status_hints;
1313
extern int advice_status_u_option;
1414
extern int advice_commit_before_merge;
15+
extern int advice_reset_quiet_warning;
1516
extern int advice_resolve_conflict;
1617
extern int advice_implicit_identity;
1718
extern int advice_detached_head;

builtin/reset.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include "submodule.h"
2626
#include "submodule-config.h"
2727

28+
#define REFRESH_INDEX_DELAY_WARNING_IN_MS (2 * 1000)
29+
2830
static const char * const git_reset_usage[] = {
2931
N_("git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]"),
3032
N_("git reset [-q] [<tree-ish>] [--] <paths>..."),
@@ -307,6 +309,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
307309
};
308310

309311
git_config(git_reset_config, NULL);
312+
git_config_get_bool("reset.quiet", &quiet);
310313

311314
argc = parse_options(argc, argv, prefix, options, git_reset_usage,
312315
PARSE_OPT_KEEP_DASHDASH);
@@ -376,9 +379,19 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
376379
int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
377380
if (read_from_tree(&pathspec, &oid, intent_to_add))
378381
return 1;
379-
if (get_git_work_tree())
382+
if (!quiet && get_git_work_tree()) {
383+
uint64_t t_begin, t_delta_in_ms;
384+
385+
t_begin = getnanotime();
380386
refresh_index(&the_index, flags, NULL, NULL,
381387
_("Unstaged changes after reset:"));
388+
t_delta_in_ms = (getnanotime() - t_begin) / 1000000;
389+
if (advice_reset_quiet_warning && t_delta_in_ms > REFRESH_INDEX_DELAY_WARNING_IN_MS) {
390+
printf(_("\nIt took %.2f seconds to enumerate unstaged changes after reset. You can\n"
391+
"use '--quiet' to avoid this. Set the config setting reset.quiet to true\n"
392+
"to make this the default.\n"), t_delta_in_ms / 1000.0);
393+
}
394+
}
382395
} else {
383396
int err = reset_index(&oid, reset_type, quiet);
384397
if (reset_type == KEEP && !err)

http.c

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,16 @@ static struct active_request_slot *active_queue_head;
155155

156156
static char *cached_accept_language;
157157

158+
static char *http_ssl_backend;
159+
160+
static int http_schannel_check_revoke = 1;
161+
/*
162+
* With the backend being set to `schannel`, setting sslCAinfo would override
163+
* the Certificate Store in cURL v7.60.0 and later, which is not what we want
164+
* by default.
165+
*/
166+
static int http_schannel_use_ssl_cainfo;
167+
158168
size_t fread_buffer(char *ptr, size_t eltsize, size_t nmemb, void *buffer_)
159169
{
160170
size_t size = eltsize * nmemb;
@@ -302,6 +312,22 @@ static int http_options(const char *var, const char *value, void *cb)
302312
curl_ssl_try = git_config_bool(var, value);
303313
return 0;
304314
}
315+
if (!strcmp("http.sslbackend", var)) {
316+
free(http_ssl_backend);
317+
http_ssl_backend = xstrdup_or_null(value);
318+
return 0;
319+
}
320+
321+
if (!strcmp("http.schannelcheckrevoke", var)) {
322+
http_schannel_check_revoke = git_config_bool(var, value);
323+
return 0;
324+
}
325+
326+
if (!strcmp("http.schannelusesslcainfo", var)) {
327+
http_schannel_use_ssl_cainfo = git_config_bool(var, value);
328+
return 0;
329+
}
330+
305331
if (!strcmp("http.minsessions", var)) {
306332
min_curl_sessions = git_config_int(var, value);
307333
#ifndef USE_CURL_MULTI
@@ -803,6 +829,16 @@ static CURL *get_curl_handle(void)
803829
}
804830
#endif
805831

832+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
833+
!http_schannel_check_revoke) {
834+
#if LIBCURL_VERSION_NUM >= 0x072c00
835+
curl_easy_setopt(result, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NO_REVOKE);
836+
#else
837+
warning("CURLSSLOPT_NO_REVOKE not applied to curl SSL options because\n"
838+
"your curl version is too old (< 7.44.0)");
839+
#endif
840+
}
841+
806842
if (http_proactive_auth)
807843
init_curl_http_auth(result);
808844

@@ -844,7 +880,13 @@ static CURL *get_curl_handle(void)
844880
if (ssl_pinnedkey != NULL)
845881
curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
846882
#endif
847-
if (ssl_cainfo != NULL)
883+
if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
884+
!http_schannel_use_ssl_cainfo) {
885+
curl_easy_setopt(result, CURLOPT_CAINFO, NULL);
886+
#if LIBCURL_VERSION_NUM >= 0x073400
887+
curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL);
888+
#endif
889+
} else if (ssl_cainfo != NULL)
848890
curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
849891

850892
if (curl_low_speed_limit > 0 && curl_low_speed_time > 0) {
@@ -995,6 +1037,33 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
9951037
git_config(urlmatch_config_entry, &config);
9961038
free(normalized_url);
9971039

1040+
#if LIBCURL_VERSION_NUM >= 0x073800
1041+
if (http_ssl_backend) {
1042+
const curl_ssl_backend **backends;
1043+
struct strbuf buf = STRBUF_INIT;
1044+
int i;
1045+
1046+
switch (curl_global_sslset(-1, http_ssl_backend, &backends)) {
1047+
case CURLSSLSET_UNKNOWN_BACKEND:
1048+
strbuf_addf(&buf, _("Unsupported SSL backend '%s'. "
1049+
"Supported SSL backends:"),
1050+
http_ssl_backend);
1051+
for (i = 0; backends[i]; i++)
1052+
strbuf_addf(&buf, "\n\t%s", backends[i]->name);
1053+
die("%s", buf.buf);
1054+
case CURLSSLSET_NO_BACKENDS:
1055+
die(_("Could not set SSL backend to '%s': "
1056+
"cURL was built without SSL backends"),
1057+
http_ssl_backend);
1058+
case CURLSSLSET_TOO_LATE:
1059+
die(_("Could not set SSL backend to '%s': already set"),
1060+
http_ssl_backend);
1061+
case CURLSSLSET_OK:
1062+
break; /* Okay! */
1063+
}
1064+
}
1065+
#endif
1066+
9981067
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK)
9991068
die("curl_global_init failed");
10001069

0 commit comments

Comments
 (0)