Use $Id$ as the ident attribute keyword rather than $ident$ to be consistent with other VCSs
$Id$ is present already in SVN and CVS; it would mean that people converting their existing repositories won't have to make any changes to the source files should they want to make use of the ident attribute. Given that it's a feature that's meant to calm those very people, it seems obtuse to make them edit every file just to make use of it. I think that bzr uses $Id$; Mercurial has examples hooks for $Id$; monotone has $Id$ on its wishlist. I can't think of a good reason not to stick with the de-facto standard and call ours $Id$ instead of $ident$. Signed-off-by: Andy Parkins <andyparkins@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Andy Parkins committed
May 14, 2007 at 14:37 UTC
af9b54bb2cb0e15780bf3e820b5f1ce399deb2c4
4 files changed
+28
-28
Documentation/RelNotes-1.5.2.txt
+1
-1
@@ -26,7 +26,7 @@ Updates since v1.5.1
26
considered a binary or text (the former would be treated by
27
'git diff' not to produce textual output; the latter can go
28
through the line endings conversion process in repositories
29
- with core.autocrlf set), expand and unexpand '$ident$' keyword
29
+ with core.autocrlf set), expand and unexpand '$Id$' keyword
30
with blob object name, specify a custom 3-way merge driver,
31
and specify a custom diff driver. You can also apply
32
arbitrary filter to contents on check-in/check-out codepath
Documentation/gitattributes.txt
+3
-3
@@ -138,11 +138,11 @@ upon checkout.
138
^^^^^^^
139
140
When the attribute `ident` is set to a path, git replaces
141
-`$ident$` in the blob object with `$ident:`, followed by
141
+`$Id$` in the blob object with `$Id:`, followed by
142
40-character hexadecimal blob object name, followed by a dollar
143
sign `$` upon checkout. Any byte sequence that begins with
144
-`$ident:` and ends with `$` in the worktree file is replaced
145
-with `$ident$` upon check-in.
144
+`$Id:` and ends with `$` in the worktree file is replaced
145
+with `$Id$` upon check-in.
146
147
148
Interaction between checkin/checkout attributes
convert.c
+22
-22
@@ -412,7 +412,7 @@ static void setup_convert_check(struct git_attr_check *check)
412
static int count_ident(const char *cp, unsigned long size)
413
{
414
/*
415
- * "$ident: 0000000000000000000000000000000000000000 $" <=> "$ident$"
415
+ * "$Id: 0000000000000000000000000000000000000000 $" <=> "$Id$"
416
*/
417
int cnt = 0;
418
char ch;
@@ -422,20 +422,20 @@ static int count_ident(const char *cp, unsigned long size)
422
size--;
423
if (ch != '$')
424
continue;
425
- if (size < 6)
425
+ if (size < 3)
426
break;
427
- if (memcmp("ident", cp, 5))
427
+ if (memcmp("Id", cp, 2))
428
continue;
429
- ch = cp[5];
430
- cp += 6;
431
- size -= 6;
429
+ ch = cp[2];
430
+ cp += 3;
431
+ size -= 3;
432
if (ch == '$')
433
- cnt++; /* $ident$ */
433
+ cnt++; /* $Id$ */
434
if (ch != ':')
435
continue;
436
437
/*
438
- * "$ident: ... "; scan up to the closing dollar sign and discard.
438
+ * "$Id: ... "; scan up to the closing dollar sign and discard.
439
*/
440
while (size) {
441
ch = *cp++;
@@ -466,10 +466,10 @@ static char *ident_to_git(const char *path, const char *src, unsigned long *size
466
for (dst = buf; size; size--) {
467
char ch = *src++;
468
*dst++ = ch;
469
- if ((ch == '$') && (6 <= size) &&
470
- !memcmp("ident:", src, 6)) {
471
- unsigned long rem = size - 6;
472
- const char *cp = src + 6;
469
+ if ((ch == '$') && (3 <= size) &&
470
+ !memcmp("Id:", src, 3)) {
471
+ unsigned long rem = size - 3;
472
+ const char *cp = src + 3;
473
do {
474
ch = *cp++;
475
if (ch == '$')
@@ -478,8 +478,8 @@ static char *ident_to_git(const char *path, const char *src, unsigned long *size
478
} while (rem);
479
if (!rem)
480
continue;
481
- memcpy(dst, "ident$", 6);
482
- dst += 6;
481
+ memcpy(dst, "Id$", 3);
482
+ dst += 3;
483
size -= (cp - src);
484
src = cp;
485
}
@@ -511,13 +511,13 @@ static char *ident_to_worktree(const char *path, const char *src, unsigned long
511
const char *cp;
512
char ch = *src++;
513
*dst++ = ch;
514
- if ((ch != '$') || (size < 6) || memcmp("ident", src, 5))
514
+ if ((ch != '$') || (size < 3) || memcmp("Id", src, 2))
515
continue;
516
517
- if (src[5] == ':') {
517
+ if (src[2] == ':') {
518
/* discard up to but not including the closing $ */
519
- unsigned long rem = size - 6;
520
- cp = src + 6;
519
+ unsigned long rem = size - 3;
520
+ cp = src + 3;
521
do {
522
ch = *cp++;
523
if (ch == '$')
@@ -527,13 +527,13 @@ static char *ident_to_worktree(const char *path, const char *src, unsigned long
527
if (!rem)
528
continue;
529
size -= (cp - src);
530
- } else if (src[5] == '$')
531
- cp = src + 5;
530
+ } else if (src[2] == '$')
531
+ cp = src + 2;
532
else
533
continue;
534
535
- memcpy(dst, "ident: ", 7);
536
- dst += 7;
535
+ memcpy(dst, "Id: ", 4);
536
+ dst += 4;
537
memcpy(dst, sha1_to_hex(sha1), 40);
538
dst += 40;
539
*dst++ = ' ';
t/t0021-conversion.sh
+2
-2
@@ -21,7 +21,7 @@ test_expect_success setup '
21
{
22
echo a b c d e f g h i j k l m
23
echo n o p q r s t u v w x y z
24
- echo '\''$ident$'\''
24
+ echo '\''$Id$'\''
25
} >test &&
26
cat test >test.t &&
27
cat test >test.o &&
@@ -31,7 +31,7 @@ test_expect_success setup '
31
git checkout -- test test.t test.i
32
'
33
34
-script='s/^\$ident: \([0-9a-f]*\) \$/\1/p'
34
+script='s/^\$Id: \([0-9a-f]*\) \$/\1/p'
35
36
test_expect_success check '
37