Skip to content

Commit cf0e7bc

Browse files
committed
git-synchronizer: only force-push when necessary
This helps with SourceForge: SourceForge has this ridiculously restrictive configuration that disallows non-fast-forward pushes, even to branches other than 'master'. This cannot even be changed by project administrators. As a work-around, we delete branches just before force-pushing them when we detect that the force-push targets SourceForge. However, we marked too many pushes as forced pushes, including fast-forwarding ones to the master branch. And ran into another restriction (one that actually does make sense): you cannot delete the current branch. So let's be extra careful to determine whether it is *actually* a forced push, or whether it is really a fast-forward. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent a99eb96 commit cf0e7bc

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

git-synchronizer.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,16 @@ do
252252
echo ":refs/heads/$ref"
253253
fi
254254
else
255-
if test ${sha1#+} != "$(git rev-parse $remoteref 2> /dev/null)"
255+
sha1=${sha1#+}
256+
if test $sha1 != "$(git rev-parse $remoteref 2> /dev/null)"
256257
then
257-
echo "$sha1:refs/heads/$ref"
258+
if test -n "$(git rev-list "$sha1..$remoteref")"
259+
then
260+
# really need to force
261+
echo "+$sha1:refs/heads/$ref"
262+
else
263+
echo "$sha1:refs/heads/$ref"
264+
fi
258265
fi
259266
fi
260267
done)

0 commit comments

Comments
 (0)