Skip to contentSkip to conversation

patman: Only apply patches when we know the original HEAD

PATCH New Simon Glass 4 participants 17 messages Jun 12, 2014 – Jul 28, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

When patman applies the patches it checks out a new branch, uses 'git am' to apply the patches one by one, and then tries to go back to the old branch. If you try this when the branch is 'undefined', this doesn't work as patman cannot restore the correct branch after applying the patches. It seems that 'undefined' is created by git and is persistent after it is created, so that you can end up on quite an old branch.

Add a check for the 'undefined' branch to avoid this.

---

 tools/patman/gitutil.py | 4 ++++
 1 file changed, 4 insertions(+)
tools/patman/gitutil.py +4 -0
index 3ea256d..7b75c83 100644
@@ -232,6 +232,10 @@ def ApplyPatches(verbose, args, start_point):
         print stdout
         return False
     old_head = stdout.splitlines()[0]
+    if old_head == 'undefined':
+        str = "Invalid HEAD '%s'" % stdout.strip()
+        print col.Color(col.RED, str)
+        return False
 
     # Checkout the required start point
     cmd = ['git', 'checkout', 'HEAD~%d' % start_point]
Signature · 1 line
2.0.0.526.g5318336
#1 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Masahiro,

Quoted 11 lines · Simon Glass

When patman applies the patches it checks out a new branch, uses 'git am' to apply the patches one by one, and then tries to go back to the old branch. If you try this when the branch is 'undefined', this doesn't work as patman cannot restore the correct branch after applying the patches. It seems that 'undefined' is created by git and is persistent after it is created, so that you can end up on quite an old branch.

Add a check for the 'undefined' branch to avoid this.

Can you please check if this fixes the problem you reported? If so I would like to get it into this release.

Regards,
Simon

#2 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Simon,

Quoted 10 lines · On Sat, 21 Jun 2014 10:27:06 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

Quoted 7 lines · Simon Glass

When patman applies the patches it checks out a new branch, uses 'git am' to apply the patches one by one, and then tries to go back to the old branch. If you try this when the branch is 'undefined', this doesn't work as patman cannot restore the correct branch after applying the patches. It seems that 'undefined' is created by git and is persistent after it is created, so that you can end up on quite an old branch.

Quoted 7 lines
Quoted 4 lines

Add a check for the 'undefined' branch to avoid this.

Can you please check if this fixes the problem you reported? If so I would like to get it into this release.

I cannot understand why patman needs to apply the patches with 'git am'.

Why isn't patman like this ?
[1] Generate patches with 'git format-patch'
[2] Parse the patman-tags in the generated patches and edit them.
[3] Send the patches with 'git send-email'

Best Regards
Masahiro Yamada

#3 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Masahiro,

Quoted 25 lines · Masahiro Yamada

Hi Simon,

Quoted 10 lines · On Sat, 21 Jun 2014 10:27:06 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

Quoted 7 lines · Simon Glass

When patman applies the patches it checks out a new branch, uses 'git am' to apply the patches one by one, and then tries to go back to the old branch. If you try this when the branch is 'undefined', this doesn't work as patman cannot restore the correct branch after applying the patches. It seems that 'undefined' is created by git and is persistent after it is created, so that you can end up on quite an old branch.

Quoted 7 lines
Quoted 4 lines

Add a check for the 'undefined' branch to avoid this.

Can you please check if this fixes the problem you reported? If so I would like to get it into this release.

Quoted 5 lines

I cannot understand why patman needs to apply the patches with 'git am'.

Why isn't patman like this ?
[1] Generate patches with 'git format-patch'
[2] Parse the patman-tags in the generated patches and edit them.

2a. Apply the patches to make sure there are no whitespace errors.

Quoted 2 lines

[3] Send the patches with 'git send-email'

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has got smarter?

Quoted 4 lines

Best Regards
Masahiro Yamada

Regards,
Simon

#4 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Simon,

Quoted 34 lines · On Sun, 22 Jun 2014 21:39:26 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

