From: Gary V. Vaughan Date: Sun, 7 Sep 2008 11:53:16 +0000 (+0800) Subject: Add untested git push conflict testing to commit script. X-Git-Tag: v2.2.7b~201 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96e199bd5142ebd542e587d5f3379d1e762b3ff7;p=thirdparty%2Flibtool.git Add untested git push conflict testing to commit script. * clcommit.m4sh (func_check_conflicts): Test return status of 'git push --dry-run', and display an error on non-zero. Signed-off-by: Gary V. Vaughan --- diff --git a/ChangeLog b/ChangeLog index 07b50743f..7ac504cfa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-09-07 Gary V. Vaughan + Add untested git push conflict testing to commit script. + * clcommit.m4sh (func_check_conflicts): Test return status + of 'git push --dry-run', and display an error on non-zero. + Enable release procedure to work with lzma OLDRELEASE file. * Makefile.maint (diffs, prev-tarball, new-tarball): If lzma tarballs are present use them to generate the diffs, otherwise diff --git a/clcommit.m4sh b/clcommit.m4sh index 4eefd0714..3394311a9 100644 --- a/clcommit.m4sh +++ b/clcommit.m4sh @@ -110,6 +110,7 @@ fi signature_file= log_dir="`func_mktempdir`" log_file="$log_dir/log" +push_conflicts="$log_dir/git_push.log" trap '$RM -r "$log_dir"; exit $EXIT_FAILURE' 1 2 15 @@ -289,9 +290,9 @@ set -e # func_check_conflicts func_check_conflicts () { - # HELP?!? How to check for git push conflicts? - if false; then - func_fatal_error "some conflicts were found with CVS repository, aborting..." + if $GIT push --dry-run > "$push_conflicts" 2>&1; then :; else + cat "$push_conflicts" >&2 + func_fatal_error "some conflicts were found with upstream repository, aborting..." fi } @@ -420,8 +421,6 @@ func_mailnotify () ## ----- ## { - $opt_update && func_check_conflicts - test -f "$log_file" || func_check_commit_msg grep '[^ ]' < "$log_file" > /dev/null || @@ -432,15 +431,16 @@ func_mailnotify () func_error "*** They should be used to separate distinct commits." fi + $opt_update && $opt_push && func_check_conflicts + # Do not check for empty $log_file again, even though the user might have # zeroed it out. If s/he did, it was probably intentional. if $opt_commit; then func_commit ${1+"$@"} fi - subject=`sed -n '1p' "$log_file"` - # Send a copy of the log_file if sendmail_to was set: + subject=`sed -n '1p' "$log_file"` if test -n "$sendmail_to"; then if ! $opt_push; then func_warning "Mail notification NOT sent for commit to local repository."