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
e62171e2
Commit
e62171e2
authored
Dec 17, 2012
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1151 from arrbee/fix-diff-constructor-names
Fix diff constructor names
parents
0d10e79d
ba084f7a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
66 additions
and
66 deletions
+66
-66
examples/Makefile
+1
-1
examples/diff.c
+7
-7
include/git2/diff.h
+0
-0
src/checkout.c
+1
-1
src/diff.c
+3
-3
src/stash.c
+3
-3
src/status.c
+2
-2
src/submodule.c
+2
-2
tests-clar/diff/diffiter.c
+11
-11
tests-clar/diff/index.c
+5
-5
tests-clar/diff/workdir.c
+31
-31
No files found.
examples/Makefile
View file @
e62171e2
.PHONY
:
all
CC
=
gcc
CFLAGS
=
-g
-I
../include
-I
../src
-Wall
-Wextra
-Wmissing-prototypes
CFLAGS
=
-g
-I
../include
-I
../src
-Wall
-Wextra
-Wmissing-prototypes
-Wno-missing-field-initializers
LFLAGS
=
-L
../build
-lgit2
-lz
APPS
=
general showindex diff
...
...
examples/diff.c
View file @
e62171e2
...
...
@@ -110,12 +110,12 @@ static int check_uint16_param(const char *arg, const char *pattern, uint16_t *va
return
1
;
}
static
int
check_str_param
(
const
char
*
arg
,
const
char
*
pattern
,
char
**
val
)
static
int
check_str_param
(
const
char
*
arg
,
const
char
*
pattern
,
c
onst
c
har
**
val
)
{
size_t
len
=
strlen
(
pattern
);
if
(
strncmp
(
arg
,
pattern
,
len
))
return
0
;
*
val
=
(
char
*
)(
arg
+
len
);
*
val
=
(
c
onst
c
har
*
)(
arg
+
len
);
return
1
;
}
...
...
@@ -206,20 +206,20 @@ int main(int argc, char *argv[])
if
(
t1
&&
t2
)
check
(
git_diff_tree_to_tree
(
&
diff
,
repo
,
t1
,
t2
,
&
opts
),
"Diff"
);
else
if
(
t1
&&
cached
)
check
(
git_diff_
index_to_tree
(
&
diff
,
repo
,
t1
,
NULL
,
&
opts
),
"Diff"
);
check
(
git_diff_
tree_to_index
(
&
diff
,
repo
,
t1
,
NULL
,
&
opts
),
"Diff"
);
else
if
(
t1
)
{
git_diff_list
*
diff2
;
check
(
git_diff_
index_to_tree
(
&
diff
,
repo
,
t1
,
NULL
,
&
opts
),
"Diff"
);
check
(
git_diff_
workdir_to_index
(
&
diff2
,
repo
,
NULL
,
&
opts
),
"Diff"
);
check
(
git_diff_
tree_to_index
(
&
diff
,
repo
,
t1
,
NULL
,
&
opts
),
"Diff"
);
check
(
git_diff_
index_to_workdir
(
&
diff2
,
repo
,
NULL
,
&
opts
),
"Diff"
);
check
(
git_diff_merge
(
diff
,
diff2
),
"Merge diffs"
);
git_diff_list_free
(
diff2
);
}
else
if
(
cached
)
{
check
(
resolve_to_tree
(
repo
,
"HEAD"
,
&
t1
),
"looking up HEAD"
);
check
(
git_diff_
index_to_tree
(
&
diff
,
repo
,
t1
,
NULL
,
&
opts
),
"Diff"
);
check
(
git_diff_
tree_to_index
(
&
diff
,
repo
,
t1
,
NULL
,
&
opts
),
"Diff"
);
}
else
check
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
),
"Diff"
);
check
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
),
"Diff"
);
if
(
color
>=
0
)
fputs
(
colors
[
0
],
stdout
);
...
...
include/git2/diff.h
View file @
e62171e2
This diff is collapsed.
Click to expand it.
src/checkout.c
View file @
e62171e2
...
...
@@ -632,7 +632,7 @@ int git_checkout_index(
if
(
opts
&&
opts
->
paths
.
count
>
0
)
diff_opts
.
pathspec
=
opts
->
paths
;
if
((
error
=
git_diff_
workdir_to_index
(
&
diff
,
repo
,
index
,
&
diff_opts
))
<
0
)
if
((
error
=
git_diff_
index_to_workdir
(
&
diff
,
repo
,
index
,
&
diff_opts
))
<
0
)
goto
cleanup
;
if
((
error
=
git_buf_puts
(
&
workdir
,
git_repository_workdir
(
repo
)))
<
0
)
...
...
src/diff.c
View file @
e62171e2
...
...
@@ -784,7 +784,7 @@ int git_diff_tree_to_tree(
return
error
;
}
int
git_diff_
index_to_tree
(
int
git_diff_
tree_to_index
(
git_diff_list
**
diff
,
git_repository
*
repo
,
git_tree
*
old_tree
,
...
...
@@ -806,7 +806,7 @@ int git_diff_index_to_tree(
return
error
;
}
int
git_diff_
workdir_to_index
(
int
git_diff_
index_to_workdir
(
git_diff_list
**
diff
,
git_repository
*
repo
,
git_index
*
index
,
...
...
@@ -828,7 +828,7 @@ int git_diff_workdir_to_index(
}
int
git_diff_
workdir_to_tree
(
int
git_diff_
tree_to_workdir
(
git_diff_list
**
diff
,
git_repository
*
repo
,
git_tree
*
old_tree
,
...
...
src/stash.c
View file @
e62171e2
...
...
@@ -251,7 +251,7 @@ static int build_untracked_tree(
if
(
git_commit_tree
(
&
i_tree
,
i_commit
)
<
0
)
goto
cleanup
;
if
(
git_diff_
workdir_to_tree
(
&
diff
,
git_index_owner
(
index
),
i_tree
,
&
opts
)
<
0
)
if
(
git_diff_
tree_to_workdir
(
&
diff
,
git_index_owner
(
index
),
i_tree
,
&
opts
)
<
0
)
goto
cleanup
;
if
(
git_diff_foreach
(
diff
,
update_index_cb
,
NULL
,
NULL
,
&
data
)
<
0
)
...
...
@@ -323,10 +323,10 @@ static int build_workdir_tree(
if
(
git_commit_tree
(
&
b_tree
,
b_commit
)
<
0
)
goto
cleanup
;
if
(
git_diff_
index_to_tree
(
&
diff
,
repo
,
b_tree
,
NULL
,
&
opts
)
<
0
)
if
(
git_diff_
tree_to_index
(
&
diff
,
repo
,
b_tree
,
NULL
,
&
opts
)
<
0
)
goto
cleanup
;
if
(
git_diff_
workdir_to_index
(
&
diff2
,
repo
,
NULL
,
&
opts
)
<
0
)
if
(
git_diff_
index_to_workdir
(
&
diff2
,
repo
,
NULL
,
&
opts
)
<
0
)
goto
cleanup
;
if
(
git_diff_merge
(
diff
,
diff2
)
<
0
)
...
...
src/status.c
View file @
e62171e2
...
...
@@ -145,11 +145,11 @@ int git_status_foreach_ext(
/* TODO: support EXCLUDE_SUBMODULES flag */
if
(
show
!=
GIT_STATUS_SHOW_WORKDIR_ONLY
&&
(
err
=
git_diff_
index_to_tree
(
&
idx2head
,
repo
,
head
,
NULL
,
&
diffopt
))
<
0
)
(
err
=
git_diff_
tree_to_index
(
&
idx2head
,
repo
,
head
,
NULL
,
&
diffopt
))
<
0
)
goto
cleanup
;
if
(
show
!=
GIT_STATUS_SHOW_INDEX_ONLY
&&
(
err
=
git_diff_
workdir_to_index
(
&
wd2idx
,
repo
,
NULL
,
&
diffopt
))
<
0
)
(
err
=
git_diff_
index_to_workdir
(
&
wd2idx
,
repo
,
NULL
,
&
diffopt
))
<
0
)
goto
cleanup
;
usercb
.
cb
=
cb
;
...
...
src/submodule.c
View file @
e62171e2
...
...
@@ -1454,7 +1454,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
if
(
sm
->
ignore
==
GIT_SUBMODULE_IGNORE_NONE
)
opt
.
flags
|=
GIT_DIFF_INCLUDE_UNTRACKED
;
error
=
git_diff_
index_to_tree
(
&
diff
,
sm_repo
,
sm_head
,
NULL
,
&
opt
);
error
=
git_diff_
tree_to_index
(
&
diff
,
sm_repo
,
sm_head
,
NULL
,
&
opt
);
if
(
!
error
)
{
if
(
git_diff_num_deltas
(
diff
)
>
0
)
...
...
@@ -1471,7 +1471,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
/* perform index-to-workdir diff on submodule */
error
=
git_diff_
workdir_to_index
(
&
diff
,
sm_repo
,
NULL
,
&
opt
);
error
=
git_diff_
index_to_workdir
(
&
diff
,
sm_repo
,
NULL
,
&
opt
);
if
(
!
error
)
{
size_t
untracked
=
...
...
tests-clar/diff/diffiter.c
View file @
e62171e2
...
...
@@ -16,7 +16,7 @@ void test_diff_diffiter__create(void)
git_diff_list
*
diff
;
size_t
d
,
num_d
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
NULL
));
num_d
=
git_diff_num_deltas
(
diff
);
for
(
d
=
0
;
d
<
num_d
;
++
d
)
{
...
...
@@ -34,7 +34,7 @@ void test_diff_diffiter__iterate_files(void)
size_t
d
,
num_d
;
int
count
=
0
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
NULL
));
num_d
=
git_diff_num_deltas
(
diff
);
cl_assert_equal_i
(
6
,
(
int
)
num_d
);
...
...
@@ -57,7 +57,7 @@ void test_diff_diffiter__iterate_files_2(void)
size_t
d
,
num_d
;
int
count
=
0
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
NULL
));
num_d
=
git_diff_num_deltas
(
diff
);
cl_assert_equal_i
(
8
,
(
int
)
num_d
);
...
...
@@ -85,7 +85,7 @@ void test_diff_diffiter__iterate_files_and_hunks(void)
opts
.
interhunk_lines
=
1
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
num_d
=
git_diff_num_deltas
(
diff
);
...
...
@@ -138,7 +138,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts
.
interhunk_lines
=
1
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
num_d
=
git_diff_num_deltas
(
diff
);
for
(
d
=
0
;
d
<
num_d
;
++
d
)
{
...
...
@@ -173,7 +173,7 @@ void test_diff_diffiter__max_size_threshold(void)
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
opts
.
max_size
=
50
;
/* treat anything over 50 bytes as binary! */
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
num_d
=
git_diff_num_deltas
(
diff
);
for
(
d
=
0
;
d
<
num_d
;
++
d
)
{
...
...
@@ -216,7 +216,7 @@ void test_diff_diffiter__iterate_all(void)
opts
.
interhunk_lines
=
1
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
num_d
=
git_diff_num_deltas
(
diff
);
for
(
d
=
0
;
d
<
num_d
;
++
d
)
{
...
...
@@ -292,7 +292,7 @@ void test_diff_diffiter__iterate_randomly_while_saving_state(void)
opts
.
interhunk_lines
=
1
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
num_d
=
git_diff_num_deltas
(
diff
);
...
...
@@ -419,7 +419,7 @@ void test_diff_diffiter__iterate_and_generate_patch_text(void)
git_diff_list
*
diff
;
size_t
d
,
num_d
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
NULL
));
num_d
=
git_diff_num_deltas
(
diff
);
cl_assert_equal_i
(
8
,
(
int
)
num_d
);
...
...
@@ -452,13 +452,13 @@ void test_diff_diffiter__checks_options_version(void)
opts
.
version
=
0
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
cl_git_fail
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
));
cl_git_fail
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
giterr_clear
();
opts
.
version
=
1024
;
cl_git_fail
(
git_diff_
workdir_to_index
(
&
diff
,
repo
,
NULL
,
&
opts
));
cl_git_fail
(
git_diff_
index_to_workdir
(
&
diff
,
repo
,
NULL
,
&
opts
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
}
...
...
tests-clar/diff/index.c
View file @
e62171e2
...
...
@@ -32,7 +32,7 @@ void test_diff_index__0(void)
memset
(
&
exp
,
0
,
sizeof
(
exp
));
cl_git_pass
(
git_diff_
index_to_tree
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_index
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_foreach
(
diff
,
diff_file_cb
,
diff_hunk_cb
,
diff_line_cb
,
&
exp
));
...
...
@@ -60,7 +60,7 @@ void test_diff_index__0(void)
diff
=
NULL
;
memset
(
&
exp
,
0
,
sizeof
(
exp
));
cl_git_pass
(
git_diff_
index_to_tree
(
&
diff
,
g_repo
,
b
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_index
(
&
diff
,
g_repo
,
b
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_foreach
(
diff
,
diff_file_cb
,
diff_hunk_cb
,
diff_line_cb
,
&
exp
));
...
...
@@ -125,7 +125,7 @@ void test_diff_index__1(void)
memset
(
&
exp
,
0
,
sizeof
(
exp
));
cl_git_pass
(
git_diff_
index_to_tree
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_index
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_assert_equal_i
(
GIT_EUSER
,
...
...
@@ -150,13 +150,13 @@ void test_diff_index__checks_options_version(void)
const
git_error
*
err
;
opts
.
version
=
0
;
cl_git_fail
(
git_diff_
index_to_tree
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_git_fail
(
git_diff_
tree_to_index
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
giterr_clear
();
opts
.
version
=
1024
;
cl_git_fail
(
git_diff_
index_to_tree
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_git_fail
(
git_diff_
tree_to_index
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
}
...
...
tests-clar/diff/workdir.c
View file @
e62171e2
...
...
@@ -26,7 +26,7 @@ void test_diff_workdir__to_index(void)
opts
.
interhunk_lines
=
1
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -84,7 +84,7 @@ void test_diff_workdir__to_tree(void)
opts
.
interhunk_lines
=
1
;
opts
.
flags
|=
GIT_DIFF_INCLUDE_IGNORED
|
GIT_DIFF_INCLUDE_UNTRACKED
;
/* You can't really generate the equivalent of git_diff_
workdir_to_tree
()
/* You can't really generate the equivalent of git_diff_
tree_to_workdir
()
* using C git. It really wants to interpose the index into the diff.
*
* To validate the following results with command line git, I ran the
...
...
@@ -94,7 +94,7 @@ void test_diff_workdir__to_tree(void)
* The results are documented at the bottom of this file in the
* long comment entitled "PREPARATION OF TEST DATA".
*/
cl_git_pass
(
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
a
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
a
,
&
opts
));
for
(
use_iterator
=
0
;
use_iterator
<=
1
;
use_iterator
++
)
{
memset
(
&
exp
,
0
,
sizeof
(
exp
));
...
...
@@ -127,8 +127,8 @@ void test_diff_workdir__to_tree(void)
* a workdir to tree diff (even though it is not really). This is what
* you would get from "git diff --name-status 26a125ee1bf"
*/
cl_git_pass
(
git_diff_
index_to_tree
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff2
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_index
(
&
diff
,
g_repo
,
a
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff2
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_merge
(
diff
,
diff2
));
git_diff_list_free
(
diff2
);
...
...
@@ -164,8 +164,8 @@ void test_diff_workdir__to_tree(void)
/* Again, emulating "git diff <sha>" for testing purposes using
* "git diff --name-status 0017bd4ab1ec3" instead.
*/
cl_git_pass
(
git_diff_
index_to_tree
(
&
diff
,
g_repo
,
b
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff2
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_index
(
&
diff
,
g_repo
,
b
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff2
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_merge
(
diff
,
diff2
));
git_diff_list_free
(
diff2
);
...
...
@@ -216,7 +216,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
opts
.
pathspec
.
strings
=
&
pathspec
;
opts
.
pathspec
.
count
=
1
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -239,7 +239,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec
=
"modified_file"
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -262,7 +262,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec
=
"subdir"
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -285,7 +285,7 @@ void test_diff_workdir__to_index_with_pathspec(void)
pathspec
=
"*_deleted"
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -324,7 +324,7 @@ void test_diff_workdir__filemode_changes(void)
/* test once with no mods */
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
g_repo
,
NULL
,
NULL
));
for
(
use_iterator
=
0
;
use_iterator
<=
1
;
use_iterator
++
)
{
memset
(
&
exp
,
0
,
sizeof
(
exp
));
...
...
@@ -347,7 +347,7 @@ void test_diff_workdir__filemode_changes(void)
cl_assert
(
cl_toggle_filemode
(
"issue_592/a.txt"
));
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
g_repo
,
NULL
,
NULL
));
for
(
use_iterator
=
0
;
use_iterator
<=
1
;
use_iterator
++
)
{
memset
(
&
exp
,
0
,
sizeof
(
exp
));
...
...
@@ -386,7 +386,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
/* test once with no mods */
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
g_repo
,
NULL
,
NULL
));
memset
(
&
exp
,
0
,
sizeof
(
exp
));
cl_git_pass
(
git_diff_foreach
(
...
...
@@ -402,7 +402,7 @@ void test_diff_workdir__filemode_changes_with_filemode_false(void)
cl_assert
(
cl_toggle_filemode
(
"issue_592/a.txt"
));
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
NULL
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
g_repo
,
NULL
,
NULL
));
memset
(
&
exp
,
0
,
sizeof
(
exp
));
cl_git_pass
(
git_diff_foreach
(
...
...
@@ -442,8 +442,8 @@ void test_diff_workdir__head_index_and_workdir_all_differ(void)
opts
.
pathspec
.
strings
=
&
pathspec
;
opts
.
pathspec
.
count
=
1
;
cl_git_pass
(
git_diff_
index_to_tree
(
&
diff_i2t
,
g_repo
,
tree
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff_w2i
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_index
(
&
diff_i2t
,
g_repo
,
tree
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff_w2i
,
g_repo
,
NULL
,
&
opts
));
for
(
use_iterator
=
0
;
use_iterator
<=
1
;
use_iterator
++
)
{
memset
(
&
exp
,
0
,
sizeof
(
exp
));
...
...
@@ -529,7 +529,7 @@ void test_diff_workdir__eof_newline_changes(void)
opts
.
pathspec
.
strings
=
&
pathspec
;
opts
.
pathspec
.
count
=
1
;
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -556,7 +556,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_append2file
(
"status/current_file"
,
"
\n
"
);
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -583,7 +583,7 @@ void test_diff_workdir__eof_newline_changes(void)
cl_git_rewritefile
(
"status/current_file"
,
"current_file"
);
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
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
));
...
...
@@ -611,7 +611,7 @@ void test_diff_workdir__eof_newline_changes(void)
/* PREPARATION OF TEST DATA
*
* Since there is no command line equivalent of git_diff_
workdir_to_tree
,
* Since there is no command line equivalent of git_diff_
tree_to_workdir
,
* it was a bit of a pain to confirm that I was getting the expected
* results in the first part of this tests. Here is what I ended up
* doing to set my expectation for the file counts and results:
...
...
@@ -699,13 +699,13 @@ void test_diff_workdir__larger_hunks(void)
/* okay, this is a bit silly, but oh well */
switch
(
i
)
{
case
0
:
cl_git_pass
(
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
index_to_workdir
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
break
;
case
1
:
cl_git_pass
(
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
a
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
a
,
&
opts
));
break
;
case
2
:
cl_git_pass
(
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
b
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
b
,
&
opts
));
break
;
}
...
...
@@ -748,7 +748,7 @@ void test_diff_workdir__larger_hunks(void)
/* Set up a test that exercises this code. The easiest test using existing
* test data is probably to create a sandbox of submod2 and then run a
* git_diff_
workdir_to_tree
against tree
* git_diff_
tree_to_workdir
against tree
* 873585b94bdeabccea991ea5e3ec1a277895b698. As for what you should actually
* test, you can start by just checking that the number of lines of diff
* content matches the actual output of git diff. That will at least
...
...
@@ -784,7 +784,7 @@ void test_diff_workdir__submodules(void)
GIT_DIFF_RECURSE_UNTRACKED_DIRS
|
GIT_DIFF_INCLUDE_UNTRACKED_CONTENT
;
cl_git_pass
(
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
a
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
a
,
&
opts
));
/* diff_print(stderr, diff); */
...
...
@@ -829,12 +829,12 @@ void test_diff_workdir__cannot_diff_against_a_bare_repository(void)
g_repo
=
cl_git_sandbox_init
(
"testrepo.git"
);
cl_assert_equal_i
(
GIT_EBAREREPO
,
git_diff_
workdir_to_index
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
GIT_EBAREREPO
,
git_diff_
index_to_workdir
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_repository_head_tree
(
&
tree
,
g_repo
));
cl_assert_equal_i
(
GIT_EBAREREPO
,
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
tree
,
&
opts
));
GIT_EBAREREPO
,
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
tree
,
&
opts
));
git_tree_free
(
tree
);
}
...
...
@@ -850,7 +850,7 @@ void test_diff_workdir__to_null_tree(void)
g_repo
=
cl_git_sandbox_init
(
"status"
);
cl_git_pass
(
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
cl_git_pass
(
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
memset
(
&
exp
,
0
,
sizeof
(
exp
));
...
...
@@ -871,13 +871,13 @@ void test_diff_workdir__checks_options_version(void)
g_repo
=
cl_git_sandbox_init
(
"status"
);
opts
.
version
=
0
;
cl_git_fail
(
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
cl_git_fail
(
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
giterr_clear
();
opts
.
version
=
1024
;
cl_git_fail
(
git_diff_
workdir_to_tree
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
cl_git_fail
(
git_diff_
tree_to_workdir
(
&
diff
,
g_repo
,
NULL
,
&
opts
));
err
=
giterr_last
();
cl_assert_equal_i
(
GITERR_INVALID
,
err
->
klass
);
}
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