Quoted 25 lines · Masahiro Yamada

Hi Simon,

Quoted 10 lines · On Sat, 21 Jun 2014 10:27:06 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

Quoted 7 lines · Simon Glass

When patman applies the patches it checks out a new branch, uses 'git am' to apply the patches one by one, and then tries to go back to the old branch. If you try this when the branch is 'undefined', this doesn't work as patman cannot restore the correct branch after applying the patches. It seems that 'undefined' is created by git and is persistent after it is created, so that you can end up on quite an old branch.

Quoted 7 lines
Quoted 4 lines

Add a check for the 'undefined' branch to avoid this.

Can you please check if this fixes the problem you reported? If so I would like to get it into this release.

Quoted 5 lines

I cannot understand why patman needs to apply the patches with 'git am'.

Why isn't patman like this ?
[1] Generate patches with 'git format-patch'
[2] Parse the patman-tags in the generated patches and edit them.

Quoted 8 lines

2a. Apply the patches to make sure there are no whitespace errors.

Quoted 2 lines

[3] Send the patches with 'git send-email'

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has got smarter?

I still don't understand.
Anyway, Patman invokes checkpatch.pl, right? Isn't whitespace error checking of checkpatch nice?

Best Regards
Masahiro Yamada

#5 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Masahiro,

Quoted 9 lines · Masahiro Yamada

Hi Simon,

Quoted 3 lines · On Sun, 22 Jun 2014 21:39:26 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

On 22 June 2014 21:19, Masahiro Yamada <[email protected]>

Quoted 10 lines · wrote:
Quoted 10 lines
Quoted 10 lines

Hi Simon,

Quoted 4 lines · On Sat, 21 Jun 2014 10:27:06 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

Quoted 1 line · Simon Glass

When patman applies the patches it checks out a new branch, uses

'git am'

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to apply the patches one by one, and then tries to go back to the

old

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

branch. If you try this when the branch is 'undefined', this

doesn't work

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

as patman cannot restore the correct branch after applying the

patches.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

It seems that 'undefined' is created by git and is persistent

after it is

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

created, so that you can end up on quite an old branch.

Add a check for the 'undefined' branch to avoid this.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Can you please check if this fixes the problem you reported? If so I would like to get it into this release.

I cannot understand why patman needs to apply the patches with 'git

am'.

Quoted 10 lines
Quoted 10 lines
Quoted 4 lines

Why isn't patman like this ?
[1] Generate patches with 'git format-patch'
[2] Parse the patman-tags in the generated patches and edit them.

2a. Apply the patches to make sure there are no whitespace errors.

Quoted 2 lines

[3] Send the patches with 'git send-email'

Quoted 7 lines
Quoted 3 lines

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has got smarter?

I still don't understand.
Anyway, Patman invokes checkpatch.pl, right? Isn't whitespace error checking of checkpatch nice?

Not when I wrote patman, no. Maybe it has changed? I could perhaps invert the meaning of the -a flag :-)

Regards,
Simon

Quoted 5 lines

Best Regards
Masahiro Yamada

#6 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

In reply to Simon Glass
Quoted 3 lines · Simon Glass

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has got smarter?

Couldn't ./scripts/cleanpatch be used to fix the whitespace issues?

#7 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi,

Quoted 8 lines · Fabio Estevam
Quoted 3 lines · Simon Glass

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has got smarter?

Couldn't ./scripts/cleanpatch be used to fix the whitespace issues?

Maybe. If you know how to test this please give it a try.

Regards,
Simon

#8 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Simon,

Quoted 6 lines · On Sun, 22 Jun 2014 22:54:43 -0600 Simon Glass <[email protected]> wrote:

Hi,

Quoted 3 lines · Fabio Estevam

On Mon, Jun 23, 2014 at 12:39 AM, Simon Glass <[email protected]> wrote:

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has got smarter?

Couldn't ./scripts/cleanpatch be used to fix the whitespace issues?

