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
61bef72d
Commit
61bef72d
authored
May 20, 2014
by
Alan Rogers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start adding GIT_DELTA_UNREADABLE and GIT_STATUS_WT_UNREADABLE.
parent
f47bc8ff
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
3 deletions
+36
-3
include/git2/diff.h
+4
-0
include/git2/status.h
+1
-0
src/checkout.c
+2
-0
src/diff.c
+20
-2
src/diff_file.c
+1
-0
src/diff_print.c
+2
-0
src/diff_tform.c
+3
-1
src/status.c
+3
-0
No files found.
include/git2/diff.h
View file @
61bef72d
...
...
@@ -191,6 +191,9 @@ typedef enum {
* can apply given diff information to binary files.
*/
GIT_DIFF_SHOW_BINARY
=
(
1
<<
30
),
/** Include unreadable files in the diff */
GIT_DIFF_INCLUDE_UNREADABLE
=
(
1
<<
31
),
}
git_diff_option_t
;
/**
...
...
@@ -237,6 +240,7 @@ typedef enum {
GIT_DELTA_IGNORED
=
6
,
/** entry is ignored item in workdir */
GIT_DELTA_UNTRACKED
=
7
,
/** entry is untracked item in workdir */
GIT_DELTA_TYPECHANGE
=
8
,
/** type of entry changed between old and new */
GIT_DELTA_UNREADABLE
=
9
,
/** entry is unreadable */
}
git_delta_t
;
/**
...
...
include/git2/status.h
View file @
61bef72d
...
...
@@ -43,6 +43,7 @@ typedef enum {
GIT_STATUS_WT_DELETED
=
(
1u
<<
9
),
GIT_STATUS_WT_TYPECHANGE
=
(
1u
<<
10
),
GIT_STATUS_WT_RENAMED
=
(
1u
<<
11
),
GIT_STATUS_WT_UNREADABLE
=
(
1u
<<
12
),
GIT_STATUS_IGNORED
=
(
1u
<<
14
),
}
git_status_t
;
...
...
src/checkout.c
View file @
61bef72d
...
...
@@ -116,6 +116,7 @@ static int checkout_notify(
case
GIT_DELTA_ADDED
:
case
GIT_DELTA_IGNORED
:
case
GIT_DELTA_UNTRACKED
:
case
GIT_DELTA_UNREADABLE
:
target
=
&
delta
->
new_file
;
break
;
case
GIT_DELTA_DELETED
:
...
...
@@ -2063,6 +2064,7 @@ int git_checkout_iterator(
diff_opts
.
flags
=
GIT_DIFF_INCLUDE_UNMODIFIED
|
GIT_DIFF_INCLUDE_UNREADABLE
|
GIT_DIFF_INCLUDE_UNTRACKED
|
GIT_DIFF_RECURSE_UNTRACKED_DIRS
|
/* needed to match baseline */
GIT_DIFF_INCLUDE_IGNORED
|
...
...
src/diff.c
View file @
61bef72d
...
...
@@ -93,6 +93,10 @@ static int diff_delta__from_one(
DIFF_FLAG_ISNT_SET
(
diff
,
GIT_DIFF_INCLUDE_UNTRACKED
))
return
0
;
if
(
status
==
GIT_DELTA_UNREADABLE
&&
DIFF_FLAG_ISNT_SET
(
diff
,
GIT_DIFF_INCLUDE_UNREADABLE
))
return
0
;
if
(
!
git_pathspec__match
(
&
diff
->
pathspec
,
entry
->
path
,
DIFF_FLAG_IS_SET
(
diff
,
GIT_DIFF_DISABLE_PATHSPEC_MATCH
),
...
...
@@ -201,6 +205,11 @@ static git_diff_delta *diff_delta__last_for_item(
git_oid__cmp
(
&
delta
->
new_file
.
id
,
&
item
->
id
)
==
0
)
return
delta
;
break
;
case
GIT_DELTA_UNREADABLE
:
if
(
diff
->
strcomp
(
delta
->
new_file
.
path
,
item
->
path
)
==
0
&&
git_oid__cmp
(
&
delta
->
new_file
.
id
,
&
item
->
id
)
==
0
)
return
delta
;
break
;
case
GIT_DELTA_MODIFIED
:
if
(
git_oid__cmp
(
&
delta
->
old_file
.
id
,
&
item
->
id
)
==
0
||
git_oid__cmp
(
&
delta
->
new_file
.
id
,
&
item
->
id
)
==
0
)
...
...
@@ -293,6 +302,10 @@ bool git_diff_delta__should_skip(
(
flags
&
GIT_DIFF_INCLUDE_UNTRACKED
)
==
0
)
return
true
;
if
(
delta
->
status
==
GIT_DELTA_UNREADABLE
&&
(
flags
&
GIT_DIFF_INCLUDE_UNREADABLE
)
==
0
)
return
true
;
return
false
;
}
...
...
@@ -924,19 +937,24 @@ static int handle_unmatched_new_item(
if
(
recurse_into_dir
)
{
error
=
git_iterator_advance_into
(
&
info
->
nitem
,
info
->
new_iter
);
printf
(
"error advancing into diff %d
\n
"
,
error
);
if
(
error
==
GIT_EUNREADABLE
)
{
delta_type
=
GIT_DELTA_UNREADABLE
;
}
else
{
/* if real error or no error, proceed with iteration */
if
(
error
!=
GIT_ENOTFOUND
&&
error
!=
GIT_EUNREADABLE
)
if
(
error
!=
GIT_ENOTFOUND
)
return
error
;
giterr_clear
();
/* if directory is empty, can't advance into it, so either skip
* it or ignore it
*/
if
(
contains_oitem
&&
error
!=
GIT_EUNREADABLE
)
if
(
contains_oitem
)
return
git_iterator_advance
(
&
info
->
nitem
,
info
->
new_iter
);
delta_type
=
GIT_DELTA_IGNORED
;
}
}
}
/* In core git, the next two checks are effectively reversed --
* i.e. when an file contained in an ignored directory is explicitly
...
...
src/diff_file.c
View file @
61bef72d
...
...
@@ -112,6 +112,7 @@ int git_diff_file_content__init_from_diff(
has_data
=
!
use_old
&&
(
diff
->
opts
.
flags
&
GIT_DIFF_SHOW_UNTRACKED_CONTENT
)
!=
0
;
break
;
case
GIT_DELTA_UNREADABLE
:
case
GIT_DELTA_MODIFIED
:
case
GIT_DELTA_COPIED
:
case
GIT_DELTA_RENAMED
:
...
...
src/diff_print.c
View file @
61bef72d
...
...
@@ -89,6 +89,7 @@ char git_diff_status_char(git_delta_t status)
case
GIT_DELTA_COPIED
:
code
=
'C'
;
break
;
case
GIT_DELTA_IGNORED
:
code
=
'I'
;
break
;
case
GIT_DELTA_UNTRACKED
:
code
=
'?'
;
break
;
case
GIT_DELTA_UNREADABLE
:
code
=
'X'
;
break
;
default:
code
=
' '
;
break
;
}
...
...
@@ -414,6 +415,7 @@ static int diff_print_patch_file(
if
(
S_ISDIR
(
delta
->
new_file
.
mode
)
||
delta
->
status
==
GIT_DELTA_UNMODIFIED
||
delta
->
status
==
GIT_DELTA_IGNORED
||
delta
->
status
==
GIT_DELTA_UNREADABLE
||
(
delta
->
status
==
GIT_DELTA_UNTRACKED
&&
(
pi
->
flags
&
GIT_DIFF_SHOW_UNTRACKED_CONTENT
)
==
0
))
return
0
;
...
...
src/diff_tform.c
View file @
61bef72d
...
...
@@ -114,7 +114,7 @@ static git_diff_delta *diff_delta__merge_like_cgit_reversed(
if
((
dup
=
diff_delta__dup
(
a
,
pool
))
==
NULL
)
return
NULL
;
if
(
b
->
status
==
GIT_DELTA_UNMODIFIED
||
b
->
status
==
GIT_DELTA_UNTRACKED
)
if
(
b
->
status
==
GIT_DELTA_UNMODIFIED
||
b
->
status
==
GIT_DELTA_UNTRACKED
||
b
->
status
==
GIT_DELTA_UNREADABLE
)
return
dup
;
if
(
dup
->
status
==
GIT_DELTA_DELETED
)
{
...
...
@@ -732,6 +732,7 @@ static bool is_rename_source(
switch
(
delta
->
status
)
{
case
GIT_DELTA_ADDED
:
case
GIT_DELTA_UNTRACKED
:
case
GIT_DELTA_UNREADABLE
:
case
GIT_DELTA_IGNORED
:
return
false
;
...
...
@@ -786,6 +787,7 @@ GIT_INLINE(bool) delta_is_new_only(git_diff_delta *delta)
{
return
(
delta
->
status
==
GIT_DELTA_ADDED
||
delta
->
status
==
GIT_DELTA_UNTRACKED
||
delta
->
status
==
GIT_DELTA_UNREADABLE
||
delta
->
status
==
GIT_DELTA_IGNORED
);
}
...
...
src/status.c
View file @
61bef72d
...
...
@@ -62,6 +62,9 @@ static unsigned int workdir_delta2status(
case
GIT_DELTA_UNTRACKED
:
st
=
GIT_STATUS_WT_NEW
;
break
;
case
GIT_DELTA_UNREADABLE
:
st
=
GIT_STATUS_WT_UNREADABLE
;
break
;
case
GIT_DELTA_DELETED
:
st
=
GIT_STATUS_WT_DELETED
;
break
;
...
...
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