Commit c23290d
Fix mishandling of $Id$ expanded in the repository copy in convert.c
If the repository contained an expanded ident keyword (i.e. $Id:XXXX$),
then the wrong bytes were discarded, and the Id keyword was not
expanded. The fault was in convert.c:ident_to_worktree().
Previously, when a "$Id:" was found in the repository version,
ident_to_worktree() would search for the next "$" after this, and
discarded everything it found until then. That was done with the loop:
do {
ch = *cp++;
if (ch == '$')
break;
rem--;
} while (rem);
The above loop left cp pointing one character _after_ the final "$"
(because of ch = *cp++). This was different from the non-expanded case,
were cp is left pointing at the "$", and was different from the comment
which stated "discard up to but not including the closing $". This
patch fixes that by making the loop:
do {
ch = *cp;
if (ch == '$')
break;
cp++;
rem--;
} while (rem);
That is, cp is tested _then_ incremented.
This loop exits if it finds a "$" or if it runs out of bytes in the
source. After this loop, if there was no closing "$" the expansion is
skipped, and the outer loop is allowed to continue leaving this
non-keyword as it was. However, when the "$" is found, size is
corrected, before running the expansion:
size -= (cp - src);
This is wrong; size is going to be corrected anyway after the expansion,
so there is no need to do it here. This patch removes that redundant
correction.
To help find this bug, I heavily commented the routine; those comments
are included here as a bonus.
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>1 parent 6d9d26d commit c23290d
1 file changed
+37
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| 512 | + | |
512 | 513 | | |
| 514 | + | |
513 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
514 | 519 | | |
515 | 520 | | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
516 | 529 | | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
517 | 534 | | |
| 535 | + | |
| 536 | + | |
518 | 537 | | |
519 | 538 | | |
| 539 | + | |
520 | 540 | | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
521 | 546 | | |
522 | | - | |
| 547 | + | |
523 | 548 | | |
524 | 549 | | |
| 550 | + | |
525 | 551 | | |
526 | 552 | | |
| 553 | + | |
| 554 | + | |
527 | 555 | | |
528 | 556 | | |
529 | | - | |
530 | 557 | | |
531 | 558 | | |
532 | 559 | | |
| 560 | + | |
| 561 | + | |
533 | 562 | | |
534 | 563 | | |
| 564 | + | |
| 565 | + | |
535 | 566 | | |
536 | 567 | | |
537 | 568 | | |
538 | 569 | | |
539 | 570 | | |
| 571 | + | |
| 572 | + | |
540 | 573 | | |
541 | 574 | | |
| 575 | + | |
| 576 | + | |
542 | 577 | | |
543 | 578 | | |
544 | 579 | | |
| |||
0 commit comments