# [PATCH 0/5] use starts_with() and ends_with()

17 messages from 2013-12-01 to 2013-12-05. Participants: Christian Couder, Jeff King, Junio C Hamano, Antoine Pelisse.
Thread: https://gitlist.dev/t/35446

## Christian Couder, 2013-12-01 07:49

Subject: [PATCH 0/5] use starts_with() and ends_with()
Message-ID: <20131201074818.3042.57357.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/20131201074818.3042.57357.chriscool%40tuxfamily.org

```
This is a new patch series along the lines Junio suggested in this
thread:

http://thread.gmane.org/gmane.comp.version-control.git/238054/

I send it now because I saw a 1.8.5 tag.

The patches in this series can be related to what Junio suggested
this way:

 * A set of clean-up patches to normalize oddball usages of existing
   functions (e.g. normalize 'prefixcmp(a,b) != 0' in some file(s)
   to 'prefixcmp(a,b)');

-> Patches 1/5 and 2/5 are such kind of cleanups.

 * A single patch to introduce the new function(s), to be applied on
   top of 1.8.5;

-> Patch 3/5 does that.

 * A large patch to convert all uses of prefixcmp to starts_with and
   suffixcmp to ends_with in the 1.8.5 codebase;

-> Patch 4/5 does that.

 * A patch for each topic in flight to convert newly introduced
   prefixcmp/suffixcmp to starts_with/ends_with, to be applied after
   the topic graduates to 'master' after 1.8.5; and then finally

-> I didn't start to work on that yet. I hope that I will only need
   to take care of what is going on in 'next'.

 * A separate patch to remove prefixcmp and suffixcmp, to be applied
   after _all_ in-flight topic has graduated to 'master'.

-> Patch 5/5 does that.


Christian Couder (5):
  environment: normalize use of prefixcmp() by removing " != 0"
  builtin/remote: remove postfixcmp() and use suffixcmp() instead
  strbuf: introduce starts_with() and ends_with()
  Replace {pre,suf}fixcmp() with {starts,ends}_with()
  strbuf: remove prefixcmp() and suffixcmp()

 alias.c                   |  2 +-
 attr.c                    |  2 +-
 bisect.c                  |  4 +--
 branch.c                  |  4 +--
 builtin/apply.c           | 12 +++----
 builtin/archive.c         |  4 +--
 builtin/branch.c          |  6 ++--
 builtin/checkout.c        |  8 ++---
 builtin/clean.c           |  4 +--
 builtin/clone.c           |  8 ++---
 builtin/column.c          |  2 +-
 builtin/commit.c          | 10 +++---
 builtin/describe.c        |  2 +-
 builtin/fast-export.c     |  2 +-
 builtin/fetch-pack.c      |  6 ++--
 builtin/fetch.c           | 18 +++++------
 builtin/fmt-merge-msg.c   | 10 +++---
 builtin/for-each-ref.c    | 14 ++++-----
 builtin/fsck.c            |  6 ++--
 builtin/help.c            |  8 ++---
 builtin/index-pack.c      |  8 ++---
 builtin/init-db.c         |  2 +-
 builtin/log.c             |  8 ++---
 builtin/ls-remote.c       |  4 +--
 builtin/mailinfo.c        | 16 +++++-----
 builtin/merge-recursive.c |  4 +--
 builtin/merge.c           | 12 +++----
 builtin/name-rev.c        |  6 ++--
 builtin/notes.c           |  2 +-
 builtin/pack-objects.c    |  2 +-
 builtin/prune.c           |  4 +--
 builtin/receive-pack.c    |  6 ++--
 builtin/reflog.c          |  4 +--
 builtin/remote.c          | 22 +++++--------
 builtin/repack.c          |  2 +-
 builtin/rev-parse.c       | 24 +++++++-------
 builtin/send-pack.c       |  8 ++---
 builtin/shortlog.c        |  6 ++--
 builtin/show-branch.c     | 20 ++++++------
 builtin/show-ref.c        |  6 ++--
 builtin/symbolic-ref.c    |  2 +-
 builtin/tag.c             |  2 +-
 builtin/tar-tree.c        |  2 +-
 builtin/unpack-objects.c  |  2 +-
 builtin/update-ref.c      | 10 +++---
 builtin/upload-archive.c  |  2 +-
 commit.c                  |  6 ++--
 config.c                  | 16 +++++-----
 connect.c                 |  2 +-
 connected.c               |  2 +-
 convert.c                 |  2 +-
 daemon.c                  | 40 ++++++++++++------------
 diff.c                    | 56 ++++++++++++++++-----------------
 environment.c             |  2 +-
 fast-import.c             | 80 +++++++++++++++++++++++------------------------
 fetch-pack.c              | 12 +++----
 git-compat-util.h         |  4 +--
 git.c                     | 12 +++----
 help.c                    |  8 ++---
 http-backend.c            |  4 +--
 http-push.c               |  4 +--
 http.c                    | 10 +++---
 imap-send.c               | 10 +++---
 log-tree.c                |  8 ++---
 merge-recursive.c         |  6 ++--
 notes-utils.c             |  4 +--
 notes.c                   |  8 ++---
 pager.c                   |  2 +-
 parse-options.c           | 12 +++----
 pathspec.c                |  2 +-
 pkt-line.c                |  4 +--
 pretty.c                  | 36 ++++++++++-----------
 refs.c                    | 30 +++++++++---------
 remote-curl.c             | 14 ++++-----
 remote-testsvn.c          | 10 +++---
 remote.c                  | 46 +++++++++++++--------------
 revision.c                | 38 +++++++++++-----------
 send-pack.c               |  4 +--
 sequencer.c               |  8 ++---
 setup.c                   |  4 +--
 sha1_name.c               | 16 +++++-----
 shell.c                   |  2 +-
 strbuf.c                  | 12 +++----
 submodule.c               |  2 +-
 tag.c                     | 10 +++---
 test-line-buffer.c        |  6 ++--
 test-string-list.c        |  2 +-
 transport-helper.c        | 16 +++++-----
 transport.c               | 28 ++++++++---------
 upload-pack.c             | 10 +++---
 vcs-svn/fast_export.c     | 11 +------
 wt-status.c               | 16 +++++-----
 92 files changed, 469 insertions(+), 486 deletions(-)

-- 
1.8.4.1.561.g12affca

```

