Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Ben Boeckel
rust-git-workarea
Commits
b68441b1
Commit
b68441b1
authored
Aug 28, 2018
by
Ben Boeckel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rustfmt: reformat `where` clauses
parent
e5d3e65b
Pipeline
#115492
passed with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
22 deletions
+34
-22
src/git.rs
src/git.rs
+24
-16
src/prepare.rs
src/prepare.rs
+10
-6
No files found.
src/git.rs
View file @
b68441b1
...
...
@@ -57,8 +57,9 @@ pub struct Identity {
impl
Identity
{
/// Create a new identity.
pub
fn
new
<
N
,
E
>
(
name
:
N
,
email
:
E
)
->
Self
where
N
:
ToString
,
E
:
ToString
,
where
N
:
ToString
,
E
:
ToString
,
{
Self
{
name
:
name
.to_string
(),
...
...
@@ -105,7 +106,8 @@ impl Display for MergeStatus {
impl
GitContext
{
/// Create a new context for the given directory.
pub
fn
new
<
P
>
(
gitdir
:
P
)
->
Self
where
P
:
AsRef
<
Path
>
,
where
P
:
AsRef
<
Path
>
,
{
Self
{
gitdir
:
gitdir
.as_ref
()
.to_path_buf
(),
...
...
@@ -115,8 +117,9 @@ impl GitContext {
/// Create a new context for the given directory with git configuration.
pub
fn
new_with_config
<
P
,
C
>
(
gitdir
:
P
,
config
:
C
)
->
Self
where
P
:
AsRef
<
Path
>
,
C
:
AsRef
<
Path
>
,
where
P
:
AsRef
<
Path
>
,
C
:
AsRef
<
Path
>
,
{
Self
{
gitdir
:
gitdir
.as_ref
()
.to_path_buf
(),
...
...
@@ -143,9 +146,10 @@ impl GitContext {
///
/// The remote is interpreted by Git, so it can be a remote or a specific URL.
pub
fn
fetch
<
R
,
I
,
N
>
(
&
self
,
remote
:
R
,
refnames
:
I
)
->
Result
<
()
>
where
R
:
AsRef
<
str
>
,
I
:
IntoIterator
<
Item
=
N
>
,
N
:
AsRef
<
OsStr
>
,
where
R
:
AsRef
<
str
>
,
I
:
IntoIterator
<
Item
=
N
>
,
N
:
AsRef
<
OsStr
>
,
{
let
fetch
=
self
.git
()
...
...
@@ -165,9 +169,10 @@ impl GitContext {
/// Fetch a commit from the given remote into a specific local refname.
pub
fn
fetch_into
<
R
,
N
,
T
>
(
&
self
,
remote
:
R
,
refname
:
N
,
target
:
T
)
->
Result
<
()
>
where
R
:
AsRef
<
str
>
,
N
:
AsRef
<
str
>
,
T
:
AsRef
<
str
>
,
where
R
:
AsRef
<
str
>
,
N
:
AsRef
<
str
>
,
T
:
AsRef
<
str
>
,
{
self
.fetch
(
remote
,
&
[
&
format!
(
"{}:{}"
,
refname
.as_ref
(),
target
.as_ref
())])
...
...
@@ -175,9 +180,10 @@ impl GitContext {
/// Fetch a commit from the given remote into a specific local refname, allowing rewinds.
pub
fn
force_fetch_into
<
R
,
N
,
T
>
(
&
self
,
remote
:
R
,
refname
:
N
,
target
:
T
)
->
Result
<
()
>
where
R
:
AsRef
<
str
>
,
N
:
AsRef
<
str
>
,
T
:
AsRef
<
str
>
,
where
R
:
AsRef
<
str
>
,
N
:
AsRef
<
str
>
,
T
:
AsRef
<
str
>
,
{
self
.fetch_into
(
remote
.as_ref
(),
format!
(
"+{}"
,
refname
.as_ref
()),
...
...
@@ -196,7 +202,8 @@ impl GitContext {
/// The reserved reference is created as `refs/{name}/heads/{id}` where `id` is a unique
/// integer (which is also returned).
pub
fn
reserve_ref
<
N
>
(
&
self
,
name
:
N
,
commit
:
&
CommitId
)
->
Result
<
(
String
,
usize
)
>
where
N
:
AsRef
<
str
>
,
where
N
:
AsRef
<
str
>
,
{
let
ref_prefix
=
format!
(
"refs/{}/heads"
,
name
.as_ref
());
...
...
@@ -260,7 +267,8 @@ impl GitContext {
/// It is assumed that the `bases` refs are aligned with the `heads` references and not used
/// for other purposes.
pub
fn
reserve_refs
<
N
>
(
&
self
,
name
:
N
,
commit
:
&
CommitId
)
->
Result
<
(
String
,
String
)
>
where
N
:
AsRef
<
str
>
,
where
N
:
AsRef
<
str
>
,
{
let
(
new_ref
,
id
)
=
self
.reserve_ref
(
name
.as_ref
(),
commit
)
?
;
let
new_base
=
format!
(
"refs/{}/bases/{}"
,
name
.as_ref
(),
id
);
...
...
src/prepare.rs
View file @
b68441b1
...
...
@@ -96,7 +96,8 @@ impl<'a> MergeCommand<'a> {
///
/// Returns the ID of the merge commit itself.
pub
fn
commit
<
M
>
(
self
,
message
:
M
)
->
Result
<
CommitId
>
where
M
:
AsRef
<
str
>
,
where
M
:
AsRef
<
str
>
,
{
self
.commit_impl
(
message
.as_ref
())
}
...
...
@@ -191,8 +192,9 @@ trait WorkareaGitContext {
/// Checkout a set of paths into a workarea.
fn
checkout
<
I
,
P
>
(
ctx
:
&
WorkareaGitContext
,
paths
:
I
)
->
Result
<
()
>
where
I
:
IntoIterator
<
Item
=
P
>
,
P
:
AsRef
<
OsStr
>
,
where
I
:
IntoIterator
<
Item
=
P
>
,
P
:
AsRef
<
OsStr
>
,
{
let
ls_files
=
ctx
.cmd
()
...
...
@@ -509,7 +511,8 @@ impl GitWorkArea {
/// Figure out if there's a possible resolution for the submodule.
fn
submodule_conflict
<
P
>
(
&
self
,
path
:
P
,
ours
:
&
CommitId
,
theirs
:
&
CommitId
)
->
Result
<
Conflict
>
where
P
:
AsRef
<
Path
>
,
where
P
:
AsRef
<
Path
>
,
{
let
path
=
path
.as_ref
()
.to_path_buf
();
...
...
@@ -655,8 +658,9 @@ impl GitWorkArea {
///
/// All paths supported by Git's globbing and searching mechanisms are supported.
pub
fn
checkout
<
I
,
P
>
(
&
mut
self
,
paths
:
I
)
->
Result
<
()
>
where
I
:
IntoIterator
<
Item
=
P
>
,
P
:
AsRef
<
OsStr
>
,
where
I
:
IntoIterator
<
Item
=
P
>
,
P
:
AsRef
<
OsStr
>
,
{
checkout
(
self
,
paths
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment