Skip to contentSkip to conversation

checkkconfigsymbols.py: Forbid passing 'HEAD' to --commit

PATCH In review Ariel Marcovitch 2 participants 2 messages Sep 1, 2021 – Sep 10, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkkconfigsymbols.py: Forbid passing 'HEAD' to --commit

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.

---
 scripts/checkkconfigsymbols.py | 3 +++
 1 file changed, 3 insertions(+)
scripts/checkkconfigsymbols.py +3 -0
index b9b0f15e5880..c57c990c3244 100755
@@ -102,6 +102,9 @@ def parse_options():
                      "continue.")
 
     if args.commit:
+        if args.commit.startswith('HEAD'):
+            sys.exit("The --commit option can't use the HEAD ref")
+
         args.find = False
 
     if args.ignore:

base-commit: 087e856cfb76e9eef9a3a6e000854794f3c36e24

Signature · 1 line
2.25.1
#1 lore raw
Quoted 15 lines · Ariel Marcovitch

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.

Quoted 8 lines

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

---
 scripts/checkkconfigsymbols.py | 3 +++
 1 file changed, 3 insertions(+)

Applied to linux-kbuild. Thanks.

Quoted 19 lines
scripts/checkkconfigsymbols.py +3 -0
index b9b0f15e5880..c57c990c3244 100755
@@ -102,6 +102,9 @@ def parse_options():
                      "continue.")
 
     if args.commit:
+        if args.commit.startswith('HEAD'):
+            sys.exit("The --commit option can't use the HEAD ref")
+
         args.find = False
 
     if args.ignore:

base-commit: 087e856cfb76e9eef9a3a6e000854794f3c36e24 --
2.25.1

Signature · 2 lines
Best Regards
Masahiro Yamada