## Christian Couder, 2013-12-01 07:49

Subject: [PATCH 1/5] environment: normalize use of prefixcmp() by removing " != 0"
Message-ID: <20131201074919.3042.88989.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/20131201074919.3042.88989.chriscool%40tuxfamily.org
In-Reply-To: <20131201074818.3042.57357.chriscool@tuxfamily.org>

```
To be able to automatically convert prefixcmp() to starts_with()
we need first to make sure that prefixcmp() is always used in
the same way.

So let's remove " != 0" after prefixcmp().

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 environment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/environment.c b/environment.c
index 0a15349..cd2b068 100644
--- a/environment.c
+++ b/environment.c
@@ -171,7 +171,7 @@ const char *get_git_namespace(void)
 
 const char *strip_namespace(const char *namespaced_ref)
 {
-	if (prefixcmp(namespaced_ref, get_git_namespace()) != 0)
+	if (prefixcmp(namespaced_ref, get_git_namespace()))
 		return NULL;
 	return namespaced_ref + namespace_len;
 }
-- 
1.8.4.1.561.g12affca

```

## Christian Couder, 2013-12-01 07:49

Subject: [PATCH 2/5] builtin/remote: remove postfixcmp() and use suffixcmp() instead
Message-ID: <20131201074919.3042.71383.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/20131201074919.3042.71383.chriscool%40tuxfamily.org
In-Reply-To: <20131201074818.3042.57357.chriscool@tuxfamily.org>

