Re: [PATCHv4 3/3] Advices about 'git rm' during conflicts (unmerged paths) more relevant

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Junio C Hamano <gitster@xxxxxxxxx> a écrit :

+		if (d->stagemask == 1 && !both_deleted_flag)
+			both_deleted_flag = 1;
+ else if ((d->stagemask == 3 || d->stagemask == 5) && !simple_deleted_flag)
+			simple_deleted_flag = 1;
+		else if ((d->stagemask == 2 || d->stagemask == 4 || d->stagemask == 6 ||
+				d->stagemask == 7) && !not_deleted_flag)
+			not_deleted_flag = 1;
+	}

	switch (d->stagemask) {
        case 1:
        	both_deleted = 1;
                break;
        case 3:
        case 5:
        	simple_deleted = 1;
                break;
        default:
        	not_deleted = 1;
                break;
	}

Yes, using switch makes the code easier to read. In fact, I put explicitly the
condition when there are no delete (cases 2, 4, 6 and 7) because there are cases
when d->stagemask can take other number than 1..7. For example:

git init git &&
cd git &&
test_commit foo main.txt foo &&
git branch second_branch &&
git mv main.txt sub_master.txt &&
git commit -m "main.txt renamed in sub_master.txt" &&
git checkout second_branch &&
git mv main.txt sub_second.txt &&
git commit -m "main.txt renamed in sub_second.txt" &&
git merge master &&
git add sub_master.txt &&
git add sub_second.txt

At this point, the output of git status shows in unmerged paths the file main.txt that is marked as 'both deleted' so the number of elements in s->change.items should be 1. However, in this case, there are 2 elements. One is about the file main.txt and its stagemask is '1' (as expected) but the stagemask of the other element (I don't
know its origin) is '0'.
Anyway, the new code becomes something like:

switch (d->stagemask) {
case 0:
	break;
case 1:
	both_deleted = 1;
	break;
case 3:
case 5:
	del_mod_conflict = 1;
	break;
default:
	not_deleted = 1;
	break;
}

Though I don't know if d->stagemask can take values such as 8, 9, etc.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]