diff options
author | Andy Parkins <andyparkins@gmail.com> | 2007-05-25 11:50:08 +0100 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-05-26 01:12:43 -0700 |
commit | c23290d528c208a25641f0fc278bac9bb9838265 (patch) | |
tree | a20f131527ee883c8e6ce5f8702a4c1e403b74bb /builtin-tar-tree.c | |
parent | 6d9d26d82623b8189fa88ebb7b47e45f8ccbb3b1 (diff) | |
download | git-c23290d528c208a25641f0fc278bac9bb9838265.tar.gz |
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>
Diffstat (limited to 'builtin-tar-tree.c')
0 files changed, 0 insertions, 0 deletions