Skip to content

Commit

Permalink
convert: Keep foreign $Id$ on checkout.
Browse files Browse the repository at this point in the history
If there are foreign $Id$ keywords in the repository, they are most
likely there for a reason. Let's keep them on checkout (which is also
what the documentation indicates). Foreign $Id$ keywords are now
recognized by there being multiple space separated fields in $Id:xxxxx$.

Signed-off-by: Henrik Grubbström <grubba@grubba.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Henrik Grubbström authored and Junio C Hamano committed Apr 11, 2010
1 parent a9f3049 commit 07814d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,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)
Expand Down Expand Up @@ -513,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) {
Expand All @@ -526,6 +529,15 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
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 {
Expand Down
2 changes: 1 addition & 1 deletion t/t0021-conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ test_expect_success expanded_in_repo '
echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
echo "\$Id: NoTerminatingSymbol"
echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
echo "\$Id: Foreign Commit With Spaces \$"
echo "\$Id: NoTerminatingSymbolAtEOF"
} > expected-output &&
Expand Down

0 comments on commit 07814d9

Please sign in to comment.