Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
c7c83394
Commit
c7c83394
authored
Feb 21, 2014
by
Juan Rubén
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to limit blame to first parent
parent
e0ebaaa5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
2 deletions
+11
-2
examples/blame.c
+5
-0
include/git2/blame.h
+2
-0
src/blame_git.c
+4
-2
No files found.
examples/blame.c
View file @
c7c83394
...
...
@@ -31,6 +31,7 @@ struct opts {
int
M
;
int
start_line
;
int
end_line
;
int
F
;
};
static
void
parse_opts
(
struct
opts
*
o
,
int
argc
,
char
*
argv
[]);
...
...
@@ -52,6 +53,7 @@ int main(int argc, char *argv[])
parse_opts
(
&
o
,
argc
,
argv
);
if
(
o
.
M
)
blameopts
.
flags
|=
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_MOVES
;
if
(
o
.
C
)
blameopts
.
flags
|=
GIT_BLAME_TRACK_COPIES_SAME_COMMIT_COPIES
;
if
(
o
.
F
)
blameopts
.
flags
|=
GIT_BLAME_FIRST_PARENT
;
/** Open the repository. */
check_lg2
(
git_repository_open_ext
(
&
repo
,
"."
,
0
,
NULL
),
"Couldn't open repository"
,
NULL
);
...
...
@@ -146,6 +148,7 @@ static void usage(const char *msg, const char *arg)
fprintf
(
stderr
,
" -L <n,m> process only line range n-m, counting from 1
\n
"
);
fprintf
(
stderr
,
" -M find line moves within and across files
\n
"
);
fprintf
(
stderr
,
" -C find line copies within and across files
\n
"
);
fprintf
(
stderr
,
" -F only care about the first parent
\n
"
);
fprintf
(
stderr
,
"
\n
"
);
exit
(
1
);
}
...
...
@@ -174,6 +177,8 @@ static void parse_opts(struct opts *o, int argc, char *argv[])
o
->
M
=
1
;
else
if
(
!
strcasecmp
(
a
,
"-C"
))
o
->
C
=
1
;
else
if
(
!
strcasecmp
(
a
,
"-F"
))
o
->
F
=
1
;
else
if
(
!
strcasecmp
(
a
,
"-L"
))
{
i
++
;
a
=
argv
[
i
];
if
(
i
>=
argc
)
fatal
(
"Not enough arguments to -L"
,
NULL
);
...
...
include/git2/blame.h
View file @
c7c83394
...
...
@@ -40,6 +40,8 @@ typedef enum {
* commit (like `git blame -CCC`). Implies SAME_COMMIT_COPIES.
* NOT IMPLEMENTED. */
GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES
=
(
1
<<
3
),
GIT_BLAME_FIRST_PARENT
=
(
1
<<
4
),
}
git_blame_flag_t
;
/**
...
...
src/blame_git.c
View file @
c7c83394
...
...
@@ -485,12 +485,14 @@ static void pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt
git_blame__origin
*
sg_buf
[
16
];
git_blame__origin
*
porigin
,
**
sg_origin
=
sg_buf
;
GIT_UNUSED
(
opt
);
num_parents
=
git_commit_parentcount
(
commit
);
if
(
!
git_oid_cmp
(
git_commit_id
(
commit
),
&
blame
->
options
.
oldest_commit
))
/* Stop at oldest specified commit */
num_parents
=
0
;
else
if
(
opt
&
GIT_BLAME_FIRST_PARENT
)
/* Limit search to the first parent */
num_parents
=
1
;
if
(
!
num_parents
)
{
git_oid_cpy
(
&
blame
->
options
.
oldest_commit
,
git_commit_id
(
commit
));
goto
finish
;
...
...
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