Skip to content

Commit 4b5087f

Browse files
committed
Merge pull request #21 from naderman/fix-exit-codes
Proeprly check exit codes of git subtree
2 parents b2a4f38 + 6a8bc71 commit 4b5087f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

git-subsplit.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,13 @@ subsplit_publish()
216216
fi
217217

218218
say " - syncing branch '${HEAD}'"
219+
219220
git checkout master >/dev/null 2>&1
220221
git branch -D "$LOCAL_BRANCH" >/dev/null 2>&1
221222
git branch -D "${LOCAL_BRANCH}-checkout" >/dev/null 2>&1
222223
git checkout -b "${LOCAL_BRANCH}-checkout" "origin/${HEAD}" >/dev/null 2>&1
223224
git subtree split -q --prefix="$SUBPATH" --branch="$LOCAL_BRANCH" "origin/${HEAD}" >/dev/null
225+
RETURNCODE=$?
224226

225227
if [ -n "$VERBOSE" ];
226228
then
@@ -231,7 +233,7 @@ subsplit_publish()
231233
echo "${DEBUG} git subtree split -q --prefix=\"$SUBPATH\" --branch=\"$LOCAL_BRANCH\" \"origin/${HEAD}\" >/dev/null"
232234
fi
233235

234-
if [ $? -eq 0 ]
236+
if [ $RETURNCODE -eq 0 ]
235237
then
236238
PUSH_CMD="git push -q ${DRY_RUN} --force $REMOTE_NAME ${LOCAL_BRANCH}:${HEAD}"
237239

@@ -291,14 +293,15 @@ subsplit_publish()
291293

292294
say " - subtree split for '${TAG}'"
293295
git subtree split -q --annotate="${ANNOTATE}" --prefix="$SUBPATH" --branch="$LOCAL_TAG" "$TAG" >/dev/null
296+
RETURNCODE=$?
294297

295298
if [ -n "$VERBOSE" ];
296299
then
297300
echo "${DEBUG} git subtree split -q --annotate=\"${ANNOTATE}\" --prefix=\"$SUBPATH\" --branch=\"$LOCAL_TAG\" \"$TAG\" >/dev/null"
298301
fi
299302

300303
say " - subtree split for '${TAG}' [DONE]"
301-
if [ $? -eq 0 ]
304+
if [ $RETURNCODE -eq 0 ]
302305
then
303306
PUSH_CMD="git push -q ${DRY_RUN} --force ${REMOTE_NAME} ${LOCAL_TAG}:refs/tags/${TAG}"
304307

0 commit comments

Comments
 (0)