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

[PATCH v2 10/10] apply: convert threeway_stage to object_id

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Mar 13, 2015, 23:39 UTC
Message-ID
<1426289976-568060-11-git-send-email-sandals@crustytoothpaste.net>
In-Reply-To
<1426289976-568060-1-git-send-email-sandals@crustytoothpaste.net>
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 builtin/apply.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index 65b97ee..c2c8f39 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -208,7 +208,7 @@ struct patch {
 	struct patch *next;
 
 	/* three-way fallback result */
-	unsigned char threeway_stage[3][20];
+	struct object_id threeway_stage[3];
 };
 
 static void free_fragment_list(struct fragment *list)
@@ -3424,11 +3424,11 @@ static int try_threeway(struct image *image, struct patch *patch,
 	if (status) {
 		patch->conflicted_threeway = 1;
 		if (patch->is_new)
-			hashclr(patch->threeway_stage[0]);
+			oidclr(&patch->threeway_stage[0]);
 		else
-			hashcpy(patch->threeway_stage[0], pre_sha1);
-		hashcpy(patch->threeway_stage[1], our_sha1);
-		hashcpy(patch->threeway_stage[2], post_sha1);
+			hashcpy(patch->threeway_stage[0].hash, pre_sha1);
+		hashcpy(patch->threeway_stage[1].hash, our_sha1);
+		hashcpy(patch->threeway_stage[2].hash, post_sha1);
 		fprintf(stderr, "Applied patch to '%s' with conflicts.\n", patch->new_name);
 	} else {
 		fprintf(stderr, "Applied patch to '%s' cleanly.\n", patch->new_name);
@@ -4184,14 +4184,14 @@ static void add_conflicted_stages_file(struct patch *patch)
 
 	remove_file_from_cache(patch->new_name);
 	for (stage = 1; stage < 4; stage++) {
-		if (is_null_sha1(patch->threeway_stage[stage - 1]))
+		if (is_null_oid(&patch->threeway_stage[stage - 1]))
 			continue;
 		ce = xcalloc(1, ce_size);
 		memcpy(ce->name, patch->new_name, namelen);
 		ce->ce_mode = create_ce_mode(mode);
 		ce->ce_flags = create_ce_flags(stage);
 		ce->ce_namelen = namelen;
-		hashcpy(ce->sha1, patch->threeway_stage[stage - 1]);
+		hashcpy(ce->sha1, patch->threeway_stage[stage - 1].hash);
 		if (add_cache_entry(ce, ADD_CACHE_OK_TO_ADD) < 0)
 			die(_("unable to add cache entry for %s"), patch->new_name);
 	}
-- 
2.2.1.209.g41e5f3a
Previous: brian m. carlsonNext: brian m. carlson
Message 11 of 12 in “Use a structure for object IDs.”
  1. 00/10 Use a structure for object IDs.brian m. carlson, Mar 13, 2015
  2. 01/10 Define a structure for object IDs.brian m. carlson, Mar 13, 2015
  3. 02/10 Define utility functions for object IDs.brian m. carlson, Mar 13, 2015
  4. 03/10 bisect.c: convert leaf functions to use struct object_idbrian m. carlson, Mar 13, 2015
  5. 04/10 archive.c: convert to use struct object_idbrian m. carlson, Mar 13, 2015
  6. 05/10 zip: use GIT_SHA1_HEXSZ for trailersbrian m. carlson, Mar 13, 2015
  7. 06/10 bulk-checkin.c: convert to use struct object_idbrian m. carlson, Mar 13, 2015
  8. 07/10 diff: convert struct combine_diff_path to object_idbrian m. carlson, Mar 13, 2015
  9. 08/10 commit: convert parts to struct object_idbrian m. carlson, Mar 13, 2015
  10. 09/10 patch-id: convert to use struct object_idbrian m. carlson, Mar 13, 2015
  11. 10/10 apply: convert threeway_stage to object_idbrian m. carlson, Mar 13, 2015
  12. brian m. carlsonMar 14, 2015

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.