{"thread":{"id":"27137","subject":"[RFC PATCH] Pass empty file to p4merge where no base is suitable.","startedAt":"2011-04-19T19:46:11Z","lastAt":"2011-05-02T00:01:26Z","messageCount":9,"participants":["Ciaran","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"166099","messageId":"BANLkTimXBayYAScPfk2j9spxcYrmtMJKxg@mail.gmail.com","threadId":"27137","inReplyTo":null,"subject":"[RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Ciaran","fromEmail":"ciaranj@gmail.com","sentAt":"2011-04-19T19:46:11Z","receivedAt":"2011-04-19T19:46:11Z","isPatch":true,"sender":{"key":"ciaranj@gmail.com","avatar":"https://avatars.githubusercontent.com/u/55368?v=4"},"body":"Modify the p4merge client command to pass a reference to an empty file\ninstead of the local file when no base revision available.\n\nIn the situation where a merge tries to add a file from one branch\ninto a branch that already contains that file (by name), p4merge\ncurrently seems to have successfully automatically resolved the\n'conflict' when it is opened (correctly if the files differed by\njust whitespace for example) but leaves the save button disabled. This\nmeans the user of the p4merge client cannot commit the resolved\nchanges back to disk and merely exits, leaving the original\n(merge-conflicted) file in-tact on the disk.\n\nProvide an empty base file to p4merge so that it leaves the save\nbutton enabled.  This will allow saving of the auto-resolution to\ndisk.\n\nPlease note that the empty file is temporarily stored in the location\nspecified as GIT_DIR/.no_base\n\nSigned-off-by: Ciaran Jessup <ciaranj@gmail.com>\n---\nThank you to David Aguilar for his feedback previously on this patch,\nhopefully I've followed the submission guidelines correctly this time.\n This patch is to improve the interaction of p4merge and git in the\ncase where merge conflicts have no common ancestor.  For more detailed\ndiscussion please see: http://marc.info/?l=git&m=130190735601527&w=2\n(I was unsure if it was ok to repost inline, sorry)\n\n git-mergetool--lib.sh |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex fb3f52b..3e007e9 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -262,7 +262,9 @@ run_merge_tool () {\n \t\t\tif $base_present; then\n \t\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n \t\t\telse\n-\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n+\t\t\t\ttouch \"$GIT_DIR/.no_base\"\n+\t\t\t\t\"$merge_tool_path\" \"$GIT_DIR/.no_base\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n+\t\t\t\trm \"$GIT_DIR/.no_base\"\n \t\t\tfi\n \t\t\tcheck_unchanged\n \t\telse\n-- \n1.7.4.1\n"},{"id":"166104","messageId":"7vwriq3p0t.fsf@alter.siamese.dyndns.org","threadId":"27137","inReplyTo":"BANLkTimXBayYAScPfk2j9spxcYrmtMJKxg@mail.gmail.com","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-19T21:33:06Z","receivedAt":"2011-04-19T21:33:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ciaran <ciaranj@gmail.com> writes:\n\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -262,7 +262,9 @@ run_merge_tool () {\n>  \t\t\tif $base_present; then\n>  \t\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n>  \t\t\telse\n> -\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n> +\t\t\t\ttouch \"$GIT_DIR/.no_base\"\n> +\t\t\t\t\"$merge_tool_path\" \"$GIT_DIR/.no_base\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n> +\t\t\t\trm \"$GIT_DIR/.no_base\"\n\nThe calling script \"git-mergetool.sh\" seems to take pains to construct\nthese filenames to have the same .ext, presumably so that the tool can\ntake advantage of it to determine the type of contents and do something\nintelligent about it (e.g. syntax highlighting).\n\nDoes the use of .no_base interfere with that effort?\n\nI suspect that you may be able to simply use \"$BASE\" for that, no?  It\nwill be cleaned up when cleanup_temp_files() is run anyway (warning: I do\nnot use mergetool, and I am writing this only from my cursory looking of\nthe script, so take this with a large grain of salt).\n\nAlso, the command to use when you want to get an empty file is not \"touch\".\nIt is not likely that you would have an existing file there, but the whole\npoint of the updated codepath is to have an empty file, and not a file\nwith recent timestamp, it would be far more sensible to say\n\n\t: >\"$BASE\"\n\ni.e. redirect into the path, with a no-op command.\n"},{"id":"166108","messageId":"7vfwpd529g.fsf@alter.siamese.dyndns.org","threadId":"27137","inReplyTo":"7vwriq3p0t.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-04-19T22:01:47Z","receivedAt":"2011-04-19T22:01:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Also, the command to use when you want to get an empty file is not \"touch\".\n> It is not likely that you would have an existing file there, but the whole\n> point of the updated codepath is to have an empty file, and not a file\n> with recent timestamp, it would be far more sensible to say\n>\n> \t: >\"$BASE\"\n>\n> i.e. redirect into the path, with a no-op command.\n\nBy the way, you may want to study what git-merge-one-file.sh script does\nwhen given a \"both sides added, but differently\" situation (look for a\nstring \"--no-add\" in the script).  It first tries to see if there are many\ncommon material that are added in both sides, and if so tries to use that\ncommon material as the \"fake\" base.  If there isn't enough common\nmaterial, it uses an empty file as the base.\n"},{"id":"166822","messageId":"BANLkTimf1q8JM46J-X1BCwQ+GaeWAgv75Q@mail.gmail.com","threadId":"27137","inReplyTo":"7vwriq3p0t.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Ciaran","fromEmail":"ciaranj@gmail.com","sentAt":"2011-05-01T20:47:22Z","receivedAt":"2011-05-01T20:47:22Z","isPatch":true,"sender":{"key":"ciaranj@gmail.com","avatar":"https://avatars.githubusercontent.com/u/55368?v=4"},"body":"Modify the p4merge client command to pass a reference to an empty file\ninstead of the local file when no base revision available.\n\nIn the situation where a merge tries to add a file from one branch\ninto a branch that already contains that file (by name), p4merge\ncurrently seems to have successfully automatically resolved the\n'conflict' when it is opened (correctly if the files differed by\njust whitespace for example) but leaves the save button disabled. This\nmeans the user of the p4merge client cannot commit the resolved\nchanges back to disk and merely exits, leaving the original\n(merge-conflicted) file in-tact on the disk.\n\nProvide an empty base file to p4merge so that it leaves the save\nbutton enabled.  This will allow saving of the auto-resolution to\ndisk.\n\nPlease note that the empty file is temporarily stored in the location\nspecified as GIT_DIR/.no_base\n\nSigned-off-by: Ciaran Jessup <ciaranj@gmail.com>\n---\n\nContinuation of the thread begun in:\nhttp://marc.info/?l=git&m=130190735601527&w=2\n\n> The calling script \"git-mergetool.sh\" seems to take pains to construct\n> these filenames to have the same .ext, presumably so that the tool can\n> take advantage of it to determine the type of contents and do something\n> intelligent about it (e.g. syntax highlighting).\n>\n> Does the use of .no_base interfere with that effort?\nIt doesn't appear to (remember this patch just affects the p4merge\ntool, and no others.)\n\n>\n> I suspect that you may be able to simply use \"$BASE\" for that, no?  It\n> will be cleaned up when cleanup_temp_files() is run anyway (warning: I do\n> not use mergetool, and I am writing this only from my cursory looking of\n> the script, so take this with a large grain of salt).\nI don't think so, the BASE file isn't created at-all in this scenario afaict.\n\n>\n> Also, the command to use when you want to get an empty file is not \"touch\".\n> It is not likely that you would have an existing file there, but the whole\n> point of the updated codepath is to have an empty file, and not a file\n> with recent timestamp, it would be far more sensible to say\n>\n>        : >\"$BASE\"\n>\n> i.e. redirect into the path, with a no-op command.\nOk, my apologies perl isn't a language I'm overly familiar with :)\nI've adapted the previous patch to take this on board.  Thank you :)\n--\n git-mergetool--lib.sh |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex fb3f52b..7b2008f 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -262,7 +262,9 @@ run_merge_tool () {\n \t\t\tif $base_present; then\n \t\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n \t\t\telse\n-\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n+\t\t\t\t: > \"$GIT_DIR/.no_base\"\n+\t\t\t\t\"$merge_tool_path\" \"$GIT_DIR/.no_base\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n+\t\t\t\trm \"$GIT_DIR/.no_base\"\n \t\t\tfi\n \t\t\tcheck_unchanged\n \t\telse\n-- \n1.7.4.1\n"},{"id":"166824","messageId":"7v7haarsrd.fsf@alter.siamese.dyndns.org","threadId":"27137","inReplyTo":"BANLkTimf1q8JM46J-X1BCwQ+GaeWAgv75Q@mail.gmail.com","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-01T21:54:46Z","receivedAt":"2011-05-01T21:54:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ciaran <ciaranj@gmail.com> writes:\n\n>> I suspect that you may be able to simply use \"$BASE\" for that, no?  It\n>> will be cleaned up when cleanup_temp_files() is run anyway (warning: I do\n>> not use mergetool, and I am writing this only from my cursory looking of\n>> the script, so take this with a large grain of salt).\n> I don't think so, the BASE file isn't created at-all in this scenario afaict.\n\nHmm, just like $BASE, your .no-base is not created at all in this scenario\neither, but you create it yourself in your patch, and because you picked a\nnew filename for that temporary file, you also need to worry about\ncleaning it up.\n\nWhy can't that temporary file be \"$BASE\"?  That is what I was asking.\nThen you would still create an empty file (but see *1*), and can rely on\nexisting codepaths to clean it up.\n\nIOW, wouldn't it be far simpler to turn the part you are patching into\nthese three lines?\n\n\t$base_present || >\"$BASE\"\n        \"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n        check_unchanged\n\n> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> index fb3f52b..7b2008f 100644\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -262,7 +262,9 @@ run_merge_tool () {\n>  \t\t\tif $base_present; then\n>  \t\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n>  \t\t\telse\n> -\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n> +\t\t\t\t: > \"$GIT_DIR/.no_base\"\n> +\t\t\t\t\"$merge_tool_path\" \"$GIT_DIR/.no_base\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n> +\t\t\t\trm \"$GIT_DIR/.no_base\"\n>  \t\t\tfi\n>  \t\t\tcheck_unchanged\n>  \t\telse\n\n\n[Footnote]\n\n*1* It also may be worth considering to employ the \"use either an empty\n    file or use the common parts of merged files, whichever makes the\n    merge simpler, as a phony base\" technique found in git-merge-one-file.\n"},{"id":"166825","messageId":"BANLkTikv0YmB-u74sOrQUQZGQvYJNmBx_w@mail.gmail.com","threadId":"27137","inReplyTo":"7v7haarsrd.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Ciaran","fromEmail":"ciaranj@gmail.com","sentAt":"2011-05-01T22:08:24Z","receivedAt":"2011-05-01T22:08:24Z","isPatch":true,"sender":{"key":"ciaranj@gmail.com","avatar":"https://avatars.githubusercontent.com/u/55368?v=4"},"body":"On Sun, May 1, 2011 at 10:54 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ciaran <ciaranj@gmail.com> writes:\n>\n>>> I suspect that you may be able to simply use \"$BASE\" for that, no?  It\n>>> will be cleaned up when cleanup_temp_files() is run anyway (warning: I do\n>>> not use mergetool, and I am writing this only from my cursory looking of\n>>> the script, so take this with a large grain of salt).\n>> I don't think so, the BASE file isn't created at-all in this scenario afaict.\n>\n> Hmm, just like $BASE, your .no-base is not created at all in this scenario\n> either, but you create it yourself in your patch, and because you picked a\n> new filename for that temporary file, you also need to worry about\n> cleaning it up.\n>\n> Why can't that temporary file be \"$BASE\"?  That is what I was asking.\n> Then you would still create an empty file (but see *1*), and can rely on\n> existing codepaths to clean it up.\n>\n> IOW, wouldn't it be far simpler to turn the part you are patching into\n> these three lines?\n>\n>        $base_present || >\"$BASE\"\n>        \"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n>        check_unchanged\n\nYes, that is a *much* better solution that solves my issue perfectly\n;) Patch to follow.\n\n<!-- Snip -->\n\n> [Footnote]\n>\n> *1* It also may be worth considering to employ the \"use either an empty\n>    file or use the common parts of merged files, whichever makes the\n>    merge simpler, as a phony base\" technique found in git-merge-one-file.\n>\nI did consider your earlier post on this, but it seems that that\nperforce's merge client is sufficiently smart enough to do this\nalignment/matching itself, so the effort isn't required (imho) for\nthis client (which is the client that I'm experiencing 'pain' with atm\n!\n\nThanks,\n- Cj.\n"},{"id":"166826","messageId":"BANLkTimD_S3ik7-0j0gMCiEo3aoRwCy92Q@mail.gmail.com","threadId":"27137","inReplyTo":"BANLkTikv0YmB-u74sOrQUQZGQvYJNmBx_w@mail.gmail.com","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Ciaran","fromEmail":"ciaranj@gmail.com","sentAt":"2011-05-01T22:16:02Z","receivedAt":"2011-05-01T22:16:02Z","isPatch":true,"sender":{"key":"ciaranj@gmail.com","avatar":"https://avatars.githubusercontent.com/u/55368?v=4"},"body":"Modify the p4merge client command to pass a reference to an empty file\ninstead of the local file when no base revision available.\n\nIn the situation where a merge tries to add a file from one branch\ninto a branch that already contains that file (by name), p4merge\ncurrently seems to have successfully automatically resolved the\n'conflict' when it is opened (correctly if the files differed by\njust whitespace for example) but leaves the save button disabled. This\nmeans the user of the p4merge client cannot commit the resolved\nchanges back to disk and merely exits, leaving the original\n(merge-conflicted) file intact on the disk.\n\nProvide an empty base file to p4merge so that it leaves the save\nbutton enabled.  This will allow saving of the auto-resolution to\ndisk.\n\nSigned-off-by: Ciaran Jessup <ciaranj@gmail.com>\n---\nA hopefully final stab at the patch, which effectively backs out my\nversion, and implements the suggestions of\nJunio C Hamano.\n\n git-mergetool--lib.sh |    9 +++------\n 1 files changed, 3 insertions(+), 6 deletions(-)\n\ndiff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\nindex fb3f52b..4db9212 100644\n--- a/git-mergetool--lib.sh\n+++ b/git-mergetool--lib.sh\n@@ -258,12 +258,9 @@ run_merge_tool () {\n \t\t;;\n \tp4merge)\n \t\tif merge_mode; then\n-\t\t    touch \"$BACKUP\"\n-\t\t\tif $base_present; then\n-\t\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n-\t\t\telse\n-\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n-\t\t\tfi\n+\t\t\ttouch \"$BACKUP\"\n+\t\t\t$base_present || >\"$BASE\"\n+\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n \t\t\tcheck_unchanged\n \t\telse\n \t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$REMOTE\"\n-- \n1.7.4.1\n"},{"id":"166830","messageId":"7vk4eaq8m3.fsf@alter.siamese.dyndns.org","threadId":"27137","inReplyTo":"BANLkTimD_S3ik7-0j0gMCiEo3aoRwCy92Q@mail.gmail.com","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-05-01T23:55:16Z","receivedAt":"2011-05-01T23:55:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ciaran <ciaranj@gmail.com> writes:\n\n> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n> index fb3f52b..4db9212 100644\n> --- a/git-mergetool--lib.sh\n> +++ b/git-mergetool--lib.sh\n> @@ -258,12 +258,9 @@ run_merge_tool () {\n>  \t\t;;\n>  \tp4merge)\n>  \t\tif merge_mode; then\n> -\t\t    touch \"$BACKUP\"\n> -\t\t\tif $base_present; then\n> -\t\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n> -\t\t\telse\n> -\t\t\t\t\"$merge_tool_path\" \"$LOCAL\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n> -\t\t\tfi\n> +\t\t\ttouch \"$BACKUP\"\n> +\t\t\t$base_present || >\"$BASE\"\n> +\t\t\t\"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n>  \t\t\tcheck_unchanged\n\nWill queue this version as-is; thanks.\n\n\nSomebody might want to revisit if that \"touch\" is still really necessary,\nthough.  It is outside the scope of this change, as that has been there\nbefore this patch.\n"},{"id":"166832","messageId":"BANLkTi=wpxzyn01=g5g1JmjY1UPVQ6faHQ@mail.gmail.com","threadId":"27137","inReplyTo":"7vk4eaq8m3.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC PATCH] Pass empty file to p4merge where no base is suitable.","fromName":"Ciaran","fromEmail":"ciaranj@gmail.com","sentAt":"2011-05-02T00:01:26Z","receivedAt":"2011-05-02T00:01:26Z","isPatch":true,"sender":{"key":"ciaranj@gmail.com","avatar":"https://avatars.githubusercontent.com/u/55368?v=4"},"body":"On Mon, May 2, 2011 at 12:55 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ciaran <ciaranj@gmail.com> writes:\n>\n>> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh\n>> index fb3f52b..4db9212 100644\n>> --- a/git-mergetool--lib.sh\n>> +++ b/git-mergetool--lib.sh\n>> @@ -258,12 +258,9 @@ run_merge_tool () {\n>>               ;;\n>>       p4merge)\n>>               if merge_mode; then\n>> -                 touch \"$BACKUP\"\n>> -                     if $base_present; then\n>> -                             \"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n>> -                     else\n>> -                             \"$merge_tool_path\" \"$LOCAL\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n>> -                     fi\n>> +                     touch \"$BACKUP\"\n>> +                     $base_present || >\"$BASE\"\n>> +                     \"$merge_tool_path\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"\n>>                       check_unchanged\n>\n> Will queue this version as-is; thanks.\n\nThank you.\n\n>\n>\n> Somebody might want to revisit if that \"touch\" is still really necessary,\n> though.  It is outside the scope of this change, as that has been there\n> before this patch.\nThe only reason my patch touches it was to 'fix' the whitespace (i.e.\nit was mixed tabs + space chars, where all the other instances of that\nline aren't)\n\nI did debate backing that change out though :)\n- cj.\n\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"}]}