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

[PATCH 14/33] diff: convert fill_filespec to struct object_id

From
BWBrandon Williams <bmwill@google.com>
Date
May 30, 2017, 17:30 UTC
Message-ID
<20170530173109.54904-15-bmwill@google.com>
In-Reply-To
<20170530173109.54904-1-bmwill@google.com>
Signed-off-by: Brandon Williams <bmwill@google.com>
---
 builtin/blame.c   |  2 +-
 builtin/diff.c    |  4 ++--
 combine-diff.c    |  4 ++--
 diff-lib.c        |  2 +-
 diff-no-index.c   |  2 +-
 diff.c            | 16 ++++++++--------
 diffcore-rename.c |  2 +-
 diffcore.h        |  2 +-
 grep.c            |  2 +-
 line-log.c        |  6 +++---
 10 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 1043e5376..5ad435380 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -163,7 +163,7 @@ int textconv_object(const char *path,
 	struct userdiff_driver *textconv;
 
 	df = alloc_filespec(path);
-	fill_filespec(df, oid->hash, oid_valid, mode);
+	fill_filespec(df, oid, oid_valid, mode);
 	textconv = get_textconv(df);
 	if (!textconv) {
 		free_filespec(df);
diff --git a/builtin/diff.c b/builtin/diff.c
index 8c03ddaf5..b2d7c32cd 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -57,8 +57,8 @@ static void stuff_change(struct diff_options *opt,
 
 	one = alloc_filespec(old_name);
 	two = alloc_filespec(new_name);
-	fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
-	fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
+	fill_filespec(one, old_oid, old_oid_valid, old_mode);
+	fill_filespec(two, new_oid, new_oid_valid, new_mode);
 
 	diff_queue(&diff_queued_diff, one, two);
 }
diff --git a/combine-diff.c b/combine-diff.c
index 2848034fe..ad063ecb1 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -302,7 +302,7 @@ static char *grab_blob(const struct object_id *oid, unsigned int mode,
 		return xcalloc(1, 1);
 	} else if (textconv) {
 		struct diff_filespec *df = alloc_filespec(path);
-		fill_filespec(df, oid->hash, 1, mode);
+		fill_filespec(df, oid, 1, mode);
 		*size = fill_textconv(textconv, df, &blob);
 		free_filespec(df);
 	} else {
@@ -1022,7 +1022,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 						   &result_size, NULL, NULL);
 		} else if (textconv) {
 			struct diff_filespec *df = alloc_filespec(elem->path);
-			fill_filespec(df, null_sha1, 0, st.st_mode);
+			fill_filespec(df, &null_oid, 0, st.st_mode);
 			result_size = fill_textconv(textconv, df, &result);
 			free_filespec(df);
 		} else if (0 <= (fd = open(elem->path, O_RDONLY))) {
diff --git a/diff-lib.c b/diff-lib.c
index 1e8215df5..9e076a488 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -409,7 +409,7 @@ static void do_oneway_diff(struct unpack_trees_options *o,
 		struct diff_filepair *pair;
 		pair = diff_unmerge(&revs->diffopt, idx->name);
 		if (tree)
-			fill_filespec(pair->one, tree->oid.hash, 1,
+			fill_filespec(pair->one, &tree->oid, 1,
 				      tree->ce_mode);
 		return;
 	}
diff --git a/diff-no-index.c b/diff-no-index.c
index 79229382b..80ff17d46 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -82,7 +82,7 @@ static struct diff_filespec *noindex_filespec(const char *name, int mode)
 	if (!name)
 		name = "/dev/null";
 	s = alloc_filespec(name);
-	fill_filespec(s, null_sha1, 0, mode);
+	fill_filespec(s, &null_oid, 0, mode);
 	if (name == file_from_standard_input)
 		populate_from_stdin(s);
 	return s;
diff --git a/diff.c b/diff.c
index b9bb3f6ca..e0c179f5f 100644
--- a/diff.c
+++ b/diff.c
@@ -2702,13 +2702,13 @@ void free_filespec(struct diff_filespec *spec)
 	}
 }
 
-void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
-		   int sha1_valid, unsigned short mode)
+void fill_filespec(struct diff_filespec *spec, const struct object_id *oid,
+		   int oid_valid, unsigned short mode)
 {
 	if (mode) {
 		spec->mode = canon_mode(mode);
-		hashcpy(spec->oid.hash, sha1);
-		spec->oid_valid = sha1_valid;
+		oidcpy(&spec->oid, oid);
+		spec->oid_valid = oid_valid;
 	}
 }
 
