Thread (42 messages) flat view 42 messages, 2 authors, 2016-09-06
STALE3671d

Revision v14 of 6 in this series.

Revisions (6)
  1. v6 [diff vs current]
  2. v7 [diff vs current]
  3. v8 [diff vs current]
  4. v9 [diff vs current]
  5. v10 [diff vs current]
  6. v14 current

[PATCH v14 39/41] apply: pass apply state to build_fake_ancestor()

From: Christian Couder <hidden>
Date: 2016-09-04 20:20:24
Subsystem: the rest · Maintainer: Linus Torvalds

To libify git apply functionality, we will need to read from a
different index file in get_current_sha1(). This index file will be
stored in "struct apply_state", so let's pass the state to
build_fake_ancestor() which will later pass it to get_current_sha1().

Signed-off-by: Christian Couder <redacted>
---
 apply.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/apply.c b/apply.c
index 2dad0db..f29387d 100644
--- a/apply.c
+++ b/apply.c
@@ -4042,7 +4042,7 @@ static int preimage_sha1_in_gitlink_patch(struct patch *p, unsigned char sha1[20
 }
 
 /* Build an index that contains the just the files needed for a 3way merge */
-static int build_fake_ancestor(struct patch *list, const char *filename)
+static int build_fake_ancestor(struct apply_state *state, struct patch *list)
 {
 	struct patch *patch;
 	struct index_state result = { NULL };
@@ -4089,12 +4089,13 @@ static int build_fake_ancestor(struct patch *list, const char *filename)
 		}
 	}
 
-	hold_lock_file_for_update(&lock, filename, LOCK_DIE_ON_ERROR);
+	hold_lock_file_for_update(&lock, state->fake_ancestor, LOCK_DIE_ON_ERROR);
 	res = write_locked_index(&result, &lock, COMMIT_LOCK);
 	discard_index(&result);
 
 	if (res)
-		return error("Could not write temporary index to %s", filename);
+		return error("Could not write temporary index to %s",
+			     state->fake_ancestor);
 
 	return 0;
 }
@@ -4709,7 +4710,7 @@ static int apply_patch(struct apply_state *state,
 	}
 
 	if (state->fake_ancestor &&
-	    build_fake_ancestor(list, state->fake_ancestor)) {
+	    build_fake_ancestor(state, list)) {
 		res = -128;
 		goto end;
 	}
-- 
2.10.0.41.g9df52c3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help