@matheusbsbs / matheus-bagliano / commits / 07814d9009
Fork 0

convert: Keep foreign $Id$ on checkout.

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>

Henrik Grubbström committed Apr 6, 2010 at 14:46 UTC 07814d90095b65b4594efd47c69f9f171ef162d4
2 files changed +15 -3
convert.c
+14 -2
@@ -477,7 +477,7 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
477 struct strbuf *buf, int ident)
478 {
479 unsigned char sha1[20];
480 - char *to_free = NULL, *dollar;
480 + char *to_free = NULL, *dollar, *spc;
481 int cnt;
482
483 if (!ident)
@@ -513,7 +513,10 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
513 } else if (src[2] == ':') {
514 /*
515 * It's possible that an expanded Id has crept its way into the
516 - * repository, we cope with that by stripping the expansion out
516 + * repository, we cope with that by stripping the expansion out.
517 + * This is probably not a good idea, since it will cause changes
518 + * on checkout, which won't go away by stash, but let's keep it
519 + * for git-style ids.
520 */
521 dollar = memchr(src + 3, '$', len - 3);
522 if (!dollar) {
@@ -526,6 +529,15 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
529 continue;
530 }
531
532 + spc = memchr(src + 4, ' ', dollar - src - 4);
533 + if (spc && spc < dollar-1) {
534 + /* There are spaces in unexpected places.
535 + * This is probably an id from some other
536 + * versioning system. Keep it for now.
537 + */
538 + continue;
539 + }
540 +
541 len -= dollar + 1 - src;
542 src = dollar + 1;
543 } else {
t/t0021-conversion.sh
+1 -1
@@ -78,7 +78,7 @@ test_expect_success expanded_in_repo '
78 echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
79 echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
80 echo "\$Id: NoTerminatingSymbol"
81 - echo "\$Id: fd0478f5f1486f3d5177d4c3f6eb2765e8fc56b9 \$"
81 + echo "\$Id: Foreign Commit With Spaces \$"
82 echo "\$Id: NoTerminatingSymbolAtEOF"
83 } > expected-output &&
84