"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: regress/cmdline/histedit.sh: fix assumption
To:
Lucas <lucas@sexy.is>
Cc:
gameoftrees@openbsd.org
Date:
Tue, 21 Sep 2021 22:28:41 +0200

Download raw body.

Thread
On Tue, Sep 21, 2021 at 08:10:32PM +0000, Lucas wrote:
> Stefan Sperling <stsp@stsp.name> wrote:
> > I don't think we should disable the entire histedit -l check.
> > 
> > What we should do is only expect the part that says "history forked at"
> > when the commits hashes do not happen to match.
> > But the rest of the output should still be verified.
> > 
> > So could we not create an appropriate stdout.expected file that matches
> > the expected result in either case?
> 
> Makes a lot of sense and feels and look cleaner. This is also more
> reliable; previous patch didn't account for when the first histedited
> commit is the same but not the second.

Thanks, applied!
 
> diff 3da8ef855d7d7b3da96a9f1cba55df276e112f11 /home/lucas/code/git/git.gameoftrees.org/got
> blob - 8c612fafa7e7fd1f96dfce1527ee0b2f621e0f8c
> file + regress/cmdline/histedit.sh
> --- regress/cmdline/histedit.sh
> +++ regress/cmdline/histedit.sh
> @@ -28,6 +28,7 @@ test_histedit_no_op() {
>  	(cd $testroot/repo && git add epsilon/new)
>  	git_commit $testroot/repo -m "committing changes"
>  	local old_commit1=`git_show_head $testroot/repo`
> +	local old_author_time1=`git_show_author_time $testroot/repo`
>  
>  	echo "modified zeta on master" > $testroot/repo/epsilon/zeta
>  	git_commit $testroot/repo -m "committing to zeta on master"
> @@ -152,6 +153,7 @@ test_histedit_no_op() {
>  
>  	# We should have a backup of old commits
>  	(cd $testroot/repo && got histedit -l > $testroot/stdout)
> +	d_orig1=`date -u -r $old_author_time1 +"%G-%m-%d"`
>  	d_orig2=`date -u -r $old_author_time2 +"%a %b %e %X %Y UTC"`
>  	d_new2=`date -u -r $new_author_time2 +"%G-%m-%d"`
>  	d_orig=`date -u -r $orig_author_time +"%G-%m-%d"`
> @@ -165,9 +167,29 @@ date: $d_orig2
>   
>  has become commit $new_commit2 (master)
>   $d_new2 $GOT_AUTHOR_11  committing to zeta on master
> -history forked at $orig_commit
> - $d_orig $GOT_AUTHOR_11  adding the test tree
>  EOF
> +
> +	local is_forked=true d_fork fork_commit fork_commit_msg
> +
> +	if [ "$old_commit1" = "$new_commit1" ]; then
> +		if [ "$old_commit2" = "$new_commit2" ]; then
> +			is_forked=false
> +		else
> +			d_fork=$d_orig1
> +			fork_commit=$new_commit1
> +			fork_commit_msg="committing changes"
> +		fi
> +	else
> +		d_fork=$d_orig
> +		fork_commit=$orig_commit
> +		fork_commit_msg="adding the test tree"
> +	fi
> +
> +	$is_forked && cat >> $testroot/stdout.expected <<EOF
> +history forked at $fork_commit
> + $d_fork $GOT_AUTHOR_11  $fork_commit_msg
> +EOF
> +
>  	cmp -s $testroot/stdout.expected $testroot/stdout
>  	ret="$?"
>  	if [ "$ret" != "0" ]; then
> 
>