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

[PATCH] Don't allow newlines to occur in $Id:$ collapse

From
APAndy Parkins <andyparkins@gmail.com>
Date
May 25, 2007, 13:13 UTC
Message-ID
<200705251413.42389.andyparkins@gmail.com>
In-Reply-To
<200705251412.06196.andyparkins@gmail.com>

If a newline ever made it into an repository-side expanded $Id$ field, the keyword would still be detected as a keyword and collapsed, before rexpansion, e.g.

 $Id: all of this text would be removed, even if there
 were a newline in the middle of it$

This patch catches newlines in this case and abandons treating this as a keyword expansion, this text would be left untouched in the working checkout.

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 convert.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/convert.c b/convert.c
index 3c44e3d..051366c 100644
--- a/convert.c
+++ b/convert.c
@@ -547,12 +547,14 @@ static char *ident_to_worktree(const char *path, const char *src, unsigned long
 				ch = *cp;
 				if (ch == '$')
 					break;
+				if (ch == '\n')
+					break;
 				cp++;
 				rem--;
 			} while (rem);
 			/* If the above finished because it ran out of characters, then
 			 * this is an incomplete keyword, so don't run the expansion */
-			if (!rem)
+			if (!rem || ch == '\n')
 				continue;
 		} else if (src[2] == '$')
 			cp = src + 2;
-- 
1.5.2.763.g8c5e-dirty
Previous: Andy ParkinsNext: Joshua N Pritikin
Message 4 of 13 in “Fix mishandling of $Id$ expanded in the repository copy in convert.c”
  1. Fix mishandling of $Id$ expanded in the repository copy in convert.cAndy Parkins, May 25, 2007
  2. Joshua N PritikinMay 25, 2007
  3. Andy ParkinsMay 25, 2007
  4. Don't allow newlines to occur in $Id:$ collapseAndy Parkins, May 25, 2007
  5. Joshua N PritikinMay 25, 2007
  6. Nicolas PitreMay 25, 2007
  7. Andy ParkinsMay 25, 2007
  8. Joshua N PritikinMay 25, 2007
  9. Junio C HamanoMay 26, 2007
  10. Andy ParkinsMay 26, 2007
  11. Junio C HamanoMay 26, 2007
  12. Andy ParkinsMay 27, 2007
  13. Add test case for $Id$ expanded in the repositoryAndy Parkins, May 27, 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.