Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] Return error when not checking out an entry due to dirtiness.

From: Horst von Brand <hidden>
Date: 2016-06-15 22:42:08

Junio C Hamano [off-list ref] wrote:
quoted hunk
Without -f flag, 'git-checkout-index foo.c' issued an error message
when foo.c already existed in the working tree and did not match index.
However it did not return an error from the underlying checkout_entry()
function and resulted in a successful exit(0).

Signed-off-by: Junio C Hamano <redacted>

---

 * I've made sure that the existing scripts do not use
   checkout-index without -f in a way that could be affected by
   this change.  However, third-party scripts may be affected by
   this.  Cogito and StGIT should be OK -- they either run
   checkout with -f, do not check the error return when it does
   not use -f, or runs checkout without -f in an empty working
   tree.

 checkout-index.c |   11 ++++++++---
 entry.c          |    2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

5a166f6a9d1b7ca2de673139fbfc4112b1b2e308
diff --git a/checkout-index.c b/checkout-index.c
--- a/checkout-index.c
+++ b/checkout-index.c
@@ -63,15 +63,20 @@ static int checkout_file(const char *nam
 
 static int checkout_all(void)
 {
-	int i;
+	int i, errs;
 
-	for (i = 0; i < active_nr ; i++) {
+	for (errs = i = 0; i < active_nr ; i++) {
This is ugly. Why not just:

        errs = 0;
        for (i = 0; i < active_nr ; i++) {    

(errs is in no way the variable controlled by the for).
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                     Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria              +56 32 654239
Casilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help