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
4a2c4cc9
Commit
4a2c4cc9
authored
Jun 09, 2023
by
Miguel Arroz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#6576 git_diff_index_to_workdir reverse now loads untracked content
parent
2f20fe88
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
1 deletions
+48
-1
src/libgit2/diff_file.c
+1
-1
tests/libgit2/diff/workdir.c
+47
-0
No files found.
src/libgit2/diff_file.c
View file @
4a2c4cc9
...
...
@@ -112,7 +112,7 @@ int git_diff_file_content__init_from_diff(
case
GIT_DELTA_DELETED
:
has_data
=
use_old
;
break
;
case
GIT_DELTA_UNTRACKED
:
has_data
=
!
use_old
&&
has_data
=
(
use_old
==
(
diff
->
opts
.
flags
&
GIT_DIFF_REVERSE
))
&&
(
diff
->
opts
.
flags
&
GIT_DIFF_SHOW_UNTRACKED_CONTENT
)
!=
0
;
break
;
case
GIT_DELTA_UNREADABLE
:
...
...
tests/libgit2/diff/workdir.c
View file @
4a2c4cc9
...
...
@@ -2278,3 +2278,50 @@ void test_diff_workdir__ignore_blank_lines(void)
git_patch_free
(
patch
);
git_diff_free
(
diff
);
}
void
test_diff_workdir__to_index_reversed_content_loads
(
void
)
{
git_diff_options
opts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff
*
diff
=
NULL
;
diff_expects
exp
;
int
use_iterator
;
char
*
pathspec
=
"new_file"
;
g_repo
=
cl_git_sandbox_init
(
"status"
);
opts
.
context_lines
=
3
;
opts
.
interhunk_lines
=
1
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
|
GIT_DIFF_SHOW_UNTRACKED_CONTENT
|
GIT_DIFF_REVERSE
;
opts
.
pathspec
.
strings
=
&
pathspec
;
opts
.
pathspec
.
count
=
1
;
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
for
(
use_iterator
=
0
;
use_iterator
<=
1
;
use_iterator
++
)
{
memset
(
&
exp
,
0
,
sizeof
(
exp
));
if
(
use_iterator
)
cl_git_pass
(
diff_foreach_via_iterator
(
diff
,
diff_file_cb
,
diff_binary_cb
,
diff_hunk_cb
,
diff_line_cb
,
&
exp
));
else
cl_git_pass
(
git_diff_foreach
(
diff
,
diff_file_cb
,
diff_binary_cb
,
diff_hunk_cb
,
diff_line_cb
,
&
exp
));
cl_assert_equal_i
(
1
,
exp
.
files
);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_ADDED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_DELETED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_MODIFIED
]);
cl_assert_equal_i
(
0
,
exp
.
file_status
[
GIT_DELTA_IGNORED
]);
cl_assert_equal_i
(
1
,
exp
.
file_status
[
GIT_DELTA_UNTRACKED
]);
cl_assert_equal_i
(
1
,
exp
.
hunks
);
cl_assert_equal_i
(
1
,
exp
.
lines
);
cl_assert_equal_i
(
0
,
exp
.
line_ctxt
);
cl_assert_equal_i
(
0
,
exp
.
line_adds
);
cl_assert_equal_i
(
1
,
exp
.
line_dels
);
}
git_diff_free
(
diff
);
}
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