git: 9front

Download patch

ref: 6b2cc0d92f213dec2721510562a6824bd51312c7
parent: 674a5212b9b3295fcfdcc9503b552d7bbdc62e60
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, 
--