From: Junio C Hamano Date: Thu, 24 Oct 2013 21:26:39 GMT Subject: Re: [PATCH 2/2] merge-base: "--reflog" mode finds fork point from reflog entries Message-ID: In-Reply-To: Eric Sunshine writes: > On Thu, Oct 24, 2013 at 3:11 PM, Junio C Hamano wrote: >> diff --git a/t/t6010-merge-base.sh b/t/t6010-merge-base.sh >> index f80bba8..3a1abee 100755 >> --- a/t/t6010-merge-base.sh >> +++ b/t/t6010-merge-base.sh >> @@ -230,4 +230,31 @@ test_expect_success 'criss-cross merge-base for octopus-step' ' >> test_cmp expected.sorted actual.sorted >> ' >> >> +test_expect_success 'using reflog to find the fork point' ' >> + git reset --hard && >> + git checkout -b base $E && >> + ( >> + for count in 1 2 3 4 5 >> + do >> + git commit --allow-empty -m "Base commit #$count" && >> + git rev-parse HEAD >expect$count && >> + git checkout -B derived && >> + git commit --allow-empty -m "Derived #$count" && >> + git rev-parse HEAD >derived$count && >> + git checkout base && >> + count=$(( $count + 1 )) || exit 1 >> + done > > Did you want && here? No, I did not. Can't you tell from the fact that I didn't put one there ;-)? It does not hurt to have one there, but it is not necessary. Because the loop itself does not &&-cascade from anything else, the only case anything after "done &&" would be skipped and making the whole thing fail would be when anything inside the loop fails, but we already "exit 1" to terminate the whole subprocess in that case, so we will not continue past the loop. >> + >> + for count in 1 2 3 4 5 >> + do >> + git merge-base --reflog base $(cat derived$count) >actual && >> + test_cmp expect$count actual || exit 1 >> + done > > And here? Likewise. Thanks. >> + >> + # check defaulting to HEAD >> + git merge-base --reflog base >actual && >> + test_cmp expect5 actual >> + ) >> +' >> + >> test_done