/
Clone.pm6
93 lines (69 loc) · 2.27 KB
/
Clone.pm6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
use NativeCall;
use Git::Error;
use Git::Checkout;
use Git::Remote;
# git_clone_local_t
enum Git::Clone::Local <
GIT_CLONE_LOCAL_AUTO
GIT_CLONE_LOCAL
GIT_CLONE_NO_LOCAL
GIT_CLONE_LOCAL_NOLINKS
>;
class Git::Clone::Options is repr('CStruct')
{
has uint32 $.version = 1;
HAS Git::Checkout::Options $.checkout-opts;
HAS Git::Fetch::Options $.fetch-opts;
has int32 $.bare;
has int32 $.local;
has Str $.checkout-branch;
has Pointer $.repository-cb;
has Pointer $.repository-cb-payload;
has Pointer $.remote-cb;
has Pointer $.remote-cb-payload;
sub git_clone_init_options(Git::Clone::Options, uint32 --> int32)
is native('git2') {}
submethod BUILD(Bool :$bare,
Str :$local where 'auto'|'local'|'no'|'no-links' = 'auto',
Str :$checkout-branch,
|opts)
{
check(git_clone_init_options(self, 1));
if opts
{
$!checkout-opts.BUILD(|opts);
$!fetch-opts.BUILD(|opts);
}
$!bare = $bare ?? 1 !! 0;
$!local = do given $local
{
when 'auto' { GIT_CLONE_LOCAL_AUTO }
when 'local' { GIT_CLONE_LOCAL }
when 'no' { GIT_CLONE_NO_LOCAL }
when 'no-links' { GIT_CLONE_LOCAL_NOLINKS }
}
$!checkout-branch := $checkout-branch if $checkout-branch;
}
}
=begin pod
=head1 NAME
Git::Clone::Options
=head1 SYNOPSIS
=head1 DESCRIPTION
=head2 OPTIONS
=item B<:bare> - Set for a bare repo
=item Str B<:local >
Options for bypassing the git-aware transport on clone. Bypassing it
means that instead of a fetch, libgit2 will copy the object database
directory instead of figuring out what it needs, which is faster. If
possible, it will hardlink the files to save space.
'auto' - Auto-detect (default), libgit2 will bypass the git-aware
transport for local paths, but use a normal fetch for
C<file://> urls.
'local' - Bypass the git-aware transport even for a C<file://> url.
'no' - Do no bypass the git-aware transport
'no-links' - Bypass the git-aware transport, but do not try to use
hardlinks.
=item Str B<:checkout-branch> - The name of the branch to checkout
instead of the remote's default branch.
=end pod