-
Notifications
You must be signed in to change notification settings - Fork 2.5k
git_clone supports init_options #1850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
if (!(retcode = git_repository_init(&repo, local_path, normOptions.bare))) { | ||
if (!(retcode = normOptions.init_options | ||
? git_repository_init_ext(&repo, local_path, normOptions.init_options) | ||
: git_repository_init(&repo, local_path, normOptions.bare))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably better to address this in normalize_options
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should clarify a bit. It turns out that git_repository_init
is a wrapper around git_repository_init_ext
, so let's just use the _ext
variant.
This probably means dropping the bare
option, in favor of setting the GIT_REPOSITORY_INIT_BARE
bit on init_options.flags
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we have to duplicate the code from git_repository_init(), isn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one line of it.
if (!dst->init_options) {
git_repository_init_options dummy_options = GIT_REPOSITORY_INIT_OPTIONS_INIT;
opts.flags = GIT_REPOSITORY_INIT_MKPATH;
dst->init_options = /* allocate and check allocation */;
memcpy(dst->init_options, &dummy_options, sizeof(git_repository_init_options);
}
If the caller wants a bare repo, they'll provide a valid init_options
and set the proper flag. If they don't, they get the default options. The only hitch is that you'll have to track that allocation somehow, and free it later (maybe just a stack variable in do_clone
?).
I'm definitely 👍 on this. Clone landed before |
Commit updated |
I'm still thinking of 💀ing the |
@@ -427,6 +427,13 @@ static void normalize_options(git_clone_options *dst, const git_clone_options *s | |||
|
|||
/* Provide defaults for null pointers */ | |||
if (!dst->remote_name) dst->remote_name = "origin"; | |||
if (!dst->init_options) | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please keep an eye out for brackets and consistency? :)
git_clone supports init_options
git_clone supports init_options