Re: [PATCH] threeway_merge: if file will not be touched, leave it alone

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johannes Schindelin
Date: Sunday, October 22, 2006 - 5:48 pm

Hi,

On Sun, 22 Oct 2006, Junio C Hamano wrote:


Two points:

- you are correct for at least the case of choosing the merge strategy 
"theirs". (Which does not exist yet.)

- in merge-recursive.c:process_entry() (which is called on _all_ unmerged 
entries after threeway merge), "Case A" reads "deleted in one branch". 
Reading the code again, I believe there is a bug, which should be fixed by

diff --git a/merge-recursive.c b/merge-recursive.c
index 2ba43ae..9f6538a 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1005,9 +1005,10 @@ static int process_entry(const char *pat
 		    (!a_sha && sha_eq(b_sha, o_sha))) {
 			/* Deleted in both or deleted in one and
 			 * unchanged in the other */
-			if (a_sha)
+			if (!a_sha) {
 				output("Removing %s", path);
-			remove_file(1, path);
+				remove_file(1, path);
+			}
 		} else {
 			/* Deleted in one and changed in the other */
 			clean_merge = 0;

Note that not only it groups the call to output() and remove_file(), which 
matches the expectation, but also changes the condition to "!a_sha", 
meaning that the file is deleted in branch "a", but existed in the merge 
base, where it is identical to what is in branch "b".

Of course, this assumes that even in the recursive case, branch "a" is to 
be preferred over branch "b". (If I still remember correctly, then branch 
"a" is either the current head, or the temporary recursive merge, so this 
would make sense to me.)

So, after applying this patchlet, merge-recursive (more precisely: the 
function process_entry()) should behave correctly with the change to 
unpack-trees.c you have in pu, i.e. the change that drops that 
verify_absent() call to the floor.

However, I could use some additional optical lobes here.

Ciao,
Dscho

P.S.: Maybe I was wrong on my earlier assessment, that merge-recursive 
does not optimize the "subtrees have identical SHA1s" case. This should be 
handled pretty well by the call to unpack_trees() with threeway merge.

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Fri Oct 20, 7:56 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 8:34 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Fri Oct 20, 9:21 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 10:03 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 10:18 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Shawn Pearce, (Fri Oct 20, 10:21 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Fri Oct 20, 10:45 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 10:47 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 10:48 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, David Lang, (Fri Oct 20, 10:58 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 10:59 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 11:06 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jan Hudec, (Fri Oct 20, 11:12 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jon Smirl, (Fri Oct 20, 11:15 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 11:30 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Fri Oct 20, 11:35 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Fri Oct 20, 11:46 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Fri Oct 20, 11:47 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 11:48 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 12:00 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 12:04 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 12:10 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Fri Oct 20, 12:14 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 12:31 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 12:46 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 1:12 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Junio C Hamano, (Fri Oct 20, 1:17 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Petr Baudis, (Fri Oct 20, 1:23 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 1:29 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, David Lang, (Fri Oct 20, 1:49 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Shawn Pearce, (Fri Oct 20, 1:53 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Petr Baudis, (Fri Oct 20, 1:53 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, David Lang, (Fri Oct 20, 1:55 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 1:57 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jeff Licquia, (Fri Oct 20, 3:13 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Petr Baudis, (Fri Oct 20, 3:40 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jeff King, (Fri Oct 20, 3:59 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Robert Collins, (Fri Oct 20, 4:05 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Robert Collins, (Fri Oct 20, 4:15 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Aaron Bentley, (Fri Oct 20, 4:33 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jeff Licquia, (Fri Oct 20, 4:39 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Fri Oct 20, 4:59 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Junio C Hamano, (Fri Oct 20, 6:26 pm)
git-merge-recursive, was Re: [ANNOUNCE] Example Cogito Add ..., Johannes Schindelin, (Fri Oct 20, 7:03 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Matthieu Moy, (Sat Oct 21, 12:56 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Sat Oct 21, 1:36 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Sat Oct 21, 1:40 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Matthieu Moy, (Sat Oct 21, 3:09 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Sat Oct 21, 3:34 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jan Hudec, (Sat Oct 21, 10:40 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Sat Oct 21, 10:51 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Linus Torvalds, (Sat Oct 21, 11:42 am)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jan Hudec, (Sat Oct 21, 12:20 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Jakub Narebski, (Sat Oct 21, 12:21 pm)
[PATCH] threeway_merge: if file will not be touched, leave ..., Johannes Schindelin, (Sun Oct 22, 2:04 pm)
Re: [PATCH] threeway_merge: if file will not be touched, l ..., Johannes Schindelin, (Sun Oct 22, 5:48 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Matthew Hannigan, (Thu Nov 2, 8:43 pm)
Re: [ANNOUNCE] Example Cogito Addon - cogito-bundle, Martin Langhoff, (Thu Nov 2, 11:36 pm)