torbiak/git-autofixup

Use of uninitialized value $sha

Closed this issue · 5 comments

Usually, git-autofixup works quite nicely. Today, I face this problem:

$ git autofixup -vv 11236e97ee
Use of uninitialized value $sha in hash element at /usr/local/bin/git-autofixup line 198.

Only one file is modified and the changes are minimal.

In the modified file, a hunk was supposed to go in one former commit whereas another hunk was supposed to go in another one. Because git-autofixup didn't work, I manually staged and fixed up the first hunk. Then, I could use git-autofixup for the last hunk.

It seems there's a issue mapping hunk lines from the diff to lines in the git blame output, but I'm having trouble imagining why. If you can give any more information about these it'd be helpful. diff and git blame --porcelain output would be helpful even if you have to redact the changes themselves.

I ran into this too. Here's the minimal case I could use to reproduce it:

set -e

git autofixup --version
# 0.002006

tmpdir=$(mktemp -d --suffix=.autofix)
git init $tmpdir && cd $tmpdir

git commit --allow-empty -m'root' && git tag root

printf 'line abc\n' >foo && git add foo && git commit -m'abc'
for i in $(seq 1 7); do
    printf "%d\n" $i >>foo
done
git add foo && git commit -m'filler'

printf 'line def\n' >>foo && git add foo && git commit -m'def'

sed -i 's/line/ln/g' foo
git autofixup root
# Use of uninitialized value $sha in hash element at /home/kyle/.local/bin/git-autofixup line 198.

Thank you, @torbiak!

@kyleam Sorry for the delay, and thanks for the script to reproduce the issue!