```
Commit 8cc5b290 (git merge -X<option>, 25 Nov 2009) introduced
suffixcmp() with nearly the same implementation as postfixcmp()
that already existed since commit 211c8968 (Make git-remote a
builtin, 29 Feb 2008).

The only difference between the two implementations is that,
when the string is smaller than the suffix, one implementation
returns 1 while the other one returns -1.

But, as postfixcmp() is only used to compare for equality, the
distinction does not matter and does not affect the correctness of
this patch.

As postfixcmp() has always been static in builtin/remote.c
and is used nowhere else, it makes more sense to remove it
and use suffixcmp() instead in builtin/remote.c, rather than
to remove suffixcmp().

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin/remote.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/builtin/remote.c b/builtin/remote.c
index 4e14891..9b3a98e 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -80,14 +80,6 @@ static int verbose;
 static int show_all(void);
 static int prune_remote(const char *remote, int dry_run);
 
-static inline int postfixcmp(const char *string, const char *postfix)
-{
-	int len1 = strlen(string), len2 = strlen(postfix);
-	if (len1 < len2)
-		return 1;
-	return strcmp(string + len1 - len2, postfix);
-}
-
 static int fetch_remote(const char *name)
 {
 	const char *argv[] = { "fetch", name, NULL, NULL };
@@ -277,13 +269,13 @@ static int config_read_branches(const char *key, const char *value, void *cb)
 		enum { REMOTE, MERGE, REBASE } type;
 
 		key += 7;
-		if (!postfixcmp(key, ".remote")) {
+		if (!suffixcmp(key, ".remote")) {
 			name = xstrndup(key, strlen(key) - 7);
 			type = REMOTE;
-		} else if (!postfixcmp(key, ".merge")) {
+		} else if (!suffixcmp(key, ".merge")) {
 			name = xstrndup(key, strlen(key) - 6);
 			type = MERGE;
-		} else if (!postfixcmp(key, ".rebase")) {
+		} else if (!suffixcmp(key, ".rebase")) {
 			name = xstrndup(key, strlen(key) - 7);
 			type = REBASE;
 		} else
-- 
1.8.4.1.561.g12affca

```

## Christian Couder, 2013-12-01 07:49

Subject: [PATCH 3/5] strbuf: introduce starts_with() and ends_with()
Message-ID: <20131201074919.3042.28757.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/20131201074919.3042.28757.chriscool%40tuxfamily.org
In-Reply-To: <20131201074818.3042.57357.chriscool@tuxfamily.org>

```
prefixcmp() and suffixcmp() cannot be really used as comparison
functions as they are not antisymmetric:

        prefixcmp("foo", "foobar") < 0
        prefixcmp("foobar", "foo") == 0

So they are not suitable as functions for passing to qsort.
And in fact they are used nowhere as comparison functions.

Therefore we should replace them with functions that just check
for equality.

As a first step toward this goal, this patch introduces
starts_with() and end_with() that will be used to replace
respectively prefixcmp() and suffixcmp().

Some popular programming languages, like Java, Python and Ruby
have functions or methods called like starts_with() and
ends_with() that are doing what we want. Therefore it makes sense
to use such names.

In vcs-svn/fast_export.c, there was already an ends_with()
function that did the same thing. Let's use the new one instead
while at it.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git-compat-util.h     |  2 ++
 strbuf.c              | 18 ++++++++++++++++++
 vcs-svn/fast_export.c | 11 +----------
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 7776f12..b73916b 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -350,7 +350,9 @@ extern void set_die_routine(NORETURN_PTR void (*routine)(const char *err, va_lis
 extern void set_error_routine(void (*routine)(const char *err, va_list params));
 extern void set_die_is_recursing_routine(int (*routine)(void));
 
+extern int starts_with(const char *str, const char *prefix);
 extern int prefixcmp(const char *str, const char *prefix);
+extern int ends_with(const char *str, const char *suffix);
 extern int suffixcmp(const char *str, const char *suffix);
 
 static inline const char *skip_prefix(const char *str, const char *prefix)
diff --git a/strbuf.c b/strbuf.c
index 1170d01..83caf4a 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,6 +1,15 @@
 #include "cache.h"
 #include "refs.h"
 
+int starts_with(const char *str, const char *prefix)
+{
+	for (; ; str++, prefix++)
+		if (!*prefix)
+			return 1;
+		else if (*str != *prefix)
+			return 0;
+}
+
 int prefixcmp(const char *str, const char *prefix)
 {
 	for (; ; str++, prefix++)
@@ -10,6 +19,15 @@ int prefixcmp(const char *str, const char *prefix)
 			return (unsigned char)*prefix - (unsigned char)*str;
 }
 
+int ends_with(const char *str, const char *suffix)
+{
+	int len = strlen(str), suflen = strlen(suffix);
+	if (len < suflen)
+		return 0;
+	else
+		return !strcmp(str + len - suflen, suffix);
+}
+
 int suffixcmp(const char *str, const char *suffix)
 {
 	int len = strlen(str), suflen = strlen(suffix);
diff --git a/vcs-svn/fast_export.c b/vcs-svn/fast_export.c
index f2b23c8..bd0f2c2 100644
--- a/vcs-svn/fast_export.c
+++ b/vcs-svn/fast_export.c
@@ -162,22 +162,13 @@ static void die_short_read(struct line_buffer *input)
 	die("invalid dump: unexpected end of file");
 }
 
-static int ends_with(const char *s, size_t len, const char *suffix)
-{
-	const size_t suffixlen = strlen(suffix);
-	if (len < suffixlen)
-		return 0;
-	return !memcmp(s + len - suffixlen, suffix, suffixlen);
-}
-
 static int parse_cat_response_line(const char *header, off_t *len)
 {
-	size_t headerlen = strlen(header);
 	uintmax_t n;
 	const char *type;
 	const char *end;
 
-	if (ends_with(header, headerlen, " missing"))
+	if (ends_with(header, " missing"))
 		return error("cat-blob reports missing blob: %s", header);
 	type = strstr(header, " blob ");
 	if (!type)
-- 
1.8.4.1.561.g12affca

```

