Collect and convert git repo data to 'struct git_info'

We have this nasty habit of randomly passing down all the different
things that we use to look up the local and remote git repository, and
the information associated with it.

Start collecting the data into a 'struct git_info' instead, so that it
is easier to manage, and easier and more logical to just look up
different parts of the puzzle.

This is a fairly mechanical conversion, but has moved all the basic
information collection to the 'is_git_repository()' function.  That
function no longer actually opens the repository (so the 'dry_run'
argument is gone, and instead a successful 'is_git_repository()' is
followed by 'opn_git_repository()' if you actually want the old
non-dry_run semantics.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Linus Torvalds 2022-04-13 06:43:37 -10:00 committed by Dirk Hohndel
parent acc4dc57af
commit 7e632173e0
11 changed files with 365 additions and 349 deletions

View file

@ -198,20 +198,20 @@ void CheckCloudConnection::gotContinent(QNetworkReply *reply)
}
// helper to be used from C code
extern "C" bool canReachCloudServer(const char **remote)
extern "C" bool canReachCloudServer(struct git_info *info)
{
if (verbose)
qWarning() << "Cloud storage: checking connection to cloud server" << *remote;
qWarning() << "Cloud storage: checking connection to cloud server" << info->url;
bool connection = CheckCloudConnection().checkServer();
if (strstr(*remote, prefs.cloud_base_url) == nullptr) {
if (strstr(info->url, prefs.cloud_base_url) == nullptr) {
// we switched the cloud URL - likely because we couldn't reach the server passed in
// the strstr with the offset is designed so we match the right component in the name;
// the cloud_base_url ends with a '/', so we need the text starting at "git/..."
char *newremote = format_string("%s%s", prefs.cloud_base_url, strstr(*remote, "org/git/") + 4);
char *newremote = format_string("%s%s", prefs.cloud_base_url, strstr(info->url, "org/git/") + 4);
if (verbose)
qDebug() << "updating remote to: " << newremote;
free((void*)*remote);
*remote = newremote;
free((void*)info->url);
info->url = newremote;
}
return connection;
}