Re: linux-next: Fixes tag needs some work in the block tree

From: Jan Kara
Date: Tue Jan 26 2021 - 11:06:16 EST


On Tue 26-01-21 08:47:55, Jens Axboe wrote:
> On 1/26/21 6:29 AM, Jan Kara wrote:
> > On Mon 25-01-21 11:39:50, Jens Axboe wrote:
> >> On 1/25/21 11:35 AM, Paolo Valente wrote:
> >>>
> >>>
> >>>> Il giorno 25 gen 2021, alle ore 10:40, Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx> ha scritto:
> >>>>
> >>>> Hi all,
> >>>>
> >>>> In commit
> >>>>
> >>>> d4fc3640ff36 ("block, bfq: set next_rq to waker_bfqq->next_rq in waker injection")
> >>>>
> >>>> Fixes tag
> >>>>
> >>>> Fixes: c5089591c3ba ("block, bfq: detect wakers and unconditionally inject their I/O")
> >>>>
> >>>> has these problem(s):
> >>>>
> >>>> - Target SHA1 does not exist
> >>>>
> >>>> Maybe you meant
> >>>>
> >>>> Fixes: 13a857a4c4e8 ("block, bfq: detect wakers and unconditionally inject their I/O")
> >>>>
> >>>
> >>> Hi Jens,
> >>> how to proceed in such a case (with patches already applied by you)?
> >>> Shall I send you a v2 with only this change?
> >>
> >> We just have to ignore it... But in the future, always double check that
> >> you are using the right shas, not some sha from an internal tree.
> >
> > FWIW I have a commit hook in my git tree that just refuses a commit with
> > unknown Fixes tag SHA. Exactly to catch such mishaps in the patches I
> > merge...
>
> That's not a bad idea, would help catch it upfront. Can you share the
> hook?

Sure, attached. Note that the hook just gets commit ID from the Fixes tag
and formats it with 12 commit ID digits and appropriate commit subject.

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR
#!/bin/sh
#
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.

# Process all Fixes tags, check commit IDs and set appropriate commit titles.

for COMMIT in $(sed -n -e 's/^Fixes: \([0-9a-z]*\).*/\1/p' "$1"); do
GOOD=$(git show -s --abbrev-commit --abbrev=12 --pretty=format:"%h (\"%s\")%n" $COMMIT -- 2>/dev/null)
if [ -z "$GOOD" ]; then
echo "Unknown commit: $COMMIT"
exit 1
fi
echo "Setting fixes tag: $GOOD"
sed -i -e "s/^Fixes: $COMMIT.*/Fixes: $GOOD/" "$1"
done

exit 0