Maybe. If you know how to test this please give it a try.

Does Patman fix the whitespace issues?

I'm getting confused.

To make things clearer, please let me ask you some questions.

[1] What does "whitespace errors" mean here?

- Trailing whitespaces ?
- Spaces before TAB indent ?
- Or what else ?

[2] What do you expect Patman to do when it finds those errors?
- Just display an error message ?
or
- Fix the issues automatically ?

[3] Which features were missing from scripts/checkpatch.pl when you wrote Patman first ?

Best Regards
Masahiro Yamada

#9 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

+Doug who may have some thoughts here.

HI Masahiro,

Quoted 14 lines · Masahiro Yamada

Hi Simon,

Quoted 5 lines · On Sun, 22 Jun 2014 22:54:43 -0600 Simon Glass <[email protected]> wrote:

Hi,

Quoted 2 lines · Fabio Estevam

On Mon, Jun 23, 2014 at 12:39 AM, Simon Glass <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has

Quoted 8 lines

got

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

smarter?

Couldn't ./scripts/cleanpatch be used to fix the whitespace issues?

Maybe. If you know how to test this please give it a try.

Note, I do understand all the questions, but the problem is I am not

completely sure how this happens.

Quoted 8 lines

Does Patman fix the whitespace issues?

No, it just runs 'git am' which will then report them.

I'm getting confused.

Quoted 8 lines

To make things clearer, please let me ask you some questions.

[1] What does "whitespace errors" mean here?

- Trailing whitespaces ?
- Spaces before TAB indent ?
- Or what else ?

Both of those, plus a blank line at EOF as I understand it.

Quoted 4 lines

[2] What do you expect Patman to do when it finds those errors?
- Just display an error message ?

Yes (it displays an error from 'git am')

Quoted 3 lines

or
- Fix the issues automatically ?

No - apart from removing tags and adding notes patman avoids changing patches as a matter of policy.

Quoted 4 lines

[3] Which features were missing from scripts/checkpatch.pl when you wrote Patman first ?

It's really a belts-and-braces check that nothing will go wrong when the patches are applied. I have had it report errors to me on my own patches, although not recently. I'm not sure if it is still needed though.

Regards,
Simon

#10 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Quoted 67 lines · On Mon, 23 Jun 2014 06:11:28 -0600 Simon Glass <[email protected]> wrote:

+Doug who may have some thoughts here.

HI Masahiro,

Quoted 14 lines · Masahiro Yamada

Hi Simon,

Quoted 5 lines · On Sun, 22 Jun 2014 22:54:43 -0600 Simon Glass <[email protected]> wrote:

Hi,

Quoted 2 lines · Fabio Estevam

On Mon, Jun 23, 2014 at 12:39 AM, Simon Glass <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines

The whitespace problems are not common but they do happen sometimes - or at least I have seen it at times. Unless perhaps checkpatch has

Quoted 8 lines

got

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

smarter?

Couldn't ./scripts/cleanpatch be used to fix the whitespace issues?

Maybe. If you know how to test this please give it a try.

Note, I do understand all the questions, but the problem is I am not

completely sure how this happens.

Quoted 8 lines

Does Patman fix the whitespace issues?

No, it just runs 'git am' which will then report them.

I'm getting confused.

Quoted 8 lines

To make things clearer, please let me ask you some questions.

[1] What does "whitespace errors" mean here?

- Trailing whitespaces ?
- Spaces before TAB indent ?
- Or what else ?

Both of those, plus a blank line at EOF as I understand it.

Quoted 4 lines

[2] What do you expect Patman to do when it finds those errors?
- Just display an error message ?

Yes (it displays an error from 'git am')

Quoted 3 lines

or
- Fix the issues automatically ?

No - apart from removing tags and adding notes patman avoids changing patches as a matter of policy.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

[3] Which features were missing from scripts/checkpatch.pl when you wrote Patman first ?

It's really a belts-and-braces check that nothing will go wrong when the patches are applied. I have had it report errors to me on my own patches, although not recently. I'm not sure if it is still needed though.

