From: Junio C Hamano Date: Sun, 01 May 2011 21:54:46 GMT Subject: Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable. Message-ID: <7v7haarsrd.fsf@alter.siamese.dyndns.org> In-Reply-To: Ciaran writes: >> I suspect that you may be able to simply use "$BASE" for that, no? It >> will be cleaned up when cleanup_temp_files() is run anyway (warning: I do >> not use mergetool, and I am writing this only from my cursory looking of >> the script, so take this with a large grain of salt). > I don't think so, the BASE file isn't created at-all in this scenario afaict. Hmm, just like $BASE, your .no-base is not created at all in this scenario either, but you create it yourself in your patch, and because you picked a new filename for that temporary file, you also need to worry about cleaning it up. Why can't that temporary file be "$BASE"? That is what I was asking. Then you would still create an empty file (but see *1*), and can rely on existing codepaths to clean it up. IOW, wouldn't it be far simpler to turn the part you are patching into these three lines? $base_present || >"$BASE" "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED" check_unchanged > diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh > index fb3f52b..7b2008f 100644 > --- a/git-mergetool--lib.sh > +++ b/git-mergetool--lib.sh > @@ -262,7 +262,9 @@ run_merge_tool () { > if $base_present; then > "$merge_tool_path" "$BASE" "$LOCAL" "$REMOTE" "$MERGED" > else > - "$merge_tool_path" "$LOCAL" "$LOCAL" "$REMOTE" "$MERGED" > + : > "$GIT_DIR/.no_base" > + "$merge_tool_path" "$GIT_DIR/.no_base" "$LOCAL" "$REMOTE" "$MERGED" > + rm "$GIT_DIR/.no_base" > fi > check_unchanged > else [Footnote] *1* It also may be worth considering to employ the "use either an empty file or use the common parts of merged files, whichever makes the merge simpler, as a phony base" technique found in git-merge-one-file.