From: Junio C Hamano Date: Sun, 28 Dec 2025 11:46:33 GMT Subject: Re: [PATCH v8] status: show comparison with configured goal branch Message-ID: In-Reply-To: "Harald Nordgren via GitGitGadget" writes: > +test_expect_success 'status shows ahead of both tracked branch and origin/main' ' > + ( > + cd test && > + git checkout work >/dev/null && What is this redirecction for? > + git config status.goalBranch origin/main && > + git status --long -b > + ) >actual && Instead of redirecting the whole thing, if you are grabbing the output from "git status", do it more like this, probably: ( cd test && ... && git status --long --branch >../actual ) > + cat >expect <<-\EOF && Looking up what "<<-\EOF" means, it makes little sense to have these lines ... > +On branch work > +Your branch is ahead of '\''origin/feature'\'' by 2 commits. > + (use "git push" to publish your local commits) > + > +Ahead of '\''origin/main'\'' by 3 commits. > + > +nothing to commit, working tree clean > +EOF ... abut the left edge of the page. Unlike <<\EOF, the dash sign tells the shell that it should remove the leading tab from the line before feeding "cat", and the point of using that construct "<<-\EOF" to begin with is so that you can indent the here doc to the same level as the command text. IOW, you use "<<-\EOF" only because you want to avoid these ugly lines that are sticking to the left, like the above. Instead you can do this: cat >expect <<-\EOF && On branch work Your branch is ... (use "git push" ... ... EOF and the shell strips the leading tabs from these lines. > + test_cmp expect actual > +' > +test_expect_success 'checkout shows ahead of both tracked branch and origin/main' ' > + ( > + cd test && > + git checkout main >/dev/null && > + git config status.goalBranch origin/main && > + git checkout work 2>&1 Likewise. > + ) >actual && > + cat >expect <<-\EOF && > +Switched to branch '\''work'\'' > +Your branch is ahead of '\''origin/feature'\'' by 2 commits. > + (use "git push" to publish your local commits) > + > +Ahead of '\''origin/main'\'' by 3 commits. > +EOF Likewise. Also, doesn't $SQ work here, i.e. cat >expect <<-EOF && Switched to branch ${SQ}work${SQ} Your branch is ahead of ${SQ}...${SQ} by 2 commits. ... EOF As you want interpolation if you go this route, we lose quote from the end of here-doc token and write "<<-EOF" here, instead of "<<-\EOF". > + test_cmp expect actual > +' > + > +test_expect_success 'status tracking origin/main shows only main' ' > + ( > + cd test && > + git checkout b4 >/dev/null && > + git status --long -b Likewise. > + ) >actual && > + test_grep "ahead of .origin/main. by 2 commits" actual && > + test_grep ! "Ahead of" actual > +' I'll stop here.