## Christian Couder, 2013-12-01 07:49

Subject: [PATCH 5/5] strbuf: remove prefixcmp() and suffixcmp()
Message-ID: <20131201074919.3042.68588.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/20131201074919.3042.68588.chriscool%40tuxfamily.org
In-Reply-To: <20131201074818.3042.57357.chriscool@tuxfamily.org>

```
As starts_with() and ends_with() have been used to
replace prefixcmp() and suffixcmp() respectively,
we can now remove them.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 git-compat-util.h |  2 --
 strbuf.c          | 18 ------------------
 2 files changed, 20 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index b73916b..c4c01e7 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -351,9 +351,7 @@ extern void set_error_routine(void (*routine)(const char *err, va_list params));
 extern void set_die_is_recursing_routine(int (*routine)(void));
 
 extern int starts_with(const char *str, const char *prefix);
-extern int prefixcmp(const char *str, const char *prefix);
 extern int ends_with(const char *str, const char *suffix);
-extern int suffixcmp(const char *str, const char *suffix);
 
 static inline const char *skip_prefix(const char *str, const char *prefix)
 {
diff --git a/strbuf.c b/strbuf.c
index 83caf4a..ee96dcf 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -10,15 +10,6 @@ int starts_with(const char *str, const char *prefix)
 			return 0;
 }
 
-int prefixcmp(const char *str, const char *prefix)
-{
-	for (; ; str++, prefix++)
-		if (!*prefix)
-			return 0;
-		else if (*str != *prefix)
-			return (unsigned char)*prefix - (unsigned char)*str;
-}
-
 int ends_with(const char *str, const char *suffix)
 {
 	int len = strlen(str), suflen = strlen(suffix);
@@ -28,15 +19,6 @@ int ends_with(const char *str, const char *suffix)
 		return !strcmp(str + len - suflen, suffix);
 }
 
-int suffixcmp(const char *str, const char *suffix)
-{
-	int len = strlen(str), suflen = strlen(suffix);
-	if (len < suflen)
-		return -1;
-	else
-		return strcmp(str + len - suflen, suffix);
-}
-
 /*
  * Used as the default ->buf value, so that people can always assume
  * buf is non NULL and ->buf is NUL terminated even for a freshly
-- 
1.8.4.1.561.g12affca

```

## Jeff King, 2013-12-02 15:09

Subject: Re: [PATCH 0/5] use starts_with() and ends_with()
Message-ID: <20131202150956.GA20543@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20131202150956.GA20543%40sigill.intra.peff.net
In-Reply-To: <20131201074818.3042.57357.chriscool@tuxfamily.org>

```
On Sun, Dec 01, 2013 at 08:49:13AM +0100, Christian Couder wrote:

> This is a new patch series along the lines Junio suggested in this
> thread:
> 
> http://thread.gmane.org/gmane.comp.version-control.git/238054/
> 
> I send it now because I saw a 1.8.5 tag.

This looks sane to me. Your 4/5 did not make it to the list (nor
directly to me), though. Perhaps because it is huge?

-Peff

```

## Junio C Hamano, 2013-12-02 18:32

