|
|
|
@ -425,6 +425,8 @@ static int count_ident(const char *cp, unsigned long size)
@@ -425,6 +425,8 @@ static int count_ident(const char *cp, unsigned long size)
|
|
|
|
|
cnt++; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (ch == '\n') |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return cnt; |
|
|
|
@ -455,6 +457,11 @@ static int ident_to_git(const char *path, const char *src, size_t len,
@@ -455,6 +457,11 @@ static int ident_to_git(const char *path, const char *src, size_t len,
|
|
|
|
|
dollar = memchr(src + 3, '$', len - 3); |
|
|
|
|
if (!dollar) |
|
|
|
|
break; |
|
|
|
|
if (memchr(src + 3, '\n', dollar - src - 3)) { |
|
|
|
|
/* Line break before the next dollar. */ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
memcpy(dst, "Id$", 3); |
|
|
|
|
dst += 3; |
|
|
|
|
len -= dollar + 1 - src; |
|
|
|
@ -470,7 +477,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
@@ -470,7 +477,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
|
|
|
|
|
struct strbuf *buf, int ident) |
|
|
|
|
{ |
|
|
|
|
unsigned char sha1[20]; |
|
|
|
|
char *to_free = NULL, *dollar; |
|
|
|
|
char *to_free = NULL, *dollar, *spc; |
|
|
|
|
int cnt; |
|
|
|
|
|
|
|
|
|
if (!ident) |
|
|
|
@ -506,7 +513,10 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
@@ -506,7 +513,10 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
|
|
|
|
|
} else if (src[2] == ':') { |
|
|
|
|
/* |
|
|
|
|
* It's possible that an expanded Id has crept its way into the |
|
|
|
|
* repository, we cope with that by stripping the expansion out |
|
|
|
|
* repository, we cope with that by stripping the expansion out. |
|
|
|
|
* This is probably not a good idea, since it will cause changes |
|
|
|
|
* on checkout, which won't go away by stash, but let's keep it |
|
|
|
|
* for git-style ids. |
|
|
|
|
*/ |
|
|
|
|
dollar = memchr(src + 3, '$', len - 3); |
|
|
|
|
if (!dollar) { |
|
|
|
@ -514,6 +524,20 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
@@ -514,6 +524,20 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (memchr(src + 3, '\n', dollar - src - 3)) { |
|
|
|
|
/* Line break before the next dollar. */ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
spc = memchr(src + 4, ' ', dollar - src - 4); |
|
|
|
|
if (spc && spc < dollar-1) { |
|
|
|
|
/* There are spaces in unexpected places. |
|
|
|
|
* This is probably an id from some other |
|
|
|
|
* versioning system. Keep it for now. |
|
|
|
|
*/ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
len -= dollar + 1 - src; |
|
|
|
|
src = dollar + 1; |
|
|
|
|
} else { |
|
|
|
|