Skip to content

Commit

Permalink
Merge branch 'rs/pretty'
Browse files Browse the repository at this point in the history
* rs/pretty:
  Fix preprocessor logic that determines the availablity of strchrnul().
  Simplify strchrnul() compat code
  --format=pretty: avoid calculating expensive expansions twice
  add strbuf_adddup()
  --pretty=format: parse commit message only once
  --pretty=format: on-demand format expansion
  Add strchrnul()
  • Loading branch information
Junio C Hamano committed Nov 14, 2007
2 parents 4356736 + 726c8ef commit 37ec2b4
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 135 deletions.
8 changes: 2 additions & 6 deletions builtin-fetch--tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,7 @@ static int pick_rref(int sha1_only, const char *rref, const char *ls_remote_resu
cp++;
if (!*cp)
break;
np = strchr(cp, '\n');
if (!np)
np = cp + strlen(cp);
np = strchrnul(cp, '\n');
if (pass) {
lrr_list[i].line = cp;
lrr_list[i].name = cp + 41;
Expand All @@ -461,9 +459,7 @@ static int pick_rref(int sha1_only, const char *rref, const char *ls_remote_resu
rref++;
if (!*rref)
break;
next = strchr(rref, '\n');
if (!next)
next = rref + strlen(rref);
next = strchrnul(rref, '\n');
rreflen = next - rref;

for (i = 0; i < lrr_count; i++) {
Expand Down
16 changes: 16 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,22 @@ void *gitmemmem(const void *haystack, size_t haystacklen,
const void *needle, size_t needlelen);
#endif

#ifdef __GLIBC_PREREQ
#if __GLIBC_PREREQ(2, 1)
#define HAVE_STRCHRNUL
#endif
#endif

#ifndef HAVE_STRCHRNUL
#define strchrnul gitstrchrnul
static inline char *gitstrchrnul(const char *s, int c)
{
while (*s && *s != c)
s++;
return (char *)s;
}
#endif

extern void release_pack_memory(size_t, int);

static inline char* xstrdup(const char *str)
Expand Down
Loading

0 comments on commit 37ec2b4

Please sign in to comment.