shithub: riscv

Download patch

ref: 6fbf81a98f8f747444cfe0e7a0591f6de511e510
parent: aa0b6bedf4151dffec81e38b3c166aaac51c04c1
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Oct 15 13:20:28 EDT 2023

walk: handle removed files correctly

A file that was not checked in, added, and
then removed would be shown as modified, and
not skipped. It would also be stuck in the
index forever.

This change skips showing untracked moved files
and purges them from the index.

--- a/sys/src/cmd/git/walk.c
+++ b/sys/src/cmd/git/walk.c
@@ -496,9 +496,14 @@
 			c = strcmp(idx[i].path, wdir[j].path);
 		/* exists in both index and on disk */
 		if(c == 0){
-			if(idx[i].state == 'R' && checkedin(&idx[i], 0))
-				show(o, Rflg, rstr, idx[i].path);
-			else if(idx[i].state == 'A' && !checkedin(&idx[i], 1))
+			if(idx[i].state == 'R'){
+				if(checkedin(&idx[i], 0))
+					show(o, Rflg, rstr, idx[i].path);
+				else{
+					idx[i].state = 'U';
+					staleidx = 1;
+				}
+			}else if(idx[i].state == 'A' && !checkedin(&idx[i], 1))
 				show(o, Aflg, astr, idx[i].path);
 			else if(!samedata(&idx[i], &wdir[j]))
 				show(o, Mflg, mstr, idx[i].path);
@@ -534,6 +539,8 @@
 		for(i = 0; i < nidx; i++){
 			while(i+1 < nidx && strcmp(idx[i].path, idx[i+1].path) == 0)
 				i++;
+			if(idx[i].state == 'U')
+				continue;
 			Bprint(w, "%c %Q %o %s\n",
 				idx[i].state,
 				idx[i].qid,