Subject: Re: [PATCH 0/5] use starts_with() and ends_with()
Message-ID: <xmqq1u1vrtmo.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq1u1vrtmo.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20131202150956.GA20543@sigill.intra.peff.net>

```
Jeff King <peff@peff.net> writes:

> On Sun, Dec 01, 2013 at 08:49:13AM +0100, Christian Couder wrote:
>
>> This is a new patch series along the lines Junio suggested in this
>> thread:
>> 
>> http://thread.gmane.org/gmane.comp.version-control.git/238054/
>> 
>> I send it now because I saw a 1.8.5 tag.
>
> This looks sane to me. Your 4/5 did not make it to the list (nor
> directly to me), though. Perhaps because it is huge?

Nor to me, either.

```

## Christian Couder, 2013-12-02 19:29

Subject: Re: [PATCH 0/5] use starts_with() and ends_with()
Message-ID: <20131202.202952.431769670287377861.chriscool@tuxfamily.org>
URL: https://gitlist.dev/e/20131202.202952.431769670287377861.chriscool%40tuxfamily.org
In-Reply-To: <xmqq1u1vrtmo.fsf@gitster.dls.corp.google.com>

```
From: Junio C Hamano <gitster@pobox.com>
>
> Jeff King <peff@peff.net> writes:
> 
>> On Sun, Dec 01, 2013 at 08:49:13AM +0100, Christian Couder wrote:
>>
>>> This is a new patch series along the lines Junio suggested in this
>>> thread:
>>> 
>>> http://thread.gmane.org/gmane.comp.version-control.git/238054/
>>> 
>>> I send it now because I saw a 1.8.5 tag.
>>
>> This looks sane to me. Your 4/5 did not make it to the list (nor
>> directly to me), though. Perhaps because it is huge?
> 
> Nor to me, either.

Sorry about that I don't know what happened. Maybe my ISP has blocked
it because it is big.

I just tried to send it again.

Best,
Christian.

```

## Antoine Pelisse, 2013-12-02 19:32

Subject: Re: [PATCH 0/5] use starts_with() and ends_with()
Message-ID: <CALWbr2xAcvaH7L=3U=amqK3=Gf-TPOK+X0fJ3u56mGTnUDR+kw@mail.gmail.com>
URL: https://gitlist.dev/e/CALWbr2xAcvaH7L%3D3U%3DamqK3%3DGf-TPOK%2BX0fJ3u56mGTnUDR%2Bkw%40mail.gmail.com
In-Reply-To: <20131202.202952.431769670287377861.chriscool@tuxfamily.org>

```
On Mon, Dec 2, 2013 at 8:29 PM, Christian Couder
<chriscool@tuxfamily.org> wrote:
> From: Junio C Hamano <gitster@pobox.com>
>>
>> Jeff King <peff@peff.net> writes:
>>
>>> On Sun, Dec 01, 2013 at 08:49:13AM +0100, Christian Couder wrote:
>>>
>>>> This is a new patch series along the lines Junio suggested in this
>>>> thread:
>>>>
>>>> http://thread.gmane.org/gmane.comp.version-control.git/238054/
>>>>
>>>> I send it now because I saw a 1.8.5 tag.
>>>
>>> This looks sane to me. Your 4/5 did not make it to the list (nor
>>> directly to me), though. Perhaps because it is huge?
>>
>> Nor to me, either.
>
> Sorry about that I don't know what happened. Maybe my ISP has blocked
> it because it is big.

I don't know, I received it.

```

## Christian Couder, 2013-12-03 06:06

Subject: Re: [PATCH 0/5] use starts_with() and ends_with()
Message-ID: <CAP8UFD2gNv7-W8ERf7Ccypb8BOMvQ6VmncMSfJ6vmAt9PSBtLw@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD2gNv7-W8ERf7Ccypb8BOMvQ6VmncMSfJ6vmAt9PSBtLw%40mail.gmail.com
In-Reply-To: <CALWbr2xAcvaH7L=3U=amqK3=Gf-TPOK+X0fJ3u56mGTnUDR+kw@mail.gmail.com>

