git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Christian Thaeter <ct@pipapo.org>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Christian Thaeter <ct@pipapo.org>
Subject: [PATCH 1/5] Add streq() to compat-util
Date: Mon,  7 Jan 2008 06:47:31 +0100	[thread overview]
Message-ID: <1199684855-14246-1-git-send-email-ct@pipapo.org> (raw)

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

             reply	other threads:[~2008-01-07  5:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-07  5:47 Christian Thaeter [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1199684855-14246-1-git-send-email-ct@pipapo.org \
    --to=ct@pipapo.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).