git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] Add streq() to compat-util
@ 2008-01-07  5:47 Christian Thaeter
  2008-01-07  5:47 ` [PATCH 2/5] First step, making setup (somewhat) reentrant Christian Thaeter
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Thaeter @ 2008-01-07  5:47 UTC (permalink / raw)
  To: git; +Cc: gitster, Christian Thaeter

streq() compares strings for equality, it differs from strcmp() in that
it can handle NULL pointers and that it short-circruits if a==b.

returns 1 if the strings are equal (or both are NULL) and 0 when not.

Signed-off-by: Christian Thaeter <ct@pipapo.org>
---
Here comes a series of patches to reinit libgit with subsequent
setup_git_directory() calls. So far, this only suffices for simple
tasks like scanning a list of repositories (buiding the start page
of a repository browser). There are still a lot of things not
fixed yet (grep for '\tstatic', object & graft cache etc.).
Nevertheless, it works for me so far.

 git-compat-util.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index b6ef544..759e94c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -424,4 +424,13 @@ static inline int strtol_i(char const *s, int base, int *result)
 	return 0;
 }
 
+static inline int streq(const char *a, const char* b)
+{
+	if (a == b)
+		return 1;
+	if (a && b)
+		return !strcmp(a, b);
+	return 0;
+}
+
 #endif
-- 
1.5.3.7

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-01-07 11:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-07  5:47 [PATCH 1/5] Add streq() to compat-util Christian Thaeter
2008-01-07  5:47 ` [PATCH 2/5] First step, making setup (somewhat) reentrant Christian Thaeter
2008-01-07  5:47   ` [PATCH 3/5] provide a reset_packed_git() function Christian Thaeter
2008-01-07  5:47     ` [PATCH 4/5] Export some more functions to enable resetting the git state Christian Thaeter
2008-01-07  5:47       ` [PATCH 5/5] Make setup_git_directory reentrant Christian Thaeter
2008-01-07  8:50   ` [PATCH 2/5] First step, making setup (somewhat) reentrant Johannes Schindelin
2008-01-07  9:22     ` Junio C Hamano
2008-01-07 11:28       ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).