redactGitArguments function
arguments joined by spaces for display, with the value of every HTTP
extra-header configuration argument replaced by ***.
The -c http.extraHeader=value spelling (two arguments) and the attached
-chttp.extraHeader=value spelling are both masked, as are their
http.<url>.extraHeader variants, whatever the case of the key. The key
stays visible. The values are masked argument by argument, before the
join, because a value may contain spaces. URL userinfo is masked too, as
by redactUrlUserinfo.
Implementation
String redactGitArguments(List<String> arguments) {
final List<String> redacted = <String>[];
for (var index = 0; index < arguments.length; index++) {
final String argument = arguments[index];
if (argument == '-c' && index + 1 < arguments.length) {
redacted
..add(argument)
..add(_redactConfigArgument(arguments[index + 1]));
index++;
} else if (argument.startsWith('-c') && argument.length > 2) {
redacted.add('-c${_redactConfigArgument(argument.substring(2))}');
} else {
redacted.add(argument);
}
}
return redactUrlUserinfo(redacted.join(' '));
}