From d73c94b21c58d78a7bf268bc9e3b0f4daa11e514 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Sat, 19 May 2012 20:24:55 +0700 Subject: Fix spelling errors. --- include/git2/oid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index c06458d24..a05b40a37 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -84,7 +84,7 @@ GIT_EXTERN(void) git_oid_fmt(char *str, const git_oid *oid); * Format a git_oid into a loose-object path string. * * The resulting string is "aa/...", where "aa" is the first two - * hex digitis of the oid and "..." is the remaining 38 digits. + * hex digits of the oid and "..." is the remaining 38 digits. * * @param str output hex string; must be pointing at the start of * the hex sequence and have at least the number of bytes -- cgit v1.2.3 From b8457baae24269c9fb777591e2a0e1b425ba31b6 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Tue, 24 Jul 2012 07:57:58 +0200 Subject: portability: Improve x86/amd64 compatibility --- include/git2/oid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index a05b40a37..4d0796480 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -147,7 +147,7 @@ GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *b); * @param len the number of hex chars to compare * @return 0 in case of a match */ -GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, unsigned int len); +GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len); /** * Check if an oid equals an hex formatted object id. -- cgit v1.2.3 From f6b26e770ffae621408532c5b2c1aae4fa1c9e49 Mon Sep 17 00:00:00 2001 From: Michael Schubert Date: Fri, 27 Jul 2012 10:53:09 +0200 Subject: git_oid_cmp: inline memcmp by hand to optimize git.git uses an inlined hashcmp function instead of memcmp, since it performes much better when comparing hashes (most hashes compared diverge within the first byte). Measurements and rationale for the curious reader: http://thread.gmane.org/gmane.comp.version-control.git/172286 --- include/git2/oid.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index a05b40a37..d6b2d1e7f 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -136,7 +136,31 @@ GIT_EXTERN(void) git_oid_cpy(git_oid *out, const git_oid *src); * @param b second oid structure. * @return <0, 0, >0 if a < b, a == b, a > b. */ -GIT_EXTERN(int) git_oid_cmp(const git_oid *a, const git_oid *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; +} + +/** + * Compare two oid structures for equality + * + * @param a first oid structure. + * @param b second oid structure. + * @return true if equal, false otherwise + */ +GIT_INLINE(int) git_oid_equal(const git_oid *a, const git_oid *b) +{ + return !git_oid_cmp(a, b); +} /** * Compare the first 'len' hexadecimal characters (packets of 4 bits) -- cgit v1.2.3 From 5f4a61aea834fe25ce1596bc9c0e0b5e563aa98b Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Thu, 9 Aug 2012 19:43:25 -0700 Subject: Working implementation of git_submodule_status This is a big redesign of the git_submodule_status API and the implementation of the redesigned API. It also fixes a number of bugs that I found in other parts of the submodule API while writing the tests for the status part. This also fixes a couple of bugs in the iterators that had not been noticed before - one with iterating when there is a gitlink (i.e. separate-work-dir) and one where I was treating anything even vaguely submodule-like as a submodule, more aggressively than core git does. --- include/git2/oid.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index 887b33e50..9e54a9f96 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -185,6 +185,8 @@ GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str); /** * Check is an oid is all zeros. + * + * @return 1 if all zeros, 0 otherwise. */ GIT_EXTERN(int) git_oid_iszero(const git_oid *a); -- cgit v1.2.3 From 74f9132212a1c634c45241852dbd8564427e964b Mon Sep 17 00:00:00 2001 From: Ben Straub Date: Tue, 27 Nov 2012 12:45:44 -0800 Subject: API updates for oid.h --- include/git2/oid.h | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index 9e54a9f96..43717ad70 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -30,11 +30,10 @@ GIT_BEGIN_DECL #define GIT_OID_MINPREFIXLEN 4 /** Unique identity of any object (commit, tree, blob, tag). */ -typedef struct _git_oid git_oid; -struct _git_oid { +typedef struct git_oid { /** raw binary formatted id */ unsigned char id[GIT_OID_RAWSZ]; -}; +} git_oid; /** * Parse a hex formatted object id into a git_oid. @@ -71,14 +70,14 @@ GIT_EXTERN(void) git_oid_fromraw(git_oid *out, const unsigned char *raw); /** * Format a git_oid into a hex string. * - * @param str output hex string; must be pointing at the start of + * @param out output hex string; must be pointing at the start of * the hex sequence and have at least the number of bytes * needed for an oid encoded in hex (40 bytes). Only the * oid digits are written; a '\\0' terminator must be added * by the caller if it is required. * @param oid oid structure to format. */ -GIT_EXTERN(void) git_oid_fmt(char *str, const git_oid *oid); +GIT_EXTERN(void) git_oid_fmt(char *out, const git_oid *id); /** * Format a git_oid into a loose-object path string. @@ -86,14 +85,14 @@ GIT_EXTERN(void) git_oid_fmt(char *str, const git_oid *oid); * The resulting string is "aa/...", where "aa" is the first two * hex digits of the oid and "..." is the remaining 38 digits. * - * @param str output hex string; must be pointing at the start of + * @param out output hex string; must be pointing at the start of * the hex sequence and have at least the number of bytes * needed for an oid encoded in hex (41 bytes). Only the * oid digits are written; a '\\0' terminator must be added * by the caller if it is required. - * @param oid oid structure to format. + * @param id oid structure to format. */ -GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid); +GIT_EXTERN(void) git_oid_pathfmt(char *out, const git_oid *id); /** * Format a git_oid into a newly allocated c-string. @@ -102,7 +101,7 @@ GIT_EXTERN(void) git_oid_pathfmt(char *str, const git_oid *oid); * @return the c-string; NULL if memory is exhausted. Caller must * deallocate the string with git__free(). */ -GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid); +GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *id); /** * Format a git_oid into a buffer as a hex format c-string. @@ -115,11 +114,11 @@ GIT_EXTERN(char *) git_oid_allocfmt(const git_oid *oid); * * @param out the buffer into which the oid string is output. * @param n the size of the out buffer. - * @param oid the oid structure to format. + * @param id the oid structure to format. * @return the out buffer pointer, assuming no input parameter * errors, otherwise a pointer to an empty string. */ -GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *oid); +GIT_EXTERN(char *) git_oid_tostr(char *out, size_t n, const git_oid *id); /** * Copy an oid from one structure to another. @@ -176,19 +175,19 @@ GIT_EXTERN(int) git_oid_ncmp(const git_oid *a, const git_oid *b, size_t len); /** * Check if an oid equals an hex formatted object id. * - * @param a oid structure. + * @param id oid structure. * @param str input hex string of an object id. * @return GIT_ENOTOID if str is not a valid hex string, * 0 in case of a match, GIT_ERROR otherwise. */ -GIT_EXTERN(int) git_oid_streq(const git_oid *a, const char *str); +GIT_EXTERN(int) git_oid_streq(const git_oid *id, const char *str); /** * Check is an oid is all zeros. * * @return 1 if all zeros, 0 otherwise. */ -GIT_EXTERN(int) git_oid_iszero(const git_oid *a); +GIT_EXTERN(int) git_oid_iszero(const git_oid *id); /** * OID Shortener object @@ -230,12 +229,12 @@ GIT_EXTERN(git_oid_shorten *) git_oid_shorten_new(size_t min_length); * GIT_ENOMEM error * * @param os a `git_oid_shorten` instance - * @param text_oid an OID in text form + * @param text_id an OID in text form * @return the minimal length to uniquely identify all OIDs * added so far to the set; or an error code (<0) if an * error occurs. */ -GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_oid); +GIT_EXTERN(int) git_oid_shorten_add(git_oid_shorten *os, const char *text_id); /** * Free an OID shortener instance -- cgit v1.2.3 From 359fc2d241ac407bdf9bf0d28715705f01ca6360 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Tue, 8 Jan 2013 17:07:25 -0600 Subject: update copyrights --- include/git2/oid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index 43717ad70..6be02da6e 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2012 the libgit2 contributors + * Copyright (C) the libgit2 contributors. All rights reserved. * * This file is part of libgit2, distributed under the GNU GPL v2 with * a Linking Exception. For full terms see the included COPYING file. -- cgit v1.2.3 From 0c8efb38f9ffb1c4fffe620174669c51866eff79 Mon Sep 17 00:00:00 2001 From: Xavier L Date: Thu, 21 Mar 2013 11:59:01 -0400 Subject: Added an oid function that accepts nul-terminated strings --- include/git2/oid.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index 6be02da6e..d2f3f4a14 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -46,6 +46,16 @@ typedef struct git_oid { */ GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str); +/** + * Parse a hex formatted null-terminated string into a git_oid. + * + * @param out oid structure the result is written into. + * @param str input hex string; must be at least 4 characters + * long and null-terminated. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str); + /** * Parse N characters of a hex formatted object id into a git_oid * -- cgit v1.2.3 From 37ee70fab4e6dcf35afc08c0edbe9f101d4abf2d Mon Sep 17 00:00:00 2001 From: Russell Belfer Date: Mon, 25 Mar 2013 22:19:39 -0700 Subject: Implement GIT_STATUS_OPT_EXCLUDE_SUBMODULES This option has been sitting unimplemented for a while, so I finally went through and implemented it along with some tests. As part of this, I improved the implementation of GIT_DIFF_IGNORE_SUBMODULES so it be more diligent about avoiding extra work and about leaving off delta records for submodules to the greatest extent possible (though it may include them still if you are request TYPECHANGE records). --- include/git2/oid.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2/oid.h') diff --git a/include/git2/oid.h b/include/git2/oid.h index d2f3f4a14..862f4b202 100644 --- a/include/git2/oid.h +++ b/include/git2/oid.h @@ -51,7 +51,7 @@ GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str); * * @param out oid structure the result is written into. * @param str input hex string; must be at least 4 characters - * long and null-terminated. + * long and null-terminated. * @return 0 or an error code */ GIT_EXTERN(int) git_oid_fromstrp(git_oid *out, const char *str); -- cgit v1.2.3