Skip to content

Commit

Permalink
git-helper: fix bad clearing of lines
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Aug 23, 2023
1 parent ed3584f commit 9b89343
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions commands/git-helper
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ function git_helper() (

function git_update {
# verify path, assumed verified for other actions
local body=''
body="$(mktemp)"
if ! git remote &>"$body"; then
local BODY=''
BODY="$(mktemp)"
if ! git remote &>"$BODY"; then
echo-error "$0: No git repository at $path"
return 1
elif test -z "$(cat "$body")"; then
elif test -z "$(cat "$BODY")"; then
echo-error "$0: No git remotes found at $path"
return 1
fi
Expand All @@ -504,18 +504,18 @@ function git_helper() (
function do_update {
git_protocol_update "$remote"
git config pull.ff only
git pull "$remote" "$(git_default_branch)"
git pull "$remote" "$(git_default_branch)" | tee "$BODY"
}

# write to body so that already updated can be detected
# write to BODY so that already updated can be detected
# write to stderr so that [git_update] returns only [failure|current|updated]
local update_status
eval_capture --statusvar=update_status --outputvar=body --outputpipe=/dev/stderr -- do_update
eval_capture --statusvar=update_status --outputpipe=/dev/stderr -- do_update
if test "$update_status" -ne 0; then
# update failed
print_line 'failure'
return 1
elif grep --quiet --fixed-strings --regexp='Already' <"$body"; then
elif grep --quiet --fixed-strings --regexp='Already' <"$BODY"; then
# already up to date
print_line 'current'
else
Expand Down

0 comments on commit 9b89343

Please sign in to comment.