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
b7f167da
Commit
b7f167da
authored
Apr 29, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make git_oid_cmp public and add git_oid__cmp
parent
aa8f0101
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
28 additions
and
39 deletions
+28
-39
include/git2/oid.h
+1
-13
src/attr.c
+1
-1
src/checkout.c
+3
-3
src/clone.c
+1
-1
src/diff.c
+5
-5
src/diff_output.c
+2
-2
src/diff_tform.c
+1
-1
src/index.c
+1
-1
src/indexer.c
+2
-2
src/odb.c
+1
-1
src/oid.c
+2
-2
src/pack.c
+3
-3
src/push.c
+1
-1
src/refs.c
+1
-1
src/refs.h
+1
-0
src/remote.c
+1
-1
src/transports/local.c
+1
-1
No files found.
include/git2/oid.h
View file @
b7f167da
...
...
@@ -154,19 +154,7 @@ GIT_EXTERN(int) git_oid_compare(const git_oid *oid_a, const git_oid *oid_b);
* @param b second oid structure.
* @return <0, 0, >0 if a < b, a == b, a > b.
*/
GIT_INLINE
(
int
)
git_oid_cmp
(
const
git_oid
*
a
,
const
git_oid
*
b
)
{
const
unsigned
char
*
sha1
=
a
->
id
;
const
unsigned
char
*
sha2
=
b
->
id
;
int
i
;
for
(
i
=
0
;
i
<
GIT_OID_RAWSZ
;
i
++
,
sha1
++
,
sha2
++
)
{
if
(
*
sha1
!=
*
sha2
)
return
*
sha1
-
*
sha2
;
}
return
0
;
}
GIT_EXTERN
(
int
)
git_oid_cmp
(
const
git_oid
*
a
,
const
git_oid
*
b
);
/**
* Compare two oid structures for equality
...
...
src/attr.c
View file @
b7f167da
...
...
@@ -312,7 +312,7 @@ static int load_attr_blob_from_index(
entry
=
git_index_get_byindex
(
index
,
pos
);
if
(
old_oid
&&
git_oid_cmp
(
old_oid
,
&
entry
->
oid
)
==
0
)
if
(
old_oid
&&
git_oid_
_
cmp
(
old_oid
,
&
entry
->
oid
)
==
0
)
return
GIT_ENOTFOUND
;
if
((
error
=
git_blob_lookup
(
blob
,
repo
,
&
entry
->
oid
))
<
0
)
...
...
src/checkout.c
View file @
b7f167da
...
...
@@ -138,7 +138,7 @@ static bool checkout_is_workdir_modified(
if
(
!
sm_oid
)
return
false
;
return
(
git_oid_cmp
(
&
baseitem
->
oid
,
sm_oid
)
!=
0
);
return
(
git_oid_
_
cmp
(
&
baseitem
->
oid
,
sm_oid
)
!=
0
);
}
/* Look at the cache to decide if the workdir is modified. If not,
...
...
@@ -149,7 +149,7 @@ static bool checkout_is_workdir_modified(
if
(
wditem
->
mtime
.
seconds
==
ie
->
mtime
.
seconds
&&
wditem
->
mtime
.
nanoseconds
==
ie
->
mtime
.
nanoseconds
&&
wditem
->
file_size
==
ie
->
file_size
)
return
(
git_oid_cmp
(
&
baseitem
->
oid
,
&
ie
->
oid
)
!=
0
);
return
(
git_oid_
_
cmp
(
&
baseitem
->
oid
,
&
ie
->
oid
)
!=
0
);
}
/* depending on where base is coming from, we may or may not know
...
...
@@ -163,7 +163,7 @@ static bool checkout_is_workdir_modified(
wditem
->
file_size
,
&
oid
)
<
0
)
return
false
;
return
(
git_oid_cmp
(
&
baseitem
->
oid
,
&
oid
)
!=
0
);
return
(
git_oid_
_
cmp
(
&
baseitem
->
oid
,
&
oid
)
!=
0
);
}
#define CHECKOUT_ACTION_IF(FLAG,YES,NO) \
...
...
src/clone.c
View file @
b7f167da
...
...
@@ -132,7 +132,7 @@ static int reference_matches_remote_head(
return
0
;
}
if
(
git_oid_cmp
(
&
head_info
->
remote_head_oid
,
&
oid
)
==
0
)
{
if
(
git_oid_
_
cmp
(
&
head_info
->
remote_head_oid
,
&
oid
)
==
0
)
{
/* Determine the local reference name from the remote tracking one */
if
(
git_refspec_transform_l
(
&
head_info
->
branchname
,
...
...
src/diff.c
View file @
b7f167da
...
...
@@ -196,21 +196,21 @@ static git_diff_delta *diff_delta__last_for_item(
switch
(
delta
->
status
)
{
case
GIT_DELTA_UNMODIFIED
:
case
GIT_DELTA_DELETED
:
if
(
git_oid_cmp
(
&
delta
->
old_file
.
oid
,
&
item
->
oid
)
==
0
)
if
(
git_oid_
_
cmp
(
&
delta
->
old_file
.
oid
,
&
item
->
oid
)
==
0
)
return
delta
;
break
;
case
GIT_DELTA_ADDED
:
if
(
git_oid_cmp
(
&
delta
->
new_file
.
oid
,
&
item
->
oid
)
==
0
)
if
(
git_oid_
_
cmp
(
&
delta
->
new_file
.
oid
,
&
item
->
oid
)
==
0
)
return
delta
;
break
;
case
GIT_DELTA_UNTRACKED
:
if
(
diff
->
strcomp
(
delta
->
new_file
.
path
,
item
->
path
)
==
0
&&
git_oid_cmp
(
&
delta
->
new_file
.
oid
,
&
item
->
oid
)
==
0
)
git_oid_
_
cmp
(
&
delta
->
new_file
.
oid
,
&
item
->
oid
)
==
0
)
return
delta
;
break
;
case
GIT_DELTA_MODIFIED
:
if
(
git_oid_cmp
(
&
delta
->
old_file
.
oid
,
&
item
->
oid
)
==
0
||
git_oid_cmp
(
&
delta
->
new_file
.
oid
,
&
item
->
oid
)
==
0
)
if
(
git_oid_
_
cmp
(
&
delta
->
old_file
.
oid
,
&
item
->
oid
)
==
0
||
git_oid_
_
cmp
(
&
delta
->
new_file
.
oid
,
&
item
->
oid
)
==
0
)
return
delta
;
break
;
default:
...
...
src/diff_output.c
View file @
b7f167da
...
...
@@ -660,7 +660,7 @@ static int diff_patch_load(
*/
if
(
check_if_unmodified
&&
delta
->
old_file
.
mode
==
delta
->
new_file
.
mode
&&
!
git_oid_cmp
(
&
delta
->
old_file
.
oid
,
&
delta
->
new_file
.
oid
))
!
git_oid_
_
cmp
(
&
delta
->
old_file
.
oid
,
&
delta
->
new_file
.
oid
))
{
delta
->
status
=
GIT_DELTA_UNMODIFIED
;
...
...
@@ -1388,7 +1388,7 @@ static int diff_single_apply(diff_single_data *data)
(
has_old
?
GIT_DELTA_MODIFIED
:
GIT_DELTA_ADDED
)
:
(
has_old
?
GIT_DELTA_DELETED
:
GIT_DELTA_UNTRACKED
);
if
(
git_oid_cmp
(
&
delta
->
new_file
.
oid
,
&
delta
->
old_file
.
oid
)
==
0
)
if
(
git_oid_
_
cmp
(
&
delta
->
new_file
.
oid
,
&
delta
->
old_file
.
oid
)
==
0
)
delta
->
status
=
GIT_DELTA_UNMODIFIED
;
if
((
error
=
diff_delta_is_binary_by_content
(
...
...
src/diff_tform.c
View file @
b7f167da
...
...
@@ -429,7 +429,7 @@ static int similarity_measure(
if
(
GIT_MODE_TYPE
(
a_file
->
mode
)
!=
GIT_MODE_TYPE
(
b_file
->
mode
))
return
0
;
if
(
git_oid_cmp
(
&
a_file
->
oid
,
&
b_file
->
oid
)
==
0
)
if
(
git_oid_
_
cmp
(
&
a_file
->
oid
,
&
b_file
->
oid
)
==
0
)
return
100
;
/* update signature cache if needed */
...
...
src/index.c
View file @
b7f167da
...
...
@@ -1411,7 +1411,7 @@ static int parse_index(git_index *index, const char *buffer, size_t buffer_size)
/* 160-bit SHA-1 over the content of the index file before this checksum. */
git_oid_fromraw
(
&
checksum_expected
,
(
const
unsigned
char
*
)
buffer
);
if
(
git_oid_cmp
(
&
checksum_calculated
,
&
checksum_expected
)
!=
0
)
if
(
git_oid_
_
cmp
(
&
checksum_calculated
,
&
checksum_expected
)
!=
0
)
return
index_error_invalid
(
"calculated checksum does not match expected"
);
#undef seek_forward
...
...
src/indexer.c
View file @
b7f167da
...
...
@@ -9,7 +9,6 @@
#include "git2/indexer.h"
#include "git2/object.h"
#include "git2/oid.h"
#include "common.h"
#include "pack.h"
...
...
@@ -17,6 +16,7 @@
#include "posix.h"
#include "pack.h"
#include "filebuf.h"
#include "oid.h"
#include "oidmap.h"
#define UINT31_MAX (0x7FFFFFFF)
...
...
@@ -103,7 +103,7 @@ static int objects_cmp(const void *a, const void *b)
const
struct
entry
*
entrya
=
a
;
const
struct
entry
*
entryb
=
b
;
return
git_oid_cmp
(
&
entrya
->
oid
,
&
entryb
->
oid
);
return
git_oid_
_
cmp
(
&
entrya
->
oid
,
&
entryb
->
oid
);
}
int
git_indexer_stream_new
(
...
...
src/odb.c
View file @
b7f167da
...
...
@@ -764,7 +764,7 @@ attempt_lookup:
git__free
(
data
);
data
=
raw
.
data
;
if
(
found
&&
git_oid_cmp
(
&
full_oid
,
&
found_full_oid
))
if
(
found
&&
git_oid_
_
cmp
(
&
full_oid
,
&
found_full_oid
))
return
git_odb__error_ambiguous
(
"multiple matches for prefix"
);
found_full_oid
=
full_oid
;
...
...
src/oid.c
View file @
b7f167da
...
...
@@ -166,9 +166,9 @@ void git_oid_cpy(git_oid *out, const git_oid *src)
memcpy
(
out
->
id
,
src
->
id
,
sizeof
(
out
->
id
));
}
int
git_oid_c
ompare
(
const
git_oid
*
oid_a
,
const
git_oid
*
oid_
b
)
int
git_oid_c
mp
(
const
git_oid
*
a
,
const
git_oid
*
b
)
{
return
git_oid_
cmp
(
oid_a
,
oid_
b
);
return
git_oid_
_cmp
(
a
,
b
);
}
int
git_oid_ncmp
(
const
git_oid
*
oid_a
,
const
git_oid
*
oid_b
,
size_t
len
)
...
...
src/pack.c
View file @
b7f167da
...
...
@@ -12,8 +12,8 @@
#include "sha1_lookup.h"
#include "mwindow.h"
#include "fileops.h"
#include "oid.h"
#include "git2/oid.h"
#include <zlib.h>
static
int
packfile_open
(
struct
git_pack_file
*
p
);
...
...
@@ -875,7 +875,7 @@ static int packfile_open(struct git_pack_file *p)
idx_sha1
=
((
unsigned
char
*
)
p
->
index_map
.
data
)
+
p
->
index_map
.
len
-
40
;
if
(
git_oid_cmp
(
&
sha1
,
(
git_oid
*
)
idx_sha1
)
==
0
)
if
(
git_oid_
_
cmp
(
&
sha1
,
(
git_oid
*
)
idx_sha1
)
==
0
)
return
0
;
cleanup:
...
...
@@ -1139,7 +1139,7 @@ int git_pack_entry_find(
if
(
len
==
GIT_OID_HEXSZ
&&
p
->
num_bad_objects
)
{
unsigned
i
;
for
(
i
=
0
;
i
<
p
->
num_bad_objects
;
i
++
)
if
(
git_oid_cmp
(
short_oid
,
&
p
->
bad_object_sha1
[
i
])
==
0
)
if
(
git_oid_
_
cmp
(
short_oid
,
&
p
->
bad_object_sha1
[
i
])
==
0
)
return
packfile_error
(
"bad object found in packfile"
);
}
...
...
src/push.c
View file @
b7f167da
...
...
@@ -376,7 +376,7 @@ static int queue_differences(
const
git_tree_entry
*
d_entry
=
git_tree_entry_byindex
(
delta
,
j
);
int
cmp
=
0
;
if
(
!
git_oid_cmp
(
&
b_entry
->
oid
,
&
d_entry
->
oid
))
if
(
!
git_oid_
_
cmp
(
&
b_entry
->
oid
,
&
d_entry
->
oid
))
goto
loop
;
cmp
=
strcmp
(
b_entry
->
filename
,
d_entry
->
filename
);
...
...
src/refs.c
View file @
b7f167da
...
...
@@ -831,7 +831,7 @@ int git_reference_cmp(git_reference *ref1, git_reference *ref2)
if
(
type1
==
GIT_REF_SYMBOLIC
)
return
strcmp
(
ref1
->
target
.
symbolic
,
ref2
->
target
.
symbolic
);
return
git_oid_cmp
(
&
ref1
->
target
.
oid
,
&
ref2
->
target
.
oid
);
return
git_oid_
_
cmp
(
&
ref1
->
target
.
oid
,
&
ref2
->
target
.
oid
);
}
static
int
reference__update_terminal
(
...
...
src/refs.h
View file @
b7f167da
...
...
@@ -13,6 +13,7 @@
#include "git2/refdb.h"
#include "strmap.h"
#include "buffer.h"
#include "oid.h"
#define GIT_REFS_DIR "refs/"
#define GIT_REFS_HEADS_DIR GIT_REFS_DIR "heads/"
...
...
src/remote.c
View file @
b7f167da
...
...
@@ -845,7 +845,7 @@ static int update_tips_for_spec(git_remote *remote, git_refspec *spec, git_vecto
if
(
error
==
GIT_ENOTFOUND
)
memset
(
&
old
,
0
,
GIT_OID_RAWSZ
);
if
(
!
git_oid_cmp
(
&
old
,
&
head
->
oid
))
if
(
!
git_oid_
_
cmp
(
&
old
,
&
head
->
oid
))
continue
;
/* In autotag mode, don't overwrite any locally-existing tags */
...
...
src/transports/local.c
View file @
b7f167da
...
...
@@ -282,7 +282,7 @@ static int local_push_copy_object(
odb_obj_size
)
<
0
||
odb_stream
->
finalize_write
(
&
remote_odb_obj_oid
,
odb_stream
)
<
0
)
{
error
=
-
1
;
}
else
if
(
git_oid_cmp
(
&
obj
->
id
,
&
remote_odb_obj_oid
)
!=
0
)
{
}
else
if
(
git_oid_
_
cmp
(
&
obj
->
id
,
&
remote_odb_obj_oid
)
!=
0
)
{
giterr_set
(
GITERR_ODB
,
"Error when writing object to remote odb "
"during local push operation. Remote odb object oid does not "
"match local oid."
);
...
...
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