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

@ -44,23 +44,21 @@ void print_version()
void print_files()
{
const char *branch = 0;
const char *remote = 0;
const char *filename, *local_git;
struct git_info info = { };
const char *filename;
printf("\nFile locations:\n\n");
printf("Cloud email:%s\n", prefs.cloud_storage_email);
if (!empty_string(prefs.cloud_storage_email) && !empty_string(prefs.cloud_storage_password)) {
filename = cloud_url();
is_git_repository(filename, &branch, &remote, true);
is_git_repository(filename, &info);
} else {
/* strdup so the free below works in either case */
filename = strdup("No valid cloud credentials set.\n");
}
if (branch && remote) {
local_git = get_local_dir(remote, branch);
printf("Local git storage: %s\n", local_git);
if (info.localdir) {
printf("Local git storage: %s\n", info.localdir);
} else {
printf("Unable to get local git directory\n");
}