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

[WIP/RFC 05/23] convert: convert renormalize_buffer to take an index

From
BWBrandon Williams <bmwill@google.com>
Date
May 18, 2017, 23:21 UTC
Message-ID
<20170518232134.163059-6-bmwill@google.com>
In-Reply-To
<20170518232134.163059-1-bmwill@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
---
 convert.c         | 6 ++++--
 convert.h         | 3 ++-
 ll-merge.c        | 2 +-
 merge-recursive.c | 4 ++--
 4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/convert.c b/convert.c
index 3d1c7e2b6..e4c8e6ad3 100644
--- a/convert.c
+++ b/convert.c
@@ -1,3 +1,4 @@
+#define NO_THE_INDEX_COMPATIBILITY_MACROS
 #include "cache.h"
 #include "attr.h"
 #include "run-command.h"
@@ -1260,14 +1261,15 @@ int convert_to_working_tree(const char *path, const char *src, size_t len, struc
 	return convert_to_working_tree_internal(path, src, len, dst, 0);
 }
 
-int renormalize_buffer(const char *path, const char *src, size_t len, struct strbuf *dst)
+int renormalize_buffer(const struct index_state *istate, const char *path,
+		       const char *src, size_t len, struct strbuf *dst)
 {
 	int ret = convert_to_working_tree_internal(path, src, len, dst, 1);
 	if (ret) {
 		src = dst->buf;
 		len = dst->len;
 	}
-	return ret | convert_to_git(&the_index, path, src, len, dst, SAFE_CRLF_RENORMALIZE);
+	return ret | convert_to_git(istate, path, src, len, dst, SAFE_CRLF_RENORMALIZE);
 }
 
 /*****************************************************************
diff --git a/convert.h b/convert.h
index 60cb41d6a..cecf59d1a 100644
--- a/convert.h
+++ b/convert.h
@@ -46,7 +46,8 @@ extern int convert_to_git(const struct index_state *istate,
 			  struct strbuf *dst, enum safe_crlf checksafe);
 extern int convert_to_working_tree(const char *path, const char *src,
 				   size_t len, struct strbuf *dst);
-extern int renormalize_buffer(const char *path, const char *src, size_t len,
+extern int renormalize_buffer(const struct index_state *istate,
+			      const char *path, const char *src, size_t len,
 			      struct strbuf *dst);
 static inline int would_convert_to_git(const struct index_state *istate,
 				       const char *path)
diff --git a/ll-merge.c b/ll-merge.c
index ac0d4a5d7..d7eafb61a 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -339,7 +339,7 @@ static const struct ll_merge_driver *find_ll_merge_driver(const char *merge_attr
 static void normalize_file(mmfile_t *mm, const char *path)
 {
 	struct strbuf strbuf = STRBUF_INIT;
-	if (renormalize_buffer(path, mm->ptr, mm->size, &strbuf)) {
+	if (renormalize_buffer(&the_index, path, mm->ptr, mm->size, &strbuf)) {
 		free(mm->ptr);
 		mm->size = strbuf.len;
 		mm->ptr = strbuf_detach(&strbuf, NULL);
diff --git a/merge-recursive.c b/merge-recursive.c
index 62decd51c..cdf34c524 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1639,8 +1639,8 @@ static int blob_unchanged(struct merge_options *opt,
 	 * performed.  Comparison can be skipped if both files are
 	 * unchanged since their sha1s have already been compared.
 	 */
-	if (renormalize_buffer(path, o.buf, o.len, &o) |
-	    renormalize_buffer(path, a.buf, a.len, &a))
+	if (renormalize_buffer(&the_index, path, o.buf, o.len, &o) |
+	    renormalize_buffer(&the_index, path, a.buf, a.len, &a))
 		ret = (o.len == a.len && !memcmp(o.buf, a.buf, o.len));
 
 error_return:
-- 
2.13.0.303.g4ebf302169-goog
Previous: Brandon WilliamsNext: Brandon Williams
Message 10 of 41 in “[WIP/RFC 00/23] repository object”
  1. Brandon WilliamsMay 18, 2017
  2. 02/23 convert: convert crlf_to_git to take an indexBrandon Williams, May 18, 2017
  3. 03/23 convert: convert convert_to_git_filter_fd to take an indexBrandon Williams, May 18, 2017
  4. 01/23 convert: convert get_cached_convert_stats_ascii to take an indexBrandon Williams, May 18, 2017
  5. 04/23 convert: convert convert_to_git to take an indexBrandon Williams, May 18, 2017
  6. 10/23 ls-files: convert show_other_files to take an indexBrandon Williams, May 18, 2017
  7. 11/23 ls-files: convert show_ru_info to take an indexBrandon Williams, May 18, 2017
  8. 06/23 tree: convert read_tree to take an index parameterBrandon Williams, May 18, 2017
  9. 14/23 ls-files: convert show_files to take an indexBrandon Williams, May 18, 2017
  10. 05/23 convert: convert renormalize_buffer to take an indexBrandon Williams, May 18, 2017
  11. 12/23 ls-files: convert ce_excluded to take an indexBrandon Williams, May 18, 2017
  12. 15/23 ls-files: factor out debug info into a functionBrandon Williams, May 18, 2017
  13. 08/23 ls-files: convert write_eolinfo to take an indexBrandon Williams, May 18, 2017
  14. 07/23 ls-files: convert overlay_tree_on_cache to take an indexBrandon Williams, May 18, 2017
  15. 09/23 ls-files: convert show_killed_files to take an indexBrandon Williams, May 18, 2017
  16. 16/23 ls-files: factor out tag calculationBrandon Williams, May 18, 2017
  17. 20/23 submodule-config: refactor to allow for multiple submodule_cache'sBrandon Williams, May 18, 2017
  18. 19/23 repo: add per repo configBrandon Williams, May 18, 2017
  19. 22/23 submodule: add is_submodule_activeBrandon Williams, May 18, 2017
  20. 21/23 repo: add repo_read_gitmodulesBrandon Williams, May 18, 2017
  21. 18/23 repo: add index_state to struct repoBrandon Williams, May 18, 2017
  22. Stefan BellerMay 20, 2017
  23. 17/23 repo: introduce new repository objectBrandon Williams, May 18, 2017
  24. Stefan BellerMay 20, 2017
  25. Brandon WilliamsMay 23, 2017
  26. 13/23 ls-files: convert prune_cache to take an indexBrandon Williams, May 18, 2017
  27. 23/23 ls-files: use repository objectBrandon Williams, May 18, 2017
  28. Jeff HostetlerMay 19, 2017
  29. Ben PeartMay 19, 2017
  30. Brandon WilliamsMay 23, 2017
  31. Stefan BellerMay 20, 2017
  32. Johannes SchindelinMay 22, 2017
  33. Jacob KellerMay 21, 2017
  34. brian m. carlsonMay 21, 2017
  35. Jeff KingMay 22, 2017
  36. Brandon WilliamsMay 23, 2017
  37. Junio C HamanoMay 24, 2017
  38. Duy NguyenMay 29, 2017
  39. Ævar Arnfjörð BjarmasonMay 29, 2017
  40. Duy NguyenMay 29, 2017
  41. Brandon WilliamsMay 30, 2017

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.