File 0001-cl_git_fail-do-not-report-bogus-error-message.patch of Package libgit2.25920

From 97dc50aceb2cb3bce0eeab7c5a20711cb370e7b7 Mon Sep 17 00:00:00 2001
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Wed, 18 Sep 2019 15:08:56 +0200
Subject: [PATCH] cl_git_fail: do not report bogus error message

When we expect a checkout operation to fail, but it succeeds, we
actually do not want to see the error messages that were generated in
the meantime for errors that were handled gracefully by the code (e.g.
when an object could not be found in a pack: in this case, the next
backend would have been given a chance to look up the object, and
probably would have found it because the checkout succeeded, after all).

Which means that in the specific case of `cl_git_fail()`, we actually
want to clear the global error state _after_ evaluating the command: we
know that any still-available error would be bogus, seeing as the
command succeeded (unexpectedly).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 tests/clar_libgit2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/clar_libgit2.h b/tests/clar_libgit2.h
index c72d37db363..b0a06935520 100644
--- a/tests/clar_libgit2.h
+++ b/tests/clar_libgit2.h
@@ -29,8 +29,8 @@
  * calls that are supposed to fail!
  */
 #define cl_git_fail(expr) do { \
-	giterr_clear(); \
 	if ((expr) == 0) \
+		giterr_clear(), \
 		cl_git_report_failure(0, 0, __FILE__, __LINE__, "Function call succeeded: " #expr); \
 	} while (0)
 
openSUSE Build Service is sponsored by