diff mbox series

[3/3] checkkconfigsymbols.py: Forbid passing 'HEAD' to --commit

Message ID 20210822192205.43210-4-arielmarcovitch@gmail.com (mailing list archive)
State New, archived
Headers show
Series checkkconfigsymbols.py: Fix various bugs | expand

Commit Message

Ariel Marcovitch Aug. 22, 2021, 7:22 p.m. UTC
As opposed to the --diff option, --commit can get ref names instead of
commit hashes.

When using the --commit option, the script resets the working directory
to the commit before the given ref, by adding '~' to the end of the ref.

However, the 'HEAD' ref is relative, and so when the working directory
is reset to 'HEAD~', 'HEAD' points to what was 'HEAD~'. Then when the
script resets to 'HEAD' it actually stays in the same commit. In this
case, the script won't report any cases because there is no diff between
the cases of the two refs.

Prevent the user from using HEAD refs.

A better solution might be to resolve the refs before doing the
reset, but for now just disallow such refs.

Signed-off-by: Ariel Marcovitch <arielmarcovitch@gmail.com>
---
 scripts/checkkconfigsymbols.py | 3 +++
 1 file changed, 3 insertions(+)

Comments

Masahiro Yamada Aug. 24, 2021, 1:31 p.m. UTC | #1
On Mon, Aug 23, 2021 at 4:23 AM Ariel Marcovitch
<arielmarcovitch@gmail.com> wrote:
>
> As opposed to the --diff option, --commit can get ref names instead of
> commit hashes.
>
> When using the --commit option, the script resets the working directory
> to the commit before the given ref, by adding '~' to the end of the ref.
>
> However, the 'HEAD' ref is relative, and so when the working directory
> is reset to 'HEAD~', 'HEAD' points to what was 'HEAD~'. Then when the
> script resets to 'HEAD' it actually stays in the same commit. In this
> case, the script won't report any cases because there is no diff between
> the cases of the two refs.
>
> Prevent the user from using HEAD refs.
>
> A better solution might be to resolve the refs before doing the
> reset, but for now just disallow such refs.


Better than doing nothing.
So, applied to linux-kbuild.





> Signed-off-by: Ariel Marcovitch <arielmarcovitch@gmail.com>
> ---
>  scripts/checkkconfigsymbols.py | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
> index 875e9a2c14b2..6259698e662d 100755
> --- a/scripts/checkkconfigsymbols.py
> +++ b/scripts/checkkconfigsymbols.py
> @@ -103,6 +103,9 @@ def parse_options():
>                       "continue.")
>
>      if args.commit:
> +        if args.commit.startswith('HEAD'):
> +            sys.exit("The --commit option can't get use the HEAD ref")
> +
>          args.find = False
>
>      if args.ignore:
> --
> 2.25.1
>
Ariel Marcovitch Aug. 29, 2021, 1:23 p.m. UTC | #2
Hello!

On 24/08/2021 16:31, Masahiro Yamada wrote:
> On Mon, Aug 23, 2021 at 4:23 AM Ariel Marcovitch
> <arielmarcovitch@gmail.com> wrote:
>> As opposed to the --diff option, --commit can get ref names instead of
>> commit hashes.
>>
>> When using the --commit option, the script resets the working directory
>> to the commit before the given ref, by adding '~' to the end of the ref.
>>
>> However, the 'HEAD' ref is relative, and so when the working directory
>> is reset to 'HEAD~', 'HEAD' points to what was 'HEAD~'. Then when the
>> script resets to 'HEAD' it actually stays in the same commit. In this
>> case, the script won't report any cases because there is no diff between
>> the cases of the two refs.
>>
>> Prevent the user from using HEAD refs.
>>
>> A better solution might be to resolve the refs before doing the
>> reset, but for now just disallow such refs.
>
> Better than doing nothing.
> So, applied to linux-kbuild.
>
>
>
>
>
>> Signed-off-by: Ariel Marcovitch <arielmarcovitch@gmail.com>
>> ---
>>   scripts/checkkconfigsymbols.py | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
>> index 875e9a2c14b2..6259698e662d 100755
>> --- a/scripts/checkkconfigsymbols.py
>> +++ b/scripts/checkkconfigsymbols.py
>> @@ -103,6 +103,9 @@ def parse_options():
>>                        "continue.")
>>
>>       if args.commit:
>> +        if args.commit.startswith('HEAD'):
>> +            sys.exit("The --commit option can't get use the HEAD ref")

Just realized that the message says "can't get use" which doesn't make
much sense :)

Do you want me to send a new patch to fix it?

>> +
>>           args.find = False
>>
>>       if args.ignore:
>> --
>> 2.25.1
>>
>
Thanks for your time :)

Ariel Marcovitch
Masahiro Yamada Aug. 29, 2021, 11:22 p.m. UTC | #3
On Sun, Aug 29, 2021 at 10:23 PM Ariel Marcovitch <trhtkmarco@gmail.com> wrote:
>
> Hello!
>
> On 24/08/2021 16:31, Masahiro Yamada wrote:
> > On Mon, Aug 23, 2021 at 4:23 AM Ariel Marcovitch
> > <arielmarcovitch@gmail.com> wrote:
> >> As opposed to the --diff option, --commit can get ref names instead of
> >> commit hashes.
> >>
> >> When using the --commit option, the script resets the working directory
> >> to the commit before the given ref, by adding '~' to the end of the ref.
> >>
> >> However, the 'HEAD' ref is relative, and so when the working directory
> >> is reset to 'HEAD~', 'HEAD' points to what was 'HEAD~'. Then when the
> >> script resets to 'HEAD' it actually stays in the same commit. In this
> >> case, the script won't report any cases because there is no diff between
> >> the cases of the two refs.
> >>
> >> Prevent the user from using HEAD refs.
> >>
> >> A better solution might be to resolve the refs before doing the
> >> reset, but for now just disallow such refs.
> >
> > Better than doing nothing.
> > So, applied to linux-kbuild.
> >
> >
> >
> >
> >
> >> Signed-off-by: Ariel Marcovitch <arielmarcovitch@gmail.com>
> >> ---
> >>   scripts/checkkconfigsymbols.py | 3 +++
> >>   1 file changed, 3 insertions(+)
> >>
> >> diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
> >> index 875e9a2c14b2..6259698e662d 100755
> >> --- a/scripts/checkkconfigsymbols.py
> >> +++ b/scripts/checkkconfigsymbols.py
> >> @@ -103,6 +103,9 @@ def parse_options():
> >>                        "continue.")
> >>
> >>       if args.commit:
> >> +        if args.commit.startswith('HEAD'):
> >> +            sys.exit("The --commit option can't get use the HEAD ref")
>
> Just realized that the message says "can't get use" which doesn't make
> much sense :)
>
> Do you want me to send a new patch to fix it?

OK, I dropped 3/3 from my tree.

Please send v2.






> >> +
> >>           args.find = False
> >>
> >>       if args.ignore:
> >> --
> >> 2.25.1
> >>
> >
> Thanks for your time :)
>
> Ariel Marcovitch
>
diff mbox series

Patch

diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py
index 875e9a2c14b2..6259698e662d 100755
--- a/scripts/checkkconfigsymbols.py
+++ b/scripts/checkkconfigsymbols.py
@@ -103,6 +103,9 @@  def parse_options():
                      "continue.")
 
     if args.commit:
+        if args.commit.startswith('HEAD'):
+            sys.exit("The --commit option can't get use the HEAD ref")
+
         args.find = False
 
     if args.ignore: