git-rebase 的返回码 1 是什么?它还可以返回哪些其他值?

git-rebase 的返回码 1 是什么?它还可以返回哪些其他值?

我有一个脚本,它可以从 master 获取更改并将它们应用到所有分支。该脚本对我们来说效果很好,因为我们标记了我们的版本并使用了开发分支。我们不会为每个版本维护单独的分支。

git-rebase最近开始失败,返回码为 1。调试时的情况如下:

$ bash -x ./master-merge.sh 
++ git rev-parse HEAD
+ [[ -z 66dc925f94c15f92d0a2f16a03d8776df33e9144 ]]
+ ret_code=0
++ git rev-parse --abbrev-ref HEAD
+ current=master
+ git fetch --all
+ [[ 0 -eq 0 ]]
++ git branch -vv
++ grep -v ': gone]'
++ awk '{print $1}'
+ for branch in '$(git branch -vv | grep -v ": gone]" | awk '\''{print $1}'\'')'
+ '[' -e detsig ']'
+ echo 'Merging detsig'
Merging detsig
+ git checkout detsig
+ [[ 0 -ne 0 ]]
+ git rebase origin/detsig
+ [[ 1 -ne 0 ]]
+ echo 'Rebase failed for detsig'
Rebase failed for detsig
+ ret_code=1
+ continue
+ for branch in '$(git branch -vv | grep -v ": gone]" | awk '\''{print $1}'\'')'
+ '[' -e ecies ']'
+ echo 'Merging ecies'
Merging ecies
+ git checkout ecies
+ [[ 0 -ne 0 ]]
+ git rebase origin/ecies
+ [[ 1 -ne 0 ]]
+ echo 'Rebase failed for ecies'
Rebase failed for ecies
+ ret_code=1
+ continue
+ for branch in '$(git branch -vv | grep -v ": gone]" | awk '\''{print $1}'\'')'
+ '[' -e hmqv ']'
+ echo 'Merging hmqv'
Merging hmqv
+ git checkout hmqv
+ [[ 0 -ne 0 ]]
+ git rebase origin/hmqv
+ [[ 1 -ne 0 ]]
+ echo 'Rebase failed for hmqv'
Rebase failed for hmqv
+ ret_code=1
+ continue

git-rebase手册页不讨论返回码,所以我不确定它是什么意思。我也不确定该命令可以返回的其他值。

git-rebase返回码 1是什么意思?是否git-rebase有“硬故障”和“软故障”返回代码,以便我应该放松测试0


$ git --version
git version 1.8.5.2 (Apple Git-48)

$ cat master-merge.sh 
#!/usr/bin/env bash

# make sure this is a Git directory
if [[ (-z $(git rev-parse HEAD 2>/dev/null)) ]]; then
    echo "$PWD is not a Git repository"
    [[ "$0" = "$BASH_SOURCE" ]] && exit 2 || return 2
fi

ret_code=0
current=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)

git fetch --all &>/dev/null
if [[ ("$?" -eq "0") ]]; then
    for branch in $(git branch -vv | grep -v ": gone]" | awk '{print $1}'); do

        # For some reason, this picks up all files
        if [ -e "$branch" ]; then
            continue
        fi

        echo "Merging $branch"

        git checkout "$branch" &>/dev/null
        if [[ ("$?" -ne "0") ]]; then
            echo "Checkout failed for $branch"
            ret_code=1
            continue
        fi

        git rebase "origin/$branch" &>/dev/null
        if [[ ("$?" -ne "0") ]]; then
            echo "Rebase failed for $branch"
            ret_code=1
            continue
        fi

        git merge master -m "Merge 'master' into '$branch'"
        if [[ ("$?" -ne "0") ]]; then
            echo "Merge failed for $branch"
            ret_code=1
            continue
        fi

        git push
        if [[ ("$?" -ne "0") ]]; then
            echo "Push failed for $branch"
            ret_code=1
            continue
        fi
    done    
fi

if [[ (! -z "$current") ]]; then
    echo "Switching to $current"
    git checkout "$current" &>/dev/null
fi

[[ "$0" = "$BASH_SOURCE" ]] && exit "$ret_code" || return "$ret_code"

相关内容