Skip to contentSkip to conversation

devtools: check commit log fixes syntax

PATCH In review Ferruh Yigit 4 participants 15 messages Jan 29, 2019 – Jan 30, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 devtools: check commit log fixes syntax

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

---
Cc: Qi Zhang <[email protected]>

---
 devtools/check-git-log.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/check-git-log.sh +5 -0
index d39064f9d..f4d6c1fba 100755
@@ -177,6 +177,11 @@ bad=$(for fixtag in $fixtags ; do
 done | sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
 
+bad=$(for fixtag in $fixtags ; do
+	echo $fixtag | awk '{print $2}' | awk 'length != 12 {print}'
+done)
+[ -z "$bad" ] || printf "Wrong 'Fixes' syntax:\n$bad\n"
+
 # check Cc: [email protected] for fixes
 bad=$(for fix in $stablefixes ; do
 	git log --format='%b' -1 $fix | grep -qi '^Cc: *[email protected]' ||
Signature · 1 line
2.17.2
#1 lore raw
Quoted 5 lines · Ferruh Yigit

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

Can't git decide to report a longer string in case of collisions of abbreviated id ?

Tried this for 2 characters, and git forcefully reported 5 chars:

$ git log -1 --abbrev=2 origin/master --format='Fixes: %h (\"%s\")'
Fixes: a2f9c (\"version: 19.02-rc4\")

I did not find any collisions with 12 characters abbreviated commitid, but I am not sure enforcing the check on exactly 12 characters is a good idea in the long run.

Quoted 12 lines

---
Cc: Qi Zhang <[email protected]>

---
 devtools/check-git-log.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/check-git-log.sh +0 -0
index d39064f9d..f4d6c1fba 100755

devtools/check-git-log.sh bad=$(for fixtag in $fixtags ; do · line 181

Quoted 5 lines
devtools/check-git-log.sh +1 -0
@@ -177,6 +177,11 @@ bad=$(for fixtag in $fixtags ; do
 done | sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
 
+bad=$(for fixtag in $fixtags ; do
 

+ echo $fixtag | awk '{print $2}' | awk 'length != 12 {print}'

Quoted 1 line

+done)

Quoted 1 line

Not an awk expert (this could be done in pure shell, but this is a different story :-p), but I would see something like:

for fixtag in $fixtags; do
echo $fixtag | awk 'length($2) < 12 { print $2 }';
done

Signature · 1 line
David Marchand
#2 lore raw
Quoted 11 lines · David Marchand
Quoted 5 lines · Ferruh Yigit

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

Can't git decide to report a longer string in case of collisions of abbreviated id ?

Quoted 7 lines

Tried this for 2 characters, and git forcefully reported 5 chars:

$ git log -1 --abbrev=2 origin/master --format='Fixes: %h (\"%s\")'
Fixes: a2f9c (\"version: 19.02-rc4\")

I did not find any collisions with 12 characters abbreviated commitid, but I am not sure enforcing the check on exactly 12 characters is a good idea in the long run.

Yes git can report a longer string in case of collisions, but I don't expect to have one with 12 characters.

This is mainly for some cases either people use full 40 chars or small ones.

Indeed in background I am (and most probably Thomas too) fixing them while merging, I thought it is better idea to integrate that into script so that developers can be aware of the syntax issue and fix it before sending.

Quoted 24 lines
Quoted 14 lines

---
Cc: Qi Zhang <[email protected]>

---
 devtools/check-git-log.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/check-git-log.sh +0 -0
index d39064f9d..f4d6c1fba 100755

devtools/check-git-log.sh bad=$(for fixtag in $fixtags ; do · line 181

Quoted 5 lines
devtools/check-git-log.sh +1 -0
@@ -177,6 +177,11 @@ bad=$(for fixtag in $fixtags ; do
 done | sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
 
+bad=$(for fixtag in $fixtags ; do
 

+ echo $fixtag | awk '{print $2}' | awk 'length != 12 {print}'

Quoted 1 line

+done)

Quoted 1 line
Quoted 6 lines

Not an awk expert (this could be done in pure shell, but this is a different story :-p), but I would see something like:

for fixtag in $fixtags; do
echo $fixtag | awk 'length($2) < 12 { print $2 }';
done

Yes, looks better, I will update the script.

And no specific preference on shell or awk implementation, there is no performance concern in this script and awk already used by it, I am good as long as it is functional.

#3 lore raw
Quoted 26 lines · Ferruh Yigit
Quoted 1 line · David Marchand

On Tue, Jan 29, 2019 at 4:31 PM Ferruh Yigit <[email protected]>

Quoted 7 lines · wrote:
Quoted 6 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

Quoted 8 lines

Can't git decide to report a longer string in case of collisions of abbreviated id ?

Tried this for 2 characters, and git forcefully reported 5 chars:

$ git log -1 --abbrev=2 origin/master --format='Fixes: %h (\"%s\")'
Fixes: a2f9c (\"version: 19.02-rc4\")

I did not find any collisions with 12 characters abbreviated commitid,

but

Quoted 2 lines

I am not sure enforcing the check on exactly 12 characters is a good idea in the long run.

Yes git can report a longer string in case of collisions, but I don't expect to
have one with 12 characters.

Quoted 7 lines

This is mainly for some cases either people use full 40 chars or small ones.

Indeed in background I am (and most probably Thomas too) fixing them while merging, I thought it is better idea to integrate that into script so that developers can be aware of the syntax issue and fix it before sending.

I can understand you want to avoid such edits yes, and so this patch.

However, I think we can do one more thing.
The contributing guide does indicate you are supposed to run both checkpatches.sh and check-git-log.sh.
I am pretty sure I missed this second step in the past..

How about calling check-git-log.sh from checkpatches.sh ? check-git-log.sh does not support patch files as input, so it would need support for it.

Quoted 31 lines
Quoted 24 lines
Quoted 14 lines

---
Cc: Qi Zhang <[email protected]>

---
 devtools/check-git-log.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/check-git-log.sh +0 -0
index d39064f9d..f4d6c1fba 100755

devtools/check-git-log.sh bad=$(for fixtag in $fixtags ; do · line 181

Quoted 5 lines
devtools/check-git-log.sh +1 -0
@@ -177,6 +177,11 @@ bad=$(for fixtag in $fixtags ; do
 done | sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
 
+bad=$(for fixtag in $fixtags ; do
 

+ echo $fixtag | awk '{print $2}' | awk 'length != 12 {print}'

Quoted 1 line

+done)

Quoted 1 line
Quoted 6 lines

Not an awk expert (this could be done in pure shell, but this is a different story :-p), but I would see something like:

for fixtag in $fixtags; do
echo $fixtag | awk 'length($2) < 12 { print $2 }';
done

Quoted 7 lines

Yes, looks better, I will update the script.

And no specific preference on shell or awk implementation, there is no performance concern in this script and awk already used by it, I am good as long
as it is functional.

Well, I've seen Thomas reply, looks even better ;-).

Signature · 1 line
David Marchand
#4 lore raw
Quoted 38 lines · David Marchand
Quoted 26 lines · Ferruh Yigit
Quoted 1 line · David Marchand

On Tue, Jan 29, 2019 at 4:31 PM Ferruh Yigit <[email protected]>

Quoted 7 lines · wrote:
Quoted 6 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

Quoted 8 lines

Can't git decide to report a longer string in case of collisions of abbreviated id ?

Tried this for 2 characters, and git forcefully reported 5 chars:

$ git log -1 --abbrev=2 origin/master --format='Fixes: %h (\"%s\")'
Fixes: a2f9c (\"version: 19.02-rc4\")

I did not find any collisions with 12 characters abbreviated commitid,

but

Quoted 2 lines

I am not sure enforcing the check on exactly 12 characters is a good idea in the long run.

Yes git can report a longer string in case of collisions, but I don't expect to
have one with 12 characters.

Quoted 7 lines

This is mainly for some cases either people use full 40 chars or small ones.

Indeed in background I am (and most probably Thomas too) fixing them while merging, I thought it is better idea to integrate that into script so that developers can be aware of the syntax issue and fix it before sending.

I can understand you want to avoid such edits yes, and so this patch.

Quoted 8 lines

However, I think we can do one more thing.
The contributing guide does indicate you are supposed to run both checkpatches.sh and check-git-log.sh.
I am pretty sure I missed this second step in the past..

How about calling check-git-log.sh from checkpatches.sh ? check-git-log.sh does not support patch files as input, so it would need support for it.

That sounds good idea to have single script to run.

Quoted 45 lines
Quoted 34 lines
Quoted 27 lines
Quoted 17 lines

---
Cc: Qi Zhang <[email protected]>

---
 devtools/check-git-log.sh | 5 +++++
 1 file changed, 5 insertions(+)
devtools/check-git-log.sh +0 -0
index d39064f9d..f4d6c1fba 100755

devtools/check-git-log.sh bad=$(for fixtag in $fixtags ; do · line 181

Quoted 5 lines
devtools/check-git-log.sh +1 -0
@@ -177,6 +177,11 @@ bad=$(for fixtag in $fixtags ; do
 done | sed 's,^,\t,')
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
 
+bad=$(for fixtag in $fixtags ; do
 

+ echo $fixtag | awk '{print $2}' | awk 'length != 12 {print}'

Quoted 1 line

+done)

Quoted 1 line
Quoted 6 lines

Not an awk expert (this could be done in pure shell, but this is a different story :-p), but I would see something like:

for fixtag in $fixtags; do
echo $fixtag | awk 'length($2) < 12 { print $2 }';
done

Quoted 7 lines

Yes, looks better, I will update the script.

And no specific preference on shell or awk implementation, there is no performance concern in this script and awk already used by it, I am good as long
as it is functional.

Well, I've seen Thomas reply, looks even better ;-).

#5 lore raw
Quoted 44 lines · Ferruh Yigit
Quoted 43 lines · David Marchand
Quoted 26 lines · Ferruh Yigit
Quoted 1 line · David Marchand

On Tue, Jan 29, 2019 at 4:31 PM Ferruh Yigit <[email protected]>

Quoted 7 lines · wrote:
Quoted 6 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

Quoted 8 lines

Can't git decide to report a longer string in case of collisions of abbreviated id ?

Tried this for 2 characters, and git forcefully reported 5 chars:

$ git log -1 --abbrev=2 origin/master --format='Fixes: %h (\"%s\")'
Fixes: a2f9c (\"version: 19.02-rc4\")

I did not find any collisions with 12 characters abbreviated commitid,

but

Quoted 2 lines

I am not sure enforcing the check on exactly 12 characters is a good idea in the long run.

Yes git can report a longer string in case of collisions, but I don't expect to
have one with 12 characters.

Quoted 7 lines

This is mainly for some cases either people use full 40 chars or small ones.

Indeed in background I am (and most probably Thomas too) fixing them while merging, I thought it is better idea to integrate that into script so that developers can be aware of the syntax issue and fix it before sending.

I can understand you want to avoid such edits yes, and so this patch.

However, I think we can do one more thing.
The contributing guide does indicate you are supposed to run both checkpatches.sh and check-git-log.sh.
I am pretty sure I missed this second step in the past..

Quoted 6 lines
Quoted 3 lines

How about calling check-git-log.sh from checkpatches.sh ? check-git-log.sh does not support patch files as input, so it would need support for it.

That sounds good idea to have single script to run.

+1 to this

#6 lore raw
In reply to Ferruh Yigit

30/01/2019 12:17, Ferruh Yigit:

Quoted 10 lines · David Marchand
Quoted 7 lines

The contributing guide does indicate you are supposed to run both checkpatches.sh and check-git-log.sh.
I am pretty sure I missed this second step in the past..

How about calling check-git-log.sh from checkpatches.sh ? check-git-log.sh does not support patch files as input, so it would need support for it.

That sounds good idea to have single script to run.

It will never be only one script to run.
There are more scripts in devtools and I plan to add more. Some checks can be done only once for a group of commits, and will be really too slow if run for each patch when merging a branch.

About check-git-log, some tests cannot be possible outside of a git tree. Do you want to run it when checkpatches is run on git tree? Wouldn't it be confusing?

#7 lore raw
Quoted 12 lines · Thomas Monjalon

30/01/2019 12:17, Ferruh Yigit:

Quoted 10 lines · David Marchand
Quoted 7 lines

The contributing guide does indicate you are supposed to run both checkpatches.sh and check-git-log.sh.
I am pretty sure I missed this second step in the past..

How about calling check-git-log.sh from checkpatches.sh ? check-git-log.sh does not support patch files as input, so it would need support for it.

That sounds good idea to have single script to run.

Quoted 9 lines

It will never be only one script to run.
There are more scripts in devtools and I plan to add more. Some checks can be done only once for a group of commits, and will be really too slow if run for each patch when merging a branch.

About check-git-log, some tests cannot be possible outside of a git tree. Do you want to run it when checkpatches is run on git tree? Wouldn't it be confusing?

Possibly, but we can print out a warning when not run, saying "check-git-log skipped because we are not running on git tree". I think the benefit of having all checks done by one script is greater than the downside of a little confusion.

/Bruce

#8 lore raw

30/01/2019 12:31, Bruce Richardson:

Quoted 18 lines · Thomas Monjalon
Quoted 17 lines

30/01/2019 12:17, Ferruh Yigit:

Quoted 10 lines · David Marchand
Quoted 7 lines

The contributing guide does indicate you are supposed to run both checkpatches.sh and check-git-log.sh.
I am pretty sure I missed this second step in the past..

How about calling check-git-log.sh from checkpatches.sh ? check-git-log.sh does not support patch files as input, so it would need support for it.

That sounds good idea to have single script to run.

It will never be only one script to run.
There are more scripts in devtools and I plan to add more. Some checks can be done only once for a group of commits, and will be really too slow if run for each patch when merging a branch.

Quoted 8 lines
Quoted 4 lines

About check-git-log, some tests cannot be possible outside of a git tree. Do you want to run it when checkpatches is run on git tree? Wouldn't it be confusing?

Possibly, but we can print out a warning when not run, saying "check-git-log skipped because we are not running on git tree". I think the benefit of having all checks done by one script is greater than the downside of a little confusion.

OK

#9 lore raw
In reply to Ferruh Yigit

29/01/2019 16:30, Ferruh Yigit:

Quoted 4 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

This check was missing on purpose, in order to not be too strict. I think it's OK if the length of the SHA1 is not always the same.

Quoted 4 lines
devtools/check-git-log.sh +0 -0
@@ -177,6 +177,11 @@ bad=$(for fixtag in $fixtags ; do
 done | sed 's,^,\t,')

devtools/check-git-log.sh bad=$(for fixtag in $fixtags ; do · line 187

Quoted 10 lines
devtools/check-git-log.sh +5 -0
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
 
+bad=$(for fixtag in $fixtags ; do
+	echo $fixtag | awk '{print $2}' | awk 'length != 12 {print}'
+done)
+[ -z "$bad" ] || printf "Wrong 'Fixes' syntax:\n$bad\n"
+
 # check Cc: [email protected] for fixes
 bad=$(for fix in $stablefixes ; do
 	git log --format='%b' -1 $fix | grep -qi '^Cc: *[email protected]' ||

If you really want to be that strict, it can be done simpler:

bad=$(for fixtag in $fixtags ; do

        hash=$(echo "$fixtag" | sed 's,^Fixes: \([0-9a-f]*\).*,\1,')
        if git branch --contains $hash 2>&- | grep -q '^\*' ; then

- good="Fixes: $hash "$(git log --format='("%s")' -1 $hash 2>&-)
+ good=$(git log --abbrev=12 --format='Fixes: %h ("%s")' -1 $hash 2>&-)
else
good="reference not in current branch"
fi

#10 lore raw
Quoted 8 lines · Thomas Monjalon

29/01/2019 16:30, Ferruh Yigit:

Quoted 4 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

This check was missing on purpose, in order to not be too strict. I think it's OK if the length of the SHA1 is not always the same.

That is OK, if we don't want to be strict on this, I will update patch as rejected.

Quoted 29 lines
Quoted 5 lines
devtools/check-git-log.sh +0 -0
@@ -177,6 +177,11 @@ bad=$(for fixtag in $fixtags ; do
 done | sed 's,^,\t,')

devtools/check-git-log.sh bad=$(for fixtag in $fixtags ; do · line 187

Quoted 10 lines
devtools/check-git-log.sh +5 -0
 [ -z "$bad" ] || printf "Wrong 'Fixes' reference:\n$bad\n"
 
+bad=$(for fixtag in $fixtags ; do
+	echo $fixtag | awk '{print $2}' | awk 'length != 12 {print}'
+done)
+[ -z "$bad" ] || printf "Wrong 'Fixes' syntax:\n$bad\n"
+
 # check Cc: [email protected] for fixes
 bad=$(for fix in $stablefixes ; do
 	git log --format='%b' -1 $fix | grep -qi '^Cc: *[email protected]' ||

If you really want to be that strict, it can be done simpler:

bad=$(for fixtag in $fixtags ; do

        hash=$(echo "$fixtag" | sed 's,^Fixes: \([0-9a-f]*\).*,\1,')
        if git branch --contains $hash 2>&- | grep -q '^\*' ; then
(quoted diff) +1 -1
-               good="Fixes: $hash "$(git log --format='("%s")' -1 $hash 2>&-)
+               good=$(git log --abbrev=12 --format='Fixes: %h ("%s")' -1 $hash 2>&-)
        else
                good="reference not in current branch"
        fi
#11 lore raw
Quoted 5 lines · Ferruh Yigit
Quoted 4 lines · Thomas Monjalon

29/01/2019 16:30, Ferruh Yigit:

Quoted 3 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Check if the Fixes line commit id length matches the defined value.

This check was missing on purpose, in order to not be too strict. I think it's OK if the length of the SHA1 is not always the same.

That is OK, if we don't want to be strict on this, I will update patch as rejected.

I think having this check is still good. It's not enforcing the rule, just warning when violated. In 99% of cases this warning should be fixed IMHO, especially if you guys are fixing these manually anyway.

/Bruce

#12 lore raw

30/01/2019 12:29, Bruce Richardson:

Quoted 8 lines · Ferruh Yigit
Quoted 7 lines · Thomas Monjalon
Quoted 6 lines

29/01/2019 16:30, Ferruh Yigit:

Quoted 4 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

This check was missing on purpose, in order to not be too strict. I think it's OK if the length of the SHA1 is not always the same.

That is OK, if we don't want to be strict on this, I will update patch as rejected.

I think having this check is still good. It's not enforcing the rule, just warning when violated. In 99% of cases this warning should be fixed IMHO, especially if you guys are fixing these manually anyway.

I don't fix it manually. I think SHA1 length has no importance. Why do you think it should be fixed?

#13 lore raw
Quoted 12 lines · Thomas Monjalon

30/01/2019 12:29, Bruce Richardson:

Quoted 11 lines · Ferruh Yigit
Quoted 10 lines · Thomas Monjalon
Quoted 8 lines

29/01/2019 16:30, Ferruh Yigit:

Quoted 4 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Check if the Fixes line commit id length matches the defined value.

This check was missing on purpose, in order to not be too strict. I think it's OK if the length of the SHA1 is not always the same.

Quoted 9 lines
Quoted 5 lines
Quoted 2 lines

That is OK, if we don't want to be strict on this, I will update patch as rejected.

I think having this check is still good. It's not enforcing the rule, just warning when violated. In 99% of cases this warning should be fixed IMHO, especially if you guys are fixing these manually anyway.

I don't fix it manually. I think SHA1 length has no importance. Why do you think it should be fixed?

Neatness and consistency. Since we provide on the site the expected syntax for the fixes line, why not check for its use?

/Bruce

#14 lore raw

30/01/2019 12:35, Bruce Richardson:

Quoted 19 lines · Thomas Monjalon
Quoted 18 lines

30/01/2019 12:29, Bruce Richardson:

Quoted 16 lines · Ferruh Yigit
Quoted 5 lines · Thomas Monjalon
Quoted 4 lines

29/01/2019 16:30, Ferruh Yigit:

Quoted 3 lines

Fixes line commit id length defined as 12 in fixline alias:
fixline = log -1 --abbrev=12 --format='Fixes: %h (\"%s\")%nCc: %ae'

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Check if the Fixes line commit id length matches the defined value.

This check was missing on purpose, in order to not be too strict. I think it's OK if the length of the SHA1 is not always the same.

That is OK, if we don't want to be strict on this, I will update patch as rejected.

I think having this check is still good. It's not enforcing the rule, just warning when violated. In 99% of cases this warning should be fixed IMHO, especially if you guys are fixing these manually anyway.

Quoted 5 lines
Quoted 3 lines

I don't fix it manually. I think SHA1 length has no importance. Why do you think it should be fixed?

Neatness and consistency. Since we provide on the site the expected syntax for the fixes line, why not check for its use?

OK, I'm not against the check.