git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Allow the ident attribute to include a length specifier
@ 2007-05-14 13:05 Andy Parkins
  2007-05-14 13:29 ` Andy Parkins
  2007-05-17 13:53 ` [PATCH] Allow the ident attribute to include a length specifier Andy Parkins
  0 siblings, 2 replies; 14+ messages in thread
From: Andy Parkins @ 2007-05-14 13:05 UTC (permalink / raw)
  To: git

When the ident attribute is found for a path, then git replaces $ident$
with:

  $ident: df2a1fd3ebce86876721bd7e12ce02ac89c885db $

With this patch, you can put the following in your attribute file:

  somepath ident=10

And get expansions like this:

  $ident: df2a1fd3eb $

There is no change to existing behaviour.  With no parameter, the
expansion is all 40 hex digits.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 convert.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/convert.c b/convert.c
index 9ee31b0..79dfbcf 100644
--- a/convert.c
+++ b/convert.c
@@ -534,8 +534,8 @@ static char *ident_to_worktree(const char *path, const char *src, unsigned long
 
 		memcpy(dst, "ident: ", 7);
 		dst += 7;
-		memcpy(dst, sha1_to_hex(sha1), 40);
-		dst += 40;
+		memcpy(dst, sha1_to_hex(sha1), ident);
+		dst += ident;
 		*dst++ = ' ';
 		size -= (cp - src);
 		src = cp;
@@ -580,7 +580,13 @@ static int git_path_check_ident(const char *path, struct git_attr_check *check)
 {
 	const char *value = check->value;
 
-	return !!ATTR_TRUE(value);
+	if( ATTR_UNSET(value) || ATTR_FALSE(value) )
+		return 0;
+
+	if( ATTR_TRUE(value) )
+		return 40;
+
+	return atoi(value);
 }
 
 char *convert_to_git(const char *path, const char *src, unsigned long *sizep)
-- 
1.5.2.rc3.27.g43d151-dirty

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-05-17 19:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-14 13:05 [PATCH] Allow the ident attribute to include a length specifier Andy Parkins
2007-05-14 13:29 ` Andy Parkins
2007-05-14 13:37   ` [PATCH] Use $Id$ as the ident attribute keyword rather than $ident$ to be consistent with other VCSs Andy Parkins
2007-05-14 14:19     ` Johannes Sixt
2007-05-14 14:39       ` Andy Parkins
2007-05-14 14:54       ` Junio C Hamano
2007-05-14 22:24         ` Andy Parkins
2007-05-15  0:17           ` Junio C Hamano
2007-05-15  2:03           ` Junio C Hamano
2007-05-15  8:14             ` Andy Parkins
2007-05-15  8:54               ` Junio C Hamano
2007-05-15 10:34                 ` Andy Parkins
2007-05-17 13:53 ` [PATCH] Allow the ident attribute to include a length specifier Andy Parkins
2007-05-17 19:55   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).