Download raw body.
always fetch remote HEAD except when -b is used
On Sat, Feb 18, 2023 at 07:22:47PM +1100, Mark Jamsek wrote: > On 23-02-17 01:35PM, Stefan Sperling wrote: > > On Fri, Feb 17, 2023 at 02:59:44AM +1100, Mark Jamsek wrote: > > > Actual diff implementing stsp's fetch suggestion: > > > > This seems fine to me. Thanks! > > We will continue fine-tuning in time I suppose ;) > > Yes, I think so too :) > > Below diff updates regress to account for the fetch changes: Nice, thanks! Ok. I suspect we'll be happy with this behaviour. > diffstat /home/mark/src/got > M regress/cmdline/fetch.sh | 34+ 16- > > 1 file changed, 34 insertions(+), 16 deletions(-) > > diff /home/mark/src/got > commit - 118a625d39930284f891ea1285efc17fb3848cae > path + /home/mark/src/got > blob - 8062d38d224c6522d74df4b1b340812e982c72b3 > file + regress/cmdline/fetch.sh > --- regress/cmdline/fetch.sh > +++ regress/cmdline/fetch.sh > @@ -188,8 +188,8 @@ test_fetch_branch() { > git_commit $testroot/repo -m "modified alpha" > local commit_id3=`git_show_head $testroot/repo` > > - # foo is now the default HEAD branch in $testroot/repo > - # but got.conf still says to fetch "master" > + # foo is now the default HEAD branch in $testroot/repo and should be > + # fetched as the clone's remote HEAD symref target no longer matches > got fetch -q -r $testroot/repo-clone > $testroot/stdout > ret=$? > if [ $ret -ne 0 ]; then > @@ -211,9 +211,12 @@ test_fetch_branch() { > got ref -l -r $testroot/repo-clone > $testroot/stdout > > echo "HEAD: refs/heads/master" > $testroot/stdout.expected > + echo "refs/heads/foo: $commit_id3" >> $testroot/stdout.expected > echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected > - echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \ > + echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \ > >> $testroot/stdout.expected > + echo "refs/remotes/origin/foo: $commit_id3" \ > + >> $testroot/stdout.expected > echo "refs/remotes/origin/master: $commit_id2" \ > >> $testroot/stdout.expected > # refs/hoo/boo/zoo is missing because it is outside of refs/heads > @@ -1113,9 +1116,12 @@ test_fetch_update_headref() { > got ref -l -r $testroot/repo-clone > $testroot/stdout > > echo "HEAD: refs/heads/master" > $testroot/stdout.expected > + echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected > echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected > - echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \ > + echo "refs/remotes/origin/HEAD: refs/remotes/origin/foo" \ > >> $testroot/stdout.expected > + echo "refs/remotes/origin/foo: $commit_id" \ > + >> $testroot/stdout.expected > echo "refs/remotes/origin/master: $commit_id" \ > >> $testroot/stdout.expected > > @@ -1497,10 +1503,21 @@ test_fetch_honor_wt_conf_bflag() { > fi > > (cd $testroot/repo && git checkout -q boo) > - # from repo: fetch got.conf branch not repo HEAD > - # boo is the default HEAD in $testroot/repo, which is not up-to-date > - # on the clone, but we fetch got.conf "master" which is up-to-date > - got fetch -r $testroot/repo-clone > $testroot/stdout > + # clone has remote/origin/HEAD symref with "master" as its target > + # but the repo has changed HEAD to "boo", so we should fetch "boo" > + echo "HEAD: refs/heads/master" > $testroot/stdout.expected > + echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected > + echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected > + echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected > + echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected > + echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \ > + >> $testroot/stdout.expected > + echo "refs/remotes/origin/boo: $commit_id2" \ > + >> $testroot/stdout.expected > + echo "refs/remotes/origin/master: $commit_id" \ > + >> $testroot/stdout.expected > + > + got fetch -q -r $testroot/repo-clone > $testroot/stdout > ret=$? > if [ $ret -ne 0 ]; then > echo "got fetch command failed unexpectedly" >&2 > @@ -1508,9 +1525,7 @@ test_fetch_honor_wt_conf_bflag() { > return 1 > fi > > - echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \ > - > $testroot/stdout.expected > - echo "Already up-to-date" >> $testroot/stdout.expected > + got ref -l -r $testroot/repo-clone > $testroot/stdout > > cmp -s $testroot/stdout $testroot/stdout.expected > ret=$? > @@ -1520,7 +1535,7 @@ test_fetch_honor_wt_conf_bflag() { > return 1 > fi > > - # from repo: fetch -b hoo not got.conf branch or repo HEAD > + # from repo: fetch -b hoo > got fetch -q -r $testroot/repo-clone -b hoo > $testroot/stdout > ret=$? > if [ $ret -ne 0 ]; then > @@ -1543,11 +1558,14 @@ test_fetch_honor_wt_conf_bflag() { > > echo "HEAD: refs/heads/master" > $testroot/stdout.expected > echo "refs/heads/bar: $commit_id" >> $testroot/stdout.expected > + echo "refs/heads/boo: $commit_id2" >> $testroot/stdout.expected > echo "refs/heads/foo: $commit_id" >> $testroot/stdout.expected > echo "refs/heads/hoo: $commit_id3" >> $testroot/stdout.expected > echo "refs/heads/master: $commit_id" >> $testroot/stdout.expected > - echo "refs/remotes/origin/HEAD: refs/remotes/origin/master" \ > + echo "refs/remotes/origin/HEAD: refs/remotes/origin/boo" \ > >> $testroot/stdout.expected > + echo "refs/remotes/origin/boo: $commit_id2" \ > + >> $testroot/stdout.expected > echo "refs/remotes/origin/hoo: $commit_id3" \ > >> $testroot/stdout.expected > echo "refs/remotes/origin/master: $commit_id" \ > @@ -1688,8 +1706,8 @@ test_fetch_honor_wt_conf_bflag() { > return 1 > fi > > - # from wt: fetch got.conf "master" and wt "boo", not repo HEAD "hoo" > - # change default branch in got.conf from "foo" to "master" > + # from wt: fetch got.conf "master", wt "boo", and the repo's new HEAD > + # "hoo" as it no longer matches our remote HEAD symref target "master" > sed -i "s/foo/master/" $testroot/repo-clone/got.conf > echo "modified delta on master" > $testroot/repo/gamma/delta > git_commit $testroot/repo -m "modified delta on master" > @@ -1731,7 +1749,7 @@ test_fetch_honor_wt_conf_bflag() { > >> $testroot/stdout.expected > echo "refs/remotes/origin/boo: $commit_id6" \ > >> $testroot/stdout.expected > - echo "refs/remotes/origin/hoo: $commit_id3" \ > + echo "refs/remotes/origin/hoo: $commit_id7" \ > >> $testroot/stdout.expected > echo "refs/remotes/origin/master: $commit_id5" \ > >> $testroot/stdout.expected > > -- > Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org> > GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68 >
always fetch remote HEAD except when -b is used