git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Allow the ident attribute to include a length specifier

From
APAndy Parkins <andyparkins@gmail.com>
Date
May 14, 2007, 13:05 UTC
Message-ID
<200705141405.29550.andyparkins@gmail.com>

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
Next: Andy Parkins
Message 1 of 14 in “Allow the ident attribute to include a length specifier”
  1. Allow the ident attribute to include a length specifierAndy Parkins, May 14, 2007
  2. Andy ParkinsMay 14, 2007
  3. Use $Id$ as the ident attribute keyword rather than $ident$ to be consistent with other VCSsAndy Parkins, May 14, 2007
  4. Johannes SixtMay 14, 2007
  5. Andy ParkinsMay 14, 2007
  6. Junio C HamanoMay 14, 2007
  7. Andy ParkinsMay 14, 2007
  8. Junio C HamanoMay 15, 2007
  9. Junio C HamanoMay 15, 2007
  10. Andy ParkinsMay 15, 2007
  11. Junio C HamanoMay 15, 2007
  12. Andy ParkinsMay 15, 2007
  13. Andy ParkinsMay 17, 2007
  14. Junio C HamanoMay 17, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.