How to apply patches easily ?

1,309 views
Skip to first unread message

Bruno Bodin

unread,
Apr 19, 2016, 8:52:26 AM4/19/16
to isl-development
Hello,

During the last weeks I applied patches manually. It was convenient as
the patches were small. I started doing it in the first place because
the first patch I tried partially failed. Probably it was applied to a
different version of the file, or I might not use patch properly (I do
patch < patchfile).

Now I'm trying to apply a bigger patch and I'm in trouble doing it
manually (too long), and I'm afraid that using patch will fail again.

Am I doing right, or is there is a proper way to use these patches ?
Otherwise, is there is a repo where I can find a patched version ?

Thanks,
Bruno



--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

Sven Verdoolaege

unread,
Apr 19, 2016, 9:05:30 AM4/19/16
to Bruno Bodin, isl-development
On Tue, Apr 19, 2016 at 01:52:25PM +0100, Bruno Bodin wrote:
> Hello,
>
> During the last weeks I applied patches manually. It was convenient as

You really shouldn't do that if you are testing patches as you
may end up testing something other than the patch that was sent out.

> the patches were small. I started doing it in the first place because
> the first patch I tried partially failed. Probably it was applied to a
> different version of the file, or I might not use patch properly (I do
> patch < patchfile).

You should use "git apply" or "git am" instead.
"git am" can be used to apply an entire series of patches in one go.
If this fails for some reason, then you should report the failure.

skimo

Bruno Bodin

unread,
Apr 19, 2016, 9:45:59 AM4/19/16
to sven.ver...@gmail.com, isl-development
Typically, I tried to patch the 7 patches series using git apply, and
it failed (see log + patch file attached). I suppose I need to apply
all the previous patches to get it right, Am I right ?

> git apply sven.patch -v
Checking patch scan.cc...
error: while searching for:
{
PetScan *ps = (PetScan *) user;
isl_id *id;
QualType qt;

id = pet_expr_access_get_id(access);
qt = pet_id_get_array_type(id);
isl_id_free(id);
return ps->get_array_size(qt);
}

/* Construct and return a pet_array corresponding to the variable

error: patch failed: scan.cc:2191
error: scan.cc: patch does not apply
Checking patch scan.h...
error: while searching for:

static __isl_give isl_val *extract_int(isl_ctx *ctx,
clang::IntegerLiteral *expr);
__isl_give pet_expr *get_array_size(clang::QualType qt);
struct pet_array *extract_array(__isl_keep isl_id *id,
PetTypes *types, __isl_keep pet_context *pc);
private:

error: patch failed: scan.h:157
error: scan.h: patch does not apply
Checking patch Makefile.am...
error: while searching for:
id.cc \
inliner.h \
inliner.cc \
killed_locals.h \
killed_locals.cc \
loc.h \
loc.c \
nest.h \
nest.c \
options.h \

error: patch failed: Makefile.am:68
error: Makefile.am: patch does not apply
Checking patch isl_id_to_pet_expr.c...
Checking patch isl_id_to_pet_expr.h...
Checking patch maybe_pet_expr.h...
Checking patch scan.cc...
error: while searching for:
for (it_s = summary_cache.begin(); it_s != summary_cache.end();
++it_s)
pet_function_summary_free(it_s->second);

isl_union_map_free(value_bounds);
}


error: patch failed: scan.cc:216
error: scan.cc: patch does not apply
Checking patch scan.h...
error: while searching for:
*/
bool partial;

/* A cache of size expressions for array types as computed
* by PetScan::get_array_size.
*/

error: patch failed: scan.h:99
error: scan.h: patch does not apply
Checking patch scan.cc...
error: while searching for:
return expr;
}

/* Does "expr" represent the "integer" infinity?
*/
static int is_infty(__isl_keep pet_expr *expr)

error: patch failed: scan.cc:2663
error: scan.cc: patch does not apply
Checking patch scan.h...
error: while searching for:
bool partial;