OK. It seems better to check.

I added some patches which include whitespace errors and ran Patman.

It looks like nothing changes with/without -a option.

$ tools/patman/patman -a -c 3
1 warnings for 0002-arm-commit-2.patch:
	Line 21/0 has space before tab

1 warnings for 0003-arm-commit-3.patch:
Found possible blank line(s) at end of file 'None'

Cleaned 3 patches
1 errors, 0 warnings, 0 checks for 0001-arm-commit-1.patch:
error: common/cmd_mmc.c,22: trailing whitespace

1 errors, 2 warnings, 0 checks for 0002-arm-commit-2.patch:
error: common/cmd_mmc.c,26: code indent should use tabs where possible
warning: common/cmd_mmc.c,26: please, no space before tabs
warning: common/cmd_mmc.c,26: please, no spaces at the start of a line

checkpatch.pl found 2 error(s), 2 warning(s), 0 checks(s)

$ tools/patman/patman  -c 3
1 warnings for 0002-arm-commit-2.patch:
	Line 21/0 has space before tab

1 warnings for 0003-arm-commit-3.patch:
Found possible blank line(s) at end of file 'None'

Cleaned 3 patches
1 errors, 0 warnings, 0 checks for 0001-arm-commit-1.patch:
error: common/cmd_mmc.c,22: trailing whitespace

1 errors, 2 warnings, 0 checks for 0002-arm-commit-2.patch:
error: common/cmd_mmc.c,26: code indent should use tabs where possible
warning: common/cmd_mmc.c,26: please, no space before tabs
warning: common/cmd_mmc.c,26: please, no spaces at the start of a line

checkpatch.pl found 2 error(s), 2 warning(s), 0 checks(s)

Best Regards
Masahiro Yamada

#11 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi,

Quoted 38 lines · Masahiro Yamada

OK. It seems better to check.

I added some patches which include whitespace errors and ran Patman.

It looks like nothing changes with/without -a option.

$ tools/patman/patman -a -c 3
1 warnings for 0002-arm-commit-2.patch:
        Line 21/0 has space before tab

1 warnings for 0003-arm-commit-3.patch:
Found possible blank line(s) at end of file 'None'

Cleaned 3 patches
1 errors, 0 warnings, 0 checks for 0001-arm-commit-1.patch:
error: common/cmd_mmc.c,22: trailing whitespace

1 errors, 2 warnings, 0 checks for 0002-arm-commit-2.patch:
error: common/cmd_mmc.c,26: code indent should use tabs where possible
warning: common/cmd_mmc.c,26: please, no space before tabs
warning: common/cmd_mmc.c,26: please, no spaces at the start of a line

checkpatch.pl found 2 error(s), 2 warning(s), 0 checks(s)

$ tools/patman/patman  -c 3
1 warnings for 0002-arm-commit-2.patch:
        Line 21/0 has space before tab

1 warnings for 0003-arm-commit-3.patch:
Found possible blank line(s) at end of file 'None'

Cleaned 3 patches
1 errors, 0 warnings, 0 checks for 0001-arm-commit-1.patch:
error: common/cmd_mmc.c,22: trailing whitespace

Quoted 6 lines

1 errors, 2 warnings, 0 checks for 0002-arm-commit-2.patch:
error: common/cmd_mmc.c,26: code indent should use tabs where possible
warning: common/cmd_mmc.c,26: please, no space before tabs
warning: common/cmd_mmc.c,26: please, no spaces at the start of a line

checkpatch.pl found 2 error(s), 2 warning(s), 0 checks(s)

It sure looks like checkpatch now catches things so it never gets to "git am". Making "-a" off by default seems reasonable to me.

-Doug

#12 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi,

Quoted 48 lines · Doug Anderson

Hi,

Quoted 43 lines · Masahiro Yamada

OK. It seems better to check.

I added some patches which include whitespace errors and ran Patman.

