@matheusbsbs / matheus-bagliano / commits / 4232826771
Fork 0

transport.c::transport_push(): make ref status affect return value

Use push_had_errors() to check the refs for errors and modify the return value. Mark the non-fast-forward push tests to succeed. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tay Ray Chuan committed Jan 8, 2010 at 10:12 UTC 4232826771d5bdc4cc0bd21188b6ee5f3e700a52
2 files changed +7 -4
t/t5541-http-push.sh
+2 -2
@@ -88,7 +88,7 @@ test_expect_success 'used receive-pack service' '
88 test_cmp exp act
89 '
90
91 -test_expect_failure 'non-fast-forward push fails' '
91 +test_expect_success 'non-fast-forward push fails' '
92 cd "$ROOT_PATH"/test_repo_clone &&
93 git checkout master &&
94 echo "changed" > path2 &&
@@ -104,7 +104,7 @@ test_expect_success 'non-fast-forward push show ref status' '
104 grep "^ ! \[rejected\][ ]*master -> master (non-fast-forward)$" output
105 '
106
107 -test_expect_failure 'non-fast-forward push shows help message' '
107 +test_expect_success 'non-fast-forward push shows help message' '
108 grep \
109 "To prevent you from losing history, non-fast-forward updates were rejected
110 Merge the remote changes before pushing again. See the '"'non-fast-forward'"'
transport.c
+5 -2
@@ -875,7 +875,7 @@ int transport_push(struct transport *transport,
875 int verbose = flags & TRANSPORT_PUSH_VERBOSE;
876 int quiet = flags & TRANSPORT_PUSH_QUIET;
877 int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
878 - int ret;
878 + int ret, err;
879
880 if (flags & TRANSPORT_PUSH_ALL)
881 match_flags |= MATCH_REFS_ALL;
@@ -892,8 +892,11 @@ int transport_push(struct transport *transport,
892 flags & TRANSPORT_PUSH_FORCE);
893
894 ret = transport->push_refs(transport, remote_refs, flags);
895 + err = push_had_errors(remote_refs);
896
896 - if (!quiet || push_had_errors(remote_refs))
897 + ret |= err;
898 +
899 + if (!quiet || err)
900 print_push_status(transport->url, remote_refs,
901 verbose | porcelain, porcelain,
902 nonfastforward);