commit f72ce919dd6d6c15679c5174c47912ac55be1e18 from: Stefan Sperling via: Mark Jamsek date: Mon Feb 13 13:43:46 2023 UTC make 'got fetch -b branch' error reporting more helpful The patch to got-fetch-pack.c was written by stsp with only minor tweaks by me. Regress updated to account for the change in reporting. stsp's original got-fetch-pack.c diff ok op jamsek ok stsp@ commit - 1cb79834eab33d1c1c01731b4800bab440032f20 commit + f72ce919dd6d6c15679c5174c47912ac55be1e18 blob - c8d35d7046be5e229cbdc28ec23f311320cfef70 blob + 2a22df95ff37a15b31f41c7c01f263af824ddc15 --- libexec/got-fetch-pack/got-fetch-pack.c +++ libexec/got-fetch-pack/got-fetch-pack.c @@ -513,6 +513,25 @@ fetch_pack(int fd, int packfd, uint8_t *pack_sha1, /* Abort if we haven't found anything to fetch. */ if (nref == 0) { + struct got_pathlist_entry *pe; + static char msg[PATH_MAX + 33]; + + pe = TAILQ_FIRST(wanted_branches); + if (pe) { + snprintf(msg, sizeof(msg), + "branch \"%s\" not found on server", pe->path); + err = got_error_msg(GOT_ERR_FETCH_NO_BRANCH, msg); + goto done; + } + + pe = TAILQ_FIRST(wanted_refs); + if (pe) { + snprintf(msg, sizeof(msg), + "reference \"%s\" not found on server", pe->path); + err = got_error_msg(GOT_ERR_FETCH_NO_BRANCH, msg); + goto done; + } + err = got_error(GOT_ERR_FETCH_NO_BRANCH); goto done; } blob - 32900e895fc896beef177d3ad156f591d1f1ffb8 blob + b5089c370c1eb445b14ae243faad7fb9fefbb907 --- regress/cmdline/fetch.sh +++ regress/cmdline/fetch.sh @@ -1568,7 +1568,7 @@ test_fetch_honor_wt_conf_bflag() { echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \ > $testroot/stdout.expected - echo "got-fetch-pack: could not find any branches to fetch" \ + echo "got-fetch-pack: branch \"foo\" not found on server" \ > $testroot/stderr.expected echo "got: could not find any branches to fetch" \ >> $testroot/stderr.expected @@ -1797,7 +1797,7 @@ test_fetch_honor_wt_conf_bflag() { echo "Connecting to \"origin\" ssh://127.0.0.1$testroot/repo" \ > $testroot/stdout.expected - echo "got-fetch-pack: could not find any branches to fetch" \ + echo "got-fetch-pack: branch \"bar\" not found on server" \ > $testroot/stderr.expected echo "got: could not find any branches to fetch" \ >> $testroot/stderr.expected