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

[PATCH v2 3/4] diff.c: allow to pass more flags to diff_populate_filespec

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jun 24, 2014, 11:45 UTC
Message-ID
<1403610336-27761-3-git-send-email-pclouds@gmail.com>
In-Reply-To
<1403610336-27761-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 diff.c            | 13 +++++++------
 diffcore-rename.c |  6 ++++--
 diffcore.h        |  3 ++-
 3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/diff.c b/diff.c
index bba9a55..a489540 100644
--- a/diff.c
+++ b/diff.c
@@ -373,7 +373,7 @@ static unsigned long diff_filespec_size(struct diff_filespec *one)
 {
 	if (!DIFF_FILE_VALID(one))
 		return 0;
-	diff_populate_filespec(one, 1);
+	diff_populate_filespec(one, DIFF_POPULATE_SIZE_ONLY);
 	return one->size;
 }
 
@@ -1907,11 +1907,11 @@ static void show_dirstat(struct diff_options *options)
 			diff_free_filespec_data(p->one);
 			diff_free_filespec_data(p->two);
 		} else if (DIFF_FILE_VALID(p->one)) {
-			diff_populate_filespec(p->one, 1);
+			diff_populate_filespec(p->one, DIFF_POPULATE_SIZE_ONLY);
 			copied = added = 0;
 			diff_free_filespec_data(p->one);
 		} else if (DIFF_FILE_VALID(p->two)) {
-			diff_populate_filespec(p->two, 1);
+			diff_populate_filespec(p->two, DIFF_POPULATE_SIZE_ONLY);
 			copied = 0;
 			added = p->two->size;
 			diff_free_filespec_data(p->two);
@@ -2664,8 +2664,9 @@ static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
  * grab the data for the blob (or file) for our own in-core comparison.
  * diff_filespec has data and size fields for this purpose.
  */
-int diff_populate_filespec(struct diff_filespec *s, int size_only)
+int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
 {
+	int size_only = flags & DIFF_POPULATE_SIZE_ONLY;
 	int err = 0;
 	/*
 	 * demote FAIL to WARN to allow inspecting the situation
@@ -4693,8 +4694,8 @@ static int diff_filespec_check_stat_unmatch(struct diff_filepair *p)
 	    !DIFF_FILE_VALID(p->two) ||
 	    (p->one->sha1_valid && p->two->sha1_valid) ||
 	    (p->one->mode != p->two->mode) ||
-	    diff_populate_filespec(p->one, 1) ||
-	    diff_populate_filespec(p->two, 1) ||
+	    diff_populate_filespec(p->one, DIFF_POPULATE_SIZE_ONLY) ||
+	    diff_populate_filespec(p->two, DIFF_POPULATE_SIZE_ONLY) ||
 	    (p->one->size != p->two->size) ||
 	    !diff_filespec_is_identical(p->one, p->two)) /* (2) */
 		p->skip_stat_unmatch_result = 1;
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 749a35d..8437917 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -147,9 +147,11 @@ static int estimate_similarity(struct diff_filespec *src,
 	 * is a possible size - we really should have a flag to
 	 * say whether the size is valid or not!)
 	 */
-	if (!src->cnt_data && diff_populate_filespec(src, 1))
+	if (!src->cnt_data &&
+	    diff_populate_filespec(src, DIFF_POPULATE_SIZE_ONLY))
 		return 0;
-	if (!dst->cnt_data && diff_populate_filespec(dst, 1))
+	if (!dst->cnt_data &&
+	    diff_populate_filespec(dst, DIFF_POPULATE_SIZE_ONLY))
 		return 0;
 
 	max_size = ((src->size > dst->size) ? src->size : dst->size);
diff --git a/diffcore.h b/diffcore.h
index c876dac..a186d7c 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -55,7 +55,8 @@ extern void free_filespec(struct diff_filespec *);
 extern void fill_filespec(struct diff_filespec *, const unsigned char *,
 			  int, unsigned short);
 
-extern int diff_populate_filespec(struct diff_filespec *, int);
+#define DIFF_POPULATE_SIZE_ONLY 1
+extern int diff_populate_filespec(struct diff_filespec *, unsigned int);
 extern void diff_free_filespec_data(struct diff_filespec *);
 extern void diff_free_filespec_blob(struct diff_filespec *);
 extern int diff_filespec_is_binary(struct diff_filespec *);
-- 
1.9.1.346.ga2b5940
Previous: Duy NguyenNext: Nguyễn Thái Ngọc Duy
Message 23 of 49 in “Git chokes on large file”
  1. Dale R. WorleyMay 27, 2014
  2. Duy NguyenMay 28, 2014
  3. Junio C HamanoMay 28, 2014
  4. Dale R. WorleyMay 28, 2014
  5. Dale R. WorleyMay 28, 2014
  6. David LangMay 28, 2014
  7. Dale R. WorleyMay 28, 2014
  8. David LangMay 28, 2014
  9. Dale R. WorleyMay 29, 2014
  10. Junio C HamanoMay 28, 2014
  11. David LangMay 28, 2014
  12. 1/4 wrapper.c: introduce gentle xmallocz that does not die()Nguyễn Thái Ngọc Duy, May 29, 2014
  13. 2/4 fsck: do not die when not enough memory to examine a pack entryNguyễn Thái Ngọc Duy, May 29, 2014
  14. 3/4 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, May 29, 2014
  15. 4/4 diff: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, May 29, 2014
  16. Thomas BraunJun 19, 2014
  17. Duy NguyenJun 23, 2014
  18. Thomas BraunJun 23, 2014
  19. 1/4 wrapper.c: introduce gentle xmallocz that does not die()Nguyễn Thái Ngọc Duy, Jun 24, 2014
  20. 2/4 fsck: do not die when not enough memory to examine a pack entryNguyễn Thái Ngọc Duy, Jun 24, 2014
  21. Junio C HamanoJun 26, 2014
  22. Duy NguyenJun 29, 2014
  23. 3/4 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, Jun 24, 2014
  24. 4/4 diff: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, Jun 24, 2014
  25. Junio C HamanoJun 26, 2014
  26. Thomas BraunJun 27, 2014
  27. Duy NguyenJun 29, 2014
  28. 0/6 Large file improvementsNguyễn Thái Ngọc Duy, Aug 13, 2014
  29. 1/6 wrapper.c: introduce gentle xmalloc(z) that does not die()Nguyễn Thái Ngọc Duy, Aug 13, 2014
  30. Junio C HamanoAug 14, 2014
  31. 2/6 sha1_file.c: do not die failing to malloc in unpack_compressed_entryNguyễn Thái Ngọc Duy, Aug 13, 2014
  32. Junio C HamanoAug 13, 2014
  33. 3/6 unpack-objects: continue when fail to malloc due to large objectsNguyễn Thái Ngọc Duy, Aug 13, 2014
  34. Junio C HamanoAug 14, 2014
  35. Duy NguyenAug 15, 2014
  36. 4/6 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, Aug 13, 2014
  37. 5/6 diff --stat: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, Aug 13, 2014
  38. Eric SunshineAug 13, 2014
  39. 6/6 diff: shortcut for diff'ing two binary SHA-1 objectsNguyễn Thái Ngọc Duy, Aug 13, 2014
  40. Junio C HamanoAug 14, 2014
  41. Duy NguyenAug 15, 2014
  42. Junio C HamanoAug 14, 2014
  43. 0/5 Large file improvementsNguyễn Thái Ngọc Duy, Aug 16, 2014
  44. 1/5 wrapper.c: introduce gentle xmallocz that does not die()Nguyễn Thái Ngọc Duy, Aug 16, 2014
  45. 2/5 sha1_file.c: do not die failing to malloc in unpack_compressed_entryNguyễn Thái Ngọc Duy, Aug 16, 2014
  46. 3/5 diff.c: allow to pass more flags to diff_populate_filespecNguyễn Thái Ngọc Duy, Aug 16, 2014
  47. 4/5 diff --stat: mark any file larger than core.bigfilethreshold binaryNguyễn Thái Ngọc Duy, Aug 16, 2014
  48. 5/5 diff: shortcut for diff'ing two binary SHA-1 objectsNguyễn Thái Ngọc Duy, Aug 16, 2014
  49. Thomas BraunMay 28, 2014

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.