/* A cache of size expressions for array identifiers as
computed
* by PetScan::get_array_size.
*/
isl_id_to_pet_expr *id_size;
/* A cache of size expressions for array types as computed

error: patch failed: scan.h:101
error: scan.h: patch does not apply
Checking patch substituter.cc...
error: while searching for:
void *user);
}

/* Perform the substitutions stored in "subs" on "tree" and return
* the results.
* In particular, perform the substitutions on each of the access

error: patch failed: substituter.cc:49
error: substituter.cc: patch does not apply
Checking patch substituter.h...
error: while searching for:

void add_sub(__isl_take isl_id *id, __isl_take pet_expr *expr);

__isl_give pet_tree *substitute(__isl_take pet_tree *tree);

~pet_substituter();

error: patch failed: substituter.h:16
error: substituter.h: patch does not apply
Checking patch scan.cc...
Hunk #1 succeeded at 1870 (offset -1 lines).
Checking patch scan.cc...
error: while searching for:
return 0;
}

/* Try and construct a pet_tree from the body of "fd" using the actual
* arguments in "call" in place of the formal arguments.
* "fd" is assumed to point to the declaration with a function body.

error: patch failed: scan.cc:1863
error: scan.cc: patch does not apply
Checking patch scan.h...
error: while searching for:
clang::QualType qt, int pos);
struct pet_array *set_upper_bounds(struct pet_array *array,
__isl_keep pet_context *pc);

__isl_give pet_tree *insert_initial_declarations(
__isl_take pet_tree *tree, int n_decl,

error: patch failed: scan.h:192
error: scan.h: patch does not apply
Checking patch tests/inline11.c...
Checking patch tests/inline11.scop...
sven.patch

Sven Verdoolaege

unread,
Apr 19, 2016, 10:07:15 AM4/19/16
to Bruno Bodin, isl-development
On Tue, Apr 19, 2016 at 02:45:56PM +0100, Bruno Bodin wrote:
> Typically, I tried to patch the 7 patches series using git apply, and
> it failed (see log + patch file attached). I suppose I need to apply
> all the previous patches to get it right, Am I right ?

If you mean that you need to apply the patches in the series in order,
then yes.

> > git apply sven.patch -v

This "sven.patch" doesn't look like the patches I sent out.
First off, it's whitespace damaged, i.e., tabs have been replaced by spaces.
Did you copy-paste this patch?
Also, you seem to have concatenated all the patches into one.
You can't do that. You need to apply them one by one ("git am"
takes care of that).

skimo

Bruno Bodin

unread,
Apr 19, 2016, 10:19:18 AM4/19/16
to sven.ver...@gmail.com, isl-development
On Tue, 2016-04-19 at 16:07 +0200, Sven Verdoolaege wrote:
> On Tue, Apr 19, 2016 at 02:45:56PM +0100, Bruno Bodin wrote:
> > Typically, I tried to patch the 7 patches series using git apply,
> > and
> > it failed (see log + patch file attached). I suppose I need to
> > apply
> > all the previous patches to get it right, Am I right ?
>
> If you mean that you need to apply the patches in the series in
> order,
> then yes.

No I meant something different, but your next remark seems to explain
the problem better !

>
> > > git apply sven.patch -v
>
> This "sven.patch" doesn't look like the patches I sent out.
> First off, it's whitespace damaged, i.e., tabs have been replaced by
> spaces.
> Did you copy-paste this patch?

Yes, I only have access to the patch through the google page.
I subscribed to it a few hours ago to avoid this issue.

Thanks


> Also, you seem to have concatenated all the patches into one.
> You can't do that. You need to apply them one by one ("git am"
> takes care of that).
>
> skimo
>

Sven Verdoolaege

unread,
Apr 19, 2016, 10:37:34 AM4/19/16
to Bruno Bodin, isl-development
On Tue, Apr 19, 2016 at 03:19:16PM +0100, Bruno Bodin wrote:
> On Tue, 2016-04-19 at 16:07 +0200, Sven Verdoolaege wrote:
> > This "sven.patch" doesn't look like the patches I sent out.
> > First off, it's whitespace damaged, i.e., tabs have been replaced by
> > spaces.
> > Did you copy-paste this patch?
>
> Yes,

Don't do that, especially not from the default view
on the google groups page.

> I only have access to the patch through the google page.

You can get the original patch by clicking on the down arrow
in the top right corner of the message frame, selecting
"Show original" and then clicking "Show only message"
on top of the original message. The result can be saved
using the regular "Save/Save as" function of your browser.
The resulting file should have the correct patch and you
can apply it using "git am". You should even be able to
concatenate all these files and then apply them at once
using "git am", but I haven't tried that.

skimo
Reply all
Reply to author
Forward
0 new messages