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

[RFC 7/8] Convert symlink dest in diff

From
Robin Rosenberg <robin.rosenberg@dewire.com>
Date
May 12, 2009, 22:50 UTC
Message-ID
<1242168631-30753-8-git-send-email-robin.rosenberg@dewire.com>
In-Reply-To
<1242168631-30753-7-git-send-email-robin.rosenberg@dewire.com>
---
 diff.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/diff.c b/diff.c
index 170ec5a..c8132a4 100644
--- a/diff.c
+++ b/diff.c
@@ -1319,8 +1319,18 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
 				locate_size_cache(s->sha1, 0, s->size);
 		}
 		else {
-			s->data = read_sha1_file(s->sha1, type, &s->size);
-			s->should_free = 1;
+			if (S_ISLNK(s->mode)) {
+				int linksize;
+			        char *linkdata = read_sha1_file(s->sha1, type, &linksize);
+				s->size = locallen(linkdata, linksize);
+				s->data = xmalloc(s->size + 1);
+				localcpy(s->data, linkdata, linksize + 1);
+				s->should_free = 1;
+				free(linkdata);
+			} else {
+				s->data = read_sha1_file(s->sha1, type, &s->size);
+				s->should_free = 1;
+			}
 		}
 	}
 	return 0;
-- 
1.6.3.dirty
Previous: Robin RosenbergNext: Robin Rosenberg
Message 19 of 20 in “[RFC 0/8] Antique UTF-8 filename support”
  1. Robin RosenbergMay 12, 2009
  2. 1/8 UTF helpersRobin Rosenberg, May 12, 2009
  3. 2/8 Messages in locale.Robin Rosenberg, May 12, 2009
  4. 3/8 Extend tests to cover locale wrt to commit messages.Robin Rosenberg, May 12, 2009
  5. 4/8 UTF file names.Robin Rosenberg, May 12, 2009
  6. Johannes SchindelinMay 13, 2009
  7. Robin RosenbergMay 13, 2009
  8. Esko LuontolaMay 13, 2009
  9. Andreas EricssonMay 13, 2009
  10. Esko LuontolaMay 13, 2009
  11. Alex RiesenMay 13, 2009
  12. Junio C HamanoMay 13, 2009
  13. Esko LuontolaMay 13, 2009
  14. Junio C HamanoMay 13, 2009
  15. Johannes SchindelinMay 13, 2009
  16. Junio C HamanoMay 14, 2009
  17. Jay SoffianMay 14, 2009
  18. 6/8 test of utf_locallinksRobin Rosenberg, May 12, 2009
  19. 7/8 Convert symlink dest in diffRobin Rosenberg, May 12, 2009
  20. 8/8 UTF-8 in non-SHA1-objectsRobin Rosenberg, May 12, 2009

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.