It looks like nothing changes with/without -a option.

$ tools/patman/patman -a -c 3
1 warnings for 0002-arm-commit-2.patch:
        Line 21/0 has space before tab

1 warnings for 0003-arm-commit-3.patch:
Found possible blank line(s) at end of file 'None'

Cleaned 3 patches
1 errors, 0 warnings, 0 checks for 0001-arm-commit-1.patch:
error: common/cmd_mmc.c,22: trailing whitespace

1 errors, 2 warnings, 0 checks for 0002-arm-commit-2.patch:
error: common/cmd_mmc.c,26: code indent should use tabs where possible
warning: common/cmd_mmc.c,26: please, no space before tabs
warning: common/cmd_mmc.c,26: please, no spaces at the start of a line

checkpatch.pl found 2 error(s), 2 warning(s), 0 checks(s)

$ tools/patman/patman  -c 3
1 warnings for 0002-arm-commit-2.patch:
        Line 21/0 has space before tab

1 warnings for 0003-arm-commit-3.patch:
Found possible blank line(s) at end of file 'None'

Cleaned 3 patches
1 errors, 0 warnings, 0 checks for 0001-arm-commit-1.patch:
error: common/cmd_mmc.c,22: trailing whitespace

1 errors, 2 warnings, 0 checks for 0002-arm-commit-2.patch:
error: common/cmd_mmc.c,26: code indent should use tabs where possible
warning: common/cmd_mmc.c,26: please, no space before tabs
warning: common/cmd_mmc.c,26: please, no spaces at the start of a line

Quoted 4 lines
Quoted 1 line

checkpatch.pl found 2 error(s), 2 warning(s), 0 checks(s)

It sure looks like checkpatch now catches things so it never gets to "git am". Making "-a" off by default seems reasonable to me.

Well, good.

Still, we need this patch to fix the bug I thihnk.

I'll do a new patch to invert the flag too.

Regards,
Simon

#13 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Masahiro,

Quoted 10 lines · Simon Glass

Hi,

Quoted 2 lines · Doug Anderson

It sure looks like checkpatch now catches things so it never gets to "git am". Making "-a" off by default seems reasonable to me.

Well, good.

Still, we need this patch to fix the bug I thihnk.

Aside from the discussion about apply patches, does this fix the bug you reported?

Quoted 5 lines

I'll do a new patch to invert the flag too.

Regards,
Simon

Regards,
Simon

#14 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Simon,

Quoted 10 lines · On Wed, 25 Jun 2014 10:53:08 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

Quoted 7 lines · Simon Glass

Hi,

Quoted 2 lines · Doug Anderson

It sure looks like checkpatch now catches things so it never gets to "git am". Making "-a" off by default seems reasonable to me.

Quoted 6 lines
Quoted 3 lines

Well, good.

Still, we need this patch to fix the bug I thihnk.

Aside from the discussion about apply patches, does this fix the bug you reported?

Yes, that fixes the issue. Thanks!
But, is '-a' option still necessary?
Shoud we rip it off someday?

Best Regards
Masahiro Yamada

#15 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Hi Masahiro,

Quoted 18 lines · Masahiro Yamada

Hi Simon,

Quoted 12 lines · On Wed, 25 Jun 2014 10:53:08 -0600 Simon Glass <[email protected]> wrote:

Hi Masahiro,

Quoted 9 lines · Simon Glass

Hi,

Quoted 2 lines · Doug Anderson

It sure looks like checkpatch now catches things so it never gets to "git am". Making "-a" off by default seems reasonable to me.

Well, good.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Still, we need this patch to fix the bug I thihnk.

Aside from the discussion about apply patches, does this fix the bug you reported?

Yes, that fixes the issue. Thanks!
But, is '-a' option still necessary?
Shoud we rip it off someday?

I'm in favour of this, perhaps for the next release.

Regards,
Simon

author Applied
#16 lore raw

PATCH 1/1 patman: Only apply patches when we know the original HEAD

Applied via x86 tree.