From: Junio C Hamano Date: Wed, 30 Nov 2005 06:11:54 GMT Subject: Re: git-name-rev off-by-one bug Message-ID: <7vek4y1x79.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <7vslte1y5z.fsf@assigned-by-dhcp.cox.net> Junio C Hamano writes: > Linus Torvalds writes: > >> Whaddaya think? I really like it. > > Yes. Maybe split this into 3 pieces. I do not want to waste > your time with that, so will take the liberty to do so myself, > with appropriate commit log messages, if you do not mind. > > 1. give diff-files -[012] flags. > 2. merge-one-file leaves unmerged index entries. > 3. always use -M -p in git-diff. > > I do not have any issue against #1. Actually there is one. If we are asked to do diff -1 and an unmerged path does not have stage #2 but stage #1 entry exists, we would end up showing that stage #1, without telling the user that we are showing something different from what was asked. How about doing something like this, on top of yours? --- diff-files.c +++ diff-files.c @@ -117,8 +117,11 @@ */ i--; /* - * Show the diff for the 'ce' we chose + * Show the diff for the 'ce' if we found the one + * from the desired stage. */ + if (ce_stage(ce) != diff_unmerged_stage) + continue; } if (lstat(ce->name, &st) < 0) {