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

From:
"Sven M. Hallberg" <pesco@khjk.org>
Subject:
Re: [patch] preserve and show author dates
To:
gameoftrees@openbsd.org
Date:
Wed, 07 Aug 2024 09:57:39 +0200

Download raw body.

Thread
  • Sven M. Hallberg:

    [patch] preserve and show author dates

  • And here's the test, patterned after test_rebase_preserves_logmsg,
    plus one that checks the order of the "from:", "via:", "date:", and
    "orig:" headers in the output of got log (after my earlier mistake).
    
    As individual commits (on top of the others) at:
    https://gotweb.khjk.org/?action=summary&headref=authortime-test&path=got.git
    
    -p
    
    PS: I used "orig:" for the author time header because I could not think
    of something bettat that would still line up with the "date" above it,
    and having the two dates not line up seemed egregious.
    
    
    diff /home/pesco/work/got
    commit - 9a2e7ad4870891a7244450ed93be14d82bbd104b
    path + /home/pesco/work/got
    blob - aa8c37ce5f9af6c3b3fdf320c95dd8316334d667
    file + regress/cmdline/rebase.sh
    --- regress/cmdline/rebase.sh
    +++ regress/cmdline/rebase.sh
    @@ -1002,6 +1002,115 @@ test_rebase_preserves_logmsg() {
     	test_done "$testroot" "$ret"
     }
     
    +test_rebase_preserves_author_time() {
    +	local testroot=`test_init rebase_preserves_author_time`
    +
    +	git -C $testroot/repo checkout -q -b newbranch
    +	echo "modified delta on branch" > $testroot/repo/gamma/delta
    +	git_commit $testroot/repo -m "modified delta on newbranch"
    +
    +	sleep 1		# get a new timestamp
    +	echo "modified alpha on branch" > $testroot/repo/alpha
    +	git_commit $testroot/repo -m "modified alpha on newbranch"
    +
    +	(cd $testroot/repo && got log -c newbranch -l2 | \
    +		egrep '^(commit|date:)' > $testroot/dates.expected)
    +
    +	local orig_commit1=`git_show_parent_commit $testroot/repo`
    +	local orig_commit2=`git_show_head $testroot/repo`
    +
    +	git -C $testroot/repo checkout -q master
    +	echo "modified zeta on master" > $testroot/repo/epsilon/zeta
    +	git_commit $testroot/repo -m "committing to zeta on master"
    +	local master_commit=`git_show_head $testroot/repo`
    +
    +	got checkout $testroot/repo $testroot/wt > /dev/null
    +	ret=$?
    +	if [ $ret -ne 0 ]; then
    +		test_done "$testroot" "$ret"
    +		return 1
    +	fi
    +
    +	sleep 1		# get a new timestamp
    +	(cd $testroot/wt && got rebase newbranch > /dev/null \
    +		2> $testroot/stderr)
    +
    +	git -C $testroot/repo checkout -q newbranch
    +	local new_commit1=`git_show_parent_commit $testroot/repo`
    n+	local new_commit2=`git_show_head $testroot/repo`
    +
    +	echo -n > $testroot/stderr.expected
    +	cmp -s $testroot/stderr.expected $testroot/stderr
    +	ret=$?
    +	if [ $ret -ne 0 ]; then
    +		diff -u $testroot/stderr.expected $testroot/stderr
    +		test_done "$testroot" "$ret"
    +		return 1
    +	fi
    +
    +	(cd $testroot/wt && got log -c newbranch -l2 | \
    +		egrep '^(commit|orig:)' > $testroot/dates)
    +	ed -s $testroot/dates.expected <<-EOF
    +	,s/$orig_commit1/$new_commit1/
    +	,s/$orig_commit2/$new_commit2/
    +	,s/^date:/orig:/
    +	w
    +	EOF
    +	cmp -s $testroot/dates.expected $testroot/dates
    +	ret=$?
    +	if [ $ret -ne 0 ]; then
    +		diff -u $testroot/dates.expected $testroot/dates
    +	fi
    +
    +	test_done "$testroot" "$ret"
    +}
    +
    +test_rebase_header_order() {
    +	local testroot=`test_init rebase_header_order`
    +	local committer="Flan Luck <flan_luck@openbsd.org>"
    +
    +	git -C $testroot/repo checkout -q -b newbranch
    +	echo "modified delta on branch" > $testroot/repo/gamma/delta
    +	git_commit $testroot/repo -m "modified delta on newbranch"
    +
    +	git -C $testroot/repo checkout -q master
    +	echo "modified zeta on master" > $testroot/repo/epsilon/zeta
    +	git_commit $testroot/repo -m "committing to zeta on master"
    +	local master_commit=`git_show_head $testroot/repo`
    +
    +	got checkout $testroot/repo $testroot/wt > /dev/null
    +	ret=$?
    +	if [ $ret -ne 0 ]; then
    +		test_done "$testroot" "$ret"
    +		return 1
    +	fi
    +
    +	sleep 1		# get a new timestamp
    +	(cd $testroot/wt && env GOT_AUTHOR="$committer" got rebase newbranch \
    +		> /dev/null 2> $testroot/stderr)
    +
    +	echo -n > $testroot/stderr.expected
    +	cmp -s $testroot/stderr.expected $testroot/stderr
    +	ret=$?
    +	if [ $ret -ne 0 ]; then
    +		diff -u $testroot/stderr.expected $testroot/stderr
    +		test_done "$testroot" "$ret"
    +		return 1
    +	fi
    +
    +	echo "from:\nvia:\ndate:\norig:" > $testroot/headers.expected
    +	(cd $testroot/wt && got log -c newbranch -l1 | \
    +		egrep '^(from:|via:|date:|orig:)' | sed -e 's/: .*/:/' \
    +		> $testroot/headers)
    +	cmp -s $testroot/headers.expected $testroot/headers
    +	ret=$?
    +	if [ $ret -ne 0 ]; then
    +		diff -u $testroot/headers.expected $testroot/headers
    +	fi
    +
    +	test_done "$testroot" "$ret"
    +}
    +
     test_rebase_no_commits_to_rebase() {
     	local testroot=`test_init rebase_no_commits_to_rebase`
     
    @@ -2286,6 +2395,8 @@ run_test test_rebase_no_op_change
     run_test test_rebase_in_progress
     run_test test_rebase_path_prefix
     run_test test_rebase_preserves_logmsg
    +run_test test_rebase_preserves_author_time
    +run_test test_rebase_header_order
     run_test test_rebase_no_commits_to_rebase
     run_test test_rebase_forward
     run_test test_rebase_forward_path_prefix
    
    
  • Sven M. Hallberg:

    [patch] preserve and show author dates