Re: [PATCH 1/4] rebase -i: demonstrate obscure loose object cache bug
To
Johannes Schindelin via GitGitGadget
Cc
git@vger.kernel.org
Jeff King
Johannes Schindelin
From
Junio C Hamano
See Also
Prev Ref 1
Date
2019-03-14 01:12:08 UTC
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:

> +test_expect_failure SHA1 'loose object cache vs re-reading todo list' '
> +	GIT_REBASE_TODO=.git/rebase-merge/git-rebase-todo &&
> +	export GIT_REBASE_TODO &&
> +	write_script append-todo.sh <<-\EOS &&
> +	# For values 5 and 6, this yields SHA-1s with the same first two digits
> +	echo "pick $(git rev-parse --short \
> +		$(printf "%s\\n" \
> +			"tree $EMPTY_TREE" \
> +			"author A U Thor <author@example.org> $1 +0000" \
> +			"committer A U Thor <author@example.org> $1 +0000" \
> +			"" \
> +			"$1" |
> +		  git hash-object -t commit -w --stdin))" >>$GIT_REBASE_TODO

In the generated append-todo.sh, as the <<EOS above is quoted, we
will see ">>$GIT_REBASE_TODO" literally (not the actual pathname
that begins with .git, but a reference to the variable).  test-lint
may or may not catch it, but redirecting into variable reference
would trigger a(n arguably misguided) warning when run with some
versions of bash.  Quoting

		echo ... >>"$GIT_REBASE_TODO"

would work it around, of course.

> +	shift
> +	test -z "$*" ||
> +	echo "exec $0 $*" >>$GIT_REBASE_TODO

Likewise.

> +	EOS
> +
> +	git rebase HEAD -x "./append-todo.sh 5 6"
> +'
> +
>  test_done