summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Burda <dev@sinitax.com>2025-11-14 21:49:13 +0100
committerLouis Burda <dev@sinitax.com>2025-11-14 21:49:13 +0100
commitfdb21dc20f8eea296909c1b90b1646749e0e9df4 (patch)
treea5fa424971b6328d7c2b751fd48a046af10703a4
parent6462d6102e8671d15762eae9dac464d3527dc795 (diff)
downloadgit-sync-fdb21dc20f8eea296909c1b90b1646749e0e9df4.tar.gz
git-sync-fdb21dc20f8eea296909c1b90b1646749e0e9df4.zip
Report error code and dont start all the watchers at the same time
-rwxr-xr-xgit-sync15
-rwxr-xr-xgit-syncd1
2 files changed, 10 insertions, 6 deletions
diff --git a/git-sync b/git-sync
index c8dbfb5..19d99e6 100755
--- a/git-sync
+++ b/git-sync
@@ -335,8 +335,9 @@ fi
# TODO make fetching/pushing optional
__log_msg "Fetching from $remote_name/$branch_name"
git fetch $remote_name $branch_name
-if [ $? != 0 ] ; then
- __log_msg "git fetch $remote_name returned non-zero. Likely a network problem; exiting."
+rc=$?
+if [ $rc != 0 ] ; then
+ __log_msg "git fetch $remote_name returned non-zero ($rc). Likely a network problem; exiting."
exit 3
fi
@@ -351,20 +352,22 @@ case "$(sync_state)" in
"ahead")
__log_msg "Pushing changes..."
git push $remote_name $branch_name:$branch_name
- if [ $? == 0 ]; then
+ rc=$?
+ if [ $rc == 0 ]; then
exit_assuming_sync
else
- __log_msg "git push returned non-zero. Likely a connection failure."
+ __log_msg "git push returned non-zero ($rc). Likely a connection failure."
exit 3
fi
;;
"behind")
__log_msg "We are behind, fast-forwarding..."
git merge --ff --ff-only $remote_name/$branch_name
- if [ $? == 0 ]; then
+ rc=$?
+ if [ $rc == 0 ]; then
exit_assuming_sync
else
- __log_msg "git merge --ff --ff-only returned non-zero ($?). Exiting."
+ __log_msg "git merge --ff --ff-only returned non-zero ($rc). Exiting."
exit 2
fi
;;
diff --git a/git-syncd b/git-syncd
index 08f121a..b2bf1fd 100755
--- a/git-syncd
+++ b/git-syncd
@@ -86,6 +86,7 @@ start_watchers() {
for repo in "${git_syncd_repos[@]}"; do
echo "watching '$repo'.."
$git_syncd watch "$repo" &
+ sleep 1 # wait a bit
git_syncd_watchers+=($!)
done
}