Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
apply: split load_preimage() helper function out
author
Junio C Hamano
<gitster@pobox.com>
Tue, 8 May 2012 20:35:21 +0000
(13:35 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 9 Jul 2012 21:36:26 +0000
(14:36 -0700)
Given a patch for a single path, the function apply_data() reads the
preimage in core, and applies the change represented in the patch.
Separate out the first part that reads the preimage into a separate
helper function load_preimage().
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/apply.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
f4c66ee
)
diff --git
a/builtin/apply.c
b/builtin/apply.c
index 487e4034a57250cb88034b148260d69ae4642e76..4d2546f5e1ce6a702b5dc27f34c97e78770c4f64 100644
(file)
--- a/
builtin/apply.c
+++ b/
builtin/apply.c
@@
-3046,10
+3046,10
@@
static int checkout_target(struct cache_entry *ce, struct stat *st)
return 0;
}
return 0;
}
-static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *ce)
+static int load_preimage(struct image *image,
+ struct patch *patch, struct stat *st, struct cache_entry *ce)
{
struct strbuf buf = STRBUF_INIT;
{
struct strbuf buf = STRBUF_INIT;
- struct image image;
size_t len;
char *img;
struct patch *tpatch;
size_t len;
char *img;
struct patch *tpatch;
@@
-3086,7
+3086,16
@@
static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *
}
img = strbuf_detach(&buf, &len);
}
img = strbuf_detach(&buf, &len);
- prepare_image(&image, img, len, !patch->is_binary);
+ prepare_image(image, img, len, !patch->is_binary);
+ return 0;
+}
+
+static int apply_data(struct patch *patch, struct stat *st, struct cache_entry *ce)
+{
+ struct image image;
+
+ if (load_preimage(&image, patch, st, ce) < 0)
+ return -1;
if (apply_fragments(&image, patch) < 0)
return -1; /* note with --reject this succeeds. */
if (apply_fragments(&image, patch) < 0)
return -1; /* note with --reject this succeeds. */