```
On Mon, Dec 2, 2013 at 8:32 PM, Antoine Pelisse <apelisse@gmail.com> wrote:
> On Mon, Dec 2, 2013 at 8:29 PM, Christian Couder
> <chriscool@tuxfamily.org> wrote:
>> From: Junio C Hamano <gitster@pobox.com>
>>>
>>> Jeff King <peff@peff.net> writes:
>>>
>>>> This looks sane to me. Your 4/5 did not make it to the list (nor
>>>> directly to me), though. Perhaps because it is huge?
>>>
>>> Nor to me, either.
>>
>> Sorry about that I don't know what happened. Maybe my ISP has blocked
>> it because it is big.
>
> I don't know, I received it.

When I send it to my gmail account, I receive it too.

```

## Jeff King, 2013-12-03 12:46

Subject: Re: Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
Message-ID: <20131203124645.GB26667@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20131203124645.GB26667%40sigill.intra.peff.net
In-Reply-To: <CAP8UFD0jg_Vr7Zf+DiMX9RG6vmmQvmk2NvmL7j=MC-x3fLOOBA@mail.gmail.com>

```
On Tue, Dec 03, 2013 at 08:03:39AM +0100, Christian Couder wrote:

> I am trying to forward this patch from my gmail address, as it doesn't
> seem to go through when I send it from my home machine.

This made it through to me, but not the list. There are at least two
things going on:

  1. The message is 172K, which is over the 100K limit imposed by vger;
     the list is silently dropping it.

  2. In my case, the direct mail was being flagged by spam because it
     contains the blacklisted domain "old.name". Which of course is not
     a domain at all but rather this code:

       old.name = old.path + strlen("refs/heads/");

     I've tweaked my server.

I can't say why it wasn't getting to Junio via direct mail. Maybe the
same spam thing, or maybe something else.

> From: Christian Couder <chriscool@tuxfamily.org>
> Date: Sun, Dec 1, 2013 at 8:49 AM
> Subject: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
> To: christian.couder@gmail.com
> 
> This patch was generated automatically using the following
> commands:
> 
> git grep --name-only prefixcmp | grep -v '\.h' | grep -v 'strbuf.c' |
> xargs perl -pi -e 's/!prefixcmp\(/starts_with\(/g'
> git grep --name-only prefixcmp | grep -v '\.h' | grep -v 'strbuf.c' |
> xargs perl -pi -e 's/prefixcmp\(/!starts_with\(/g'
> git grep --name-only suffixcmp | grep -v '\.h' | grep -v 'strbuf.c' |
> xargs perl -pi -e 's/!suffixcmp\(/ends_with\(/g'
> git grep --name-only suffixcmp | grep -v '\.h' | grep -v 'strbuf.c' |
> xargs perl -pi -e 's/suffixcmp\(/!ends_with\(/g'
> 
> It was generated on version 1.8.5 of the git codebase.

I skimmed the patch and didn't notice any problems. It's
whitespace-damaged by gmail, of course. The simplest thing is probably
to just point us at a public repo with the commit, if you have one.

-Peff

```

## Christian Couder, 2013-12-03 20:24

Subject: Re: Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
Message-ID: <CAP8UFD0By77QVH1amsh85dX6h1S3iFZcmPzs3JjPZmiD_AmOPQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD0By77QVH1amsh85dX6h1S3iFZcmPzs3JjPZmiD_AmOPQ%40mail.gmail.com
In-Reply-To: <20131203124645.GB26667@sigill.intra.peff.net>

```
On Tue, Dec 3, 2013 at 1:46 PM, Jeff King <peff@peff.net> wrote:
>
> This made it through to me, but not the list. There are at least two
> things going on:
>
>   1. The message is 172K, which is over the 100K limit imposed by vger;
>      the list is silently dropping it.
>
>   2. In my case, the direct mail was being flagged by spam because it
>      contains the blacklisted domain "old.name". Which of course is not
>      a domain at all but rather this code:
>
>        old.name = old.path + strlen("refs/heads/");
>
>      I've tweaked my server.
>
> I can't say why it wasn't getting to Junio via direct mail. Maybe the
> same spam thing, or maybe something else.

[...]

> I skimmed the patch and didn't notice any problems. It's
> whitespace-damaged by gmail, of course. The simplest thing is probably
> to just point us at a public repo with the commit, if you have one.

Ok, the commit is in the use_starts_ends_with branch on this github repo:

https://github.com/chriscool/git.git

Thanks,
Christian.

```

## Jeff King, 2013-12-04 19:45