@@ -5114,9 +5114,9 @@ void diff_addremove(struct diff_options *options,
 	two = alloc_filespec(concatpath);
 
 	if (addremove != '+')
-		fill_filespec(one, oid->hash, oid_valid, mode);
+		fill_filespec(one, oid, oid_valid, mode);
 	if (addremove != '-') {
-		fill_filespec(two, oid->hash, oid_valid, mode);
+		fill_filespec(two, oid, oid_valid, mode);
 		two->dirty_submodule = dirty_submodule;
 	}
 
@@ -5153,8 +5153,8 @@ void diff_change(struct diff_options *options,
 
 	one = alloc_filespec(concatpath);
 	two = alloc_filespec(concatpath);
-	fill_filespec(one, old_oid->hash, old_oid_valid, old_mode);
-	fill_filespec(two, new_oid->hash, new_oid_valid, new_mode);
+	fill_filespec(one, old_oid, old_oid_valid, old_mode);
+	fill_filespec(two, new_oid, new_oid_valid, new_mode);
 	one->dirty_submodule = old_dirty_submodule;
 	two->dirty_submodule = new_dirty_submodule;
 	p = diff_queue(&diff_queued_diff, one, two);
diff --git a/diffcore-rename.c b/diffcore-rename.c
index f7444c86b..3d9719dad 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -60,7 +60,7 @@ static int add_rename_dst(struct diff_filespec *two)
 		memmove(rename_dst + first + 1, rename_dst + first,
 			(rename_dst_nr - first - 1) * sizeof(*rename_dst));
 	rename_dst[first].two = alloc_filespec(two->path);
-	fill_filespec(rename_dst[first].two, two->oid.hash, two->oid_valid,
+	fill_filespec(rename_dst[first].two, &two->oid, two->oid_valid,
 		      two->mode);
 	rename_dst[first].pair = NULL;
 	return 0;
diff --git a/diffcore.h b/diffcore.h
index 623024135..a30da161d 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -52,7 +52,7 @@ struct diff_filespec {
 
 extern struct diff_filespec *alloc_filespec(const char *);
 extern void free_filespec(struct diff_filespec *);
-extern void fill_filespec(struct diff_filespec *, const unsigned char *,
+extern void fill_filespec(struct diff_filespec *, const struct object_id *,
 			  int, unsigned short);
 
 #define CHECK_SIZE_ONLY 1
diff --git a/grep.c b/grep.c
index a240b4cdb..3e21c92b9 100644
--- a/grep.c
+++ b/grep.c
@@ -1407,7 +1407,7 @@ static int fill_textconv_grep(struct userdiff_driver *driver,
 		fill_filespec(df, gs->identifier, 1, 0100644);
 		break;
 	case GREP_SOURCE_FILE:
-		fill_filespec(df, null_sha1, 0, 0100644);
+		fill_filespec(df, &null_oid, 0, 0100644);
 		break;
 	default:
 		die("BUG: attempt to textconv something without a path?");
diff --git a/line-log.c b/line-log.c
index b9087814b..a3bd2f2d5 100644
--- a/line-log.c
+++ b/line-log.c
@@ -500,12 +500,12 @@ static struct commit *check_single_commit(struct rev_info *revs)
 static void fill_blob_sha1(struct commit *commit, struct diff_filespec *spec)
 {
 	unsigned mode;
-	unsigned char sha1[20];
+	struct object_id oid;
 
 	if (get_tree_entry(commit->object.oid.hash, spec->path,
-			   sha1, &mode))
+			   oid.hash, &mode))
 		die("There is no path %s in the commit", spec->path);
-	fill_filespec(spec, sha1, 1, mode);
+	fill_filespec(spec, &oid, 1, mode);
 
 	return;
 }
-- 
2.13.0.219.gdb65acc882-goog
Previous: Brandon WilliamsNext: Brandon Williams
Message 17 of 66 in “object id conversion (grep and diff)”
  1. 00/33 object id conversion (grep and diff)Brandon Williams, May 30, 2017
  2. 01/33 notes: convert internal structures to struct object_idBrandon Williams, May 30, 2017
  3. 03/33 notes: convert for_each_note to struct object_idBrandon Williams, May 30, 2017
  4. 05/33 notes: convert format_display_notes to struct object_idBrandon Williams, May 30, 2017
  5. 06/33 builtin/notes: convert to struct object_idBrandon Williams, May 30, 2017
  6. 02/33 notes: convert internal parts to struct object_idBrandon Williams, May 30, 2017
  7. 04/33 notes: make get_note return pointer to struct object_idBrandon Williams, May 30, 2017
  8. René ScharfeJul 15, 2017
  9. Brandon WilliamsJul 17, 2017
  10. 09/33 diff: convert get_stat_data to struct object_idBrandon Williams, May 30, 2017
  11. 07/33 notes: convert some accessor functions to struct object_idBrandon Williams, May 30, 2017
  12. 08/33 grep: convert to struct object_idBrandon Williams, May 30, 2017
  13. Junio C HamanoJun 2, 2017
  14. 15/33 diff: convert reuse_worktree_file to struct object_idBrandon Williams, May 30, 2017
  15. 10/33 diff: convert diff_index_show_file to struct object_idBrandon Williams, May 30, 2017
  16. 19/33 combine-diff: convert diff_tree_combined to struct object_idBrandon Williams, May 30, 2017
  17. 14/33 diff: convert fill_filespec to struct object_idBrandon Williams, May 30, 2017
  18. 21/33 tree-diff: convert diff_root_tree_sha1 to struct object_idBrandon Williams, May 30, 2017
  19. 24/33 notes-merge: convert find_notes_merge_pair_ps to struct object_idBrandon Williams, May 30, 2017
  20. 18/33 diff: convert diff_flush_patch_id to struct object_idBrandon Williams, May 30, 2017
  21. 25/33 notes-merge: convert verify_notes_filepair to struct object_idBrandon Williams, May 30, 2017
  22. Stefan BellerMay 31, 2017
  23. Junio C HamanoJun 2, 2017
  24. Brandon WilliamsJun 2, 2017
  25. Junio C HamanoJun 2, 2017
  26. 30/33 tree-diff: convert diff_tree_paths to struct object_idBrandon Williams, May 30, 2017
  27. Stefan BellerMay 31, 2017
  28. Jeff KingMay 31, 2017
  29. Jeff KingMay 31, 2017
  30. Junio C HamanoJun 2, 2017
  31. René ScharfeJul 15, 2017
  32. brian m. carlsonJul 15, 2017
  33. 26/33 notes-merge: convert write_note_to_worktree to struct object_idBrandon Williams, May 30, 2017
  34. 29/33 tree-diff: convert try_to_follow_renames to struct object_idBrandon Williams, May 30, 2017
  35. 20/33 combine-diff: convert find_paths_* to struct object_idBrandon Williams, May 30, 2017
  36. Stefan BellerMay 31, 2017
  37. Junio C HamanoJun 2, 2017
  38. 23/33 notes-merge: convert merge_from_diffs to struct object_idBrandon Williams, May 30, 2017
  39. Stefan BellerMay 31, 2017
  40. Junio C HamanoJun 2, 2017
  41. 22/33 notes-merge: convert notes_merge* to struct object_idBrandon Williams, May 30, 2017
  42. Stefan BellerMay 31, 2017
  43. brian m. carlsonMay 31, 2017
  44. Junio C HamanoJun 2, 2017
  45. Brandon WilliamsJun 2, 2017
  46. 33/33 diff: rename diff_fill_sha1_info to diff_fill_oid_infoBrandon Williams, May 30, 2017
  47. 31/33 tree-diff: convert path_appendnew to object_idBrandon Williams, May 30, 2017
  48. Junio C HamanoJun 2, 2017
  49. 27/33 diff-tree: convert diff_tree_sha1 to struct object_idBrandon Williams, May 30, 2017
  50. 32/33 diffcore-rename: use is_empty_blob_oidBrandon Williams, May 30, 2017
  51. 28/33 builtin/diff-tree: cleanup references to sha1Brandon Williams, May 30, 2017
  52. Junio C HamanoJun 2, 2017
  53. 17/33 patch-ids: convert to struct object_idBrandon Williams, May 30, 2017
  54. 16/33 diff: finish conversion for prepare_temp_file to struct object_idBrandon Williams, May 30, 2017
  55. Stefan BellerMay 31, 2017
  56. 11/33 diff: convert diff_addremove to struct object_idBrandon Williams, May 30, 2017
  57. 12/33 diff: convert run_diff_files to struct object_idBrandon Williams, May 30, 2017
  58. 13/33 diff: convert diff_change to struct object_idBrandon Williams, May 30, 2017
  59. brian m. carlsonMay 31, 2017
  60. Brandon WilliamsJun 2, 2017
  61. Junio C HamanoJun 2, 2017
  62. Junio C HamanoJun 2, 2017
  63. Junio C HamanoJun 2, 2017
  64. Brandon WilliamsJun 2, 2017
  65. Junio C HamanoJun 2, 2017
  66. Brandon WilliamsJun 5, 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.