Subject: Re: Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
Message-ID: <20131204194515.GA16603@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20131204194515.GA16603%40sigill.intra.peff.net
In-Reply-To: <CAP8UFD0By77QVH1amsh85dX6h1S3iFZcmPzs3JjPZmiD_AmOPQ@mail.gmail.com>

```
On Tue, Dec 03, 2013 at 09:24:40PM +0100, Christian Couder wrote:

> > I skimmed the patch and didn't notice any problems. It's
> > whitespace-damaged by gmail, of course. The simplest thing is probably
> > to just point us at a public repo with the commit, if you have one.
> 
> Ok, the commit is in the use_starts_ends_with branch on this github repo:
> 
> https://github.com/chriscool/git.git

Thanks. I looked more carefully this time, using a few greps to classify
the surrounding context (since the script you used for the update could
conceivably miss some really odd misuse). The whole thing looks good to
me.

-Peff

```

## Junio C Hamano, 2013-12-04 20:51

Subject: Re: Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
Message-ID: <xmqqk3fkjq5c.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqk3fkjq5c.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CAP8UFD0By77QVH1amsh85dX6h1S3iFZcmPzs3JjPZmiD_AmOPQ@mail.gmail.com>

```
Christian Couder <christian.couder@gmail.com> writes:

> Ok, the commit is in the use_starts_ends_with branch on this github repo:
>
> https://github.com/chriscool/git.git

I looked at the patches, and they looked alright.  The endgame needs
to be on a separate topic to be held until a distant future, though.

Will queue.  Thanks.

```

## Junio C Hamano, 2013-12-04 22:02

Subject: Re: Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
Message-ID: <xmqqfvq8jmv5.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqfvq8jmv5.fsf%40gitster.dls.corp.google.com
In-Reply-To: <xmqqk3fkjq5c.fsf@gitster.dls.corp.google.com>

```
Junio C Hamano <gitster@pobox.com> writes:

> Christian Couder <christian.couder@gmail.com> writes:
>
>> Ok, the commit is in the use_starts_ends_with branch on this github repo:
>>
>> https://github.com/chriscool/git.git
>
> I looked at the patches, and they looked alright.  The endgame needs
> to be on a separate topic to be held until a distant future, though.
>
> Will queue.  Thanks.

It turns out that, naturally, there are many new uses of prefixcmp
in the topics in flight.  I can manage, but adjusting all of them
would not look too pretty X-<.

```

## Christian Couder, 2013-12-05 07:19

Subject: Re: Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
Message-ID: <CAP8UFD1+2-JuU0EPcfWUHpcfqrp9MODZBd4XEwVv-d6C8Nk=nA@mail.gmail.com>
URL: https://gitlist.dev/e/CAP8UFD1%2B2-JuU0EPcfWUHpcfqrp9MODZBd4XEwVv-d6C8Nk%3DnA%40mail.gmail.com
In-Reply-To: <xmqqfvq8jmv5.fsf@gitster.dls.corp.google.com>

```
On Wed, Dec 4, 2013 at 11:02 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Christian Couder <christian.couder@gmail.com> writes:
>>
>>> Ok, the commit is in the use_starts_ends_with branch on this github repo:
>>>
>>> https://github.com/chriscool/git.git
>>
>> I looked at the patches, and they looked alright.  The endgame needs
>> to be on a separate topic to be held until a distant future, though.
>>
>> Will queue.  Thanks.

Great!

> It turns out that, naturally, there are many new uses of prefixcmp
> in the topics in flight.  I can manage, but adjusting all of them
> would not look too pretty X-<.

Tell me if I can do something.
I can prepare patches for the topics in flight in 'next' for example.

Thanks,
Christian.

```

## Junio C Hamano, 2013-12-05 18:04

Subject: Re: Fwd: [PATCH 4/5] Replace {pre,suf}fixcmp() with {starts,ends}_with()
Message-ID: <xmqqa9gfi37g.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqa9gfi37g.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CAP8UFD1+2-JuU0EPcfWUHpcfqrp9MODZBd4XEwVv-d6C8Nk=nA@mail.gmail.com>

```
Christian Couder <christian.couder@gmail.com> writes:

> Tell me if I can do something.

I think the tip of 'pu' with cc/starts-n-ends-with-endgame is in
fairly a good shape.  The evil merge there may need to be updated
over time, but I think I can manage.

```
