{"thread":{"id":"21747","subject":"cvsexportcommit dies when applying an (empty) merge commit","startedAt":"2009-11-25T11:59:22Z","lastAt":"2009-11-26T06:51:05Z","messageCount":4,"participants":["Nick Woolley","Michael J Gruber","Robin Rosenberg"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"128302","messageId":"4B0D1C1A.60707@yahoo.co.uk","threadId":"21747","inReplyTo":null,"subject":"cvsexportcommit dies when applying an (empty) merge commit","fromName":"Nick Woolley","fromEmail":"nickwoolley@yahoo.co.uk","sentAt":"2009-11-25T11:59:22Z","receivedAt":"2009-11-25T11:59:22Z","isPatch":false,"sender":{"key":"nick@noodlefactory.co.uk","avatar":null},"body":"Hi,\n\nI have a git repository with a merge point on the master branch.  This merge\ncommit is empty, and just contains a commit message:\n\n  Merge commit 'otherbranch'\n\nI'm trying to export this branch into CVS using git-cvsexportcommit (the latest\nversion from the master branch). It's actually done in a wrapper script [1] but\nthe command that gets invoked is essentially:\n\n git cvsexportcommit -p -v -u -w  'cvscheckout/HEAD/my-cvs-module' -c \\\n    <parent commit> <commit>\n\nWhere <commit> is the empty merge commit.  However this invocation dies and\naborts the process of exporting the branch half way.\n\nThe fatal error I get is:\n\n Applying to CVS commit <commit> from parent <parent commit>\n Checking if patch will apply\n Applying\n error: No changes\n cannot patch at /usr/lib/git-core/git-cvsexportcommit line 324.\n\nThe vicinity of line 324 is (with some lines wrapped):\n\n print \"Applying\\n\";\n if ($opt_W) {\n     system(\"git checkout -q $commit^0\") && die \"cannot patch\";\n } else {\n     `GIT_DIR= git-apply $context --summary --numstat --apply\n<.cvsexportcommit.diff` || die \"cannot patch\";\n }\n\nIt seems that the file .cvsexportcommit.diff is empty, so git-apply is refusing\nto apply it.\n\nPresumably the application would be a no-op, so this git-apply step could be\nskipped.  So I tried modifying the script to do that and it seems to work:\n\n print \"Applying\\n\";\n if ($opt_W) {\n     system(\"git checkout -q $commit^0\") && die \"cannot patch\";\n } elsif (-s \".cvsexportcommit.diff\") {\n     `GIT_DIR= git-apply $context --summary --numstat --apply\n<.cvsexportcommit.diff` || die \"cannot patch\";\n } else {\n    print \"No changes\\n\";\n }\n\nThe modified git-cvsexportcommit script completes without errors, but\nunsurprisingly, seems to export nothing, so that when imported back into git,\nthere is no empty commit.  There appears to be no log message added in CVS, either.\n\nThis does seem more acceptable than dying, although it doesn't faithfully\nreproduce the git history.  However I'm not sure if that would be possible in\nthis case.\n\nIs the existing behaviour deliberately fatal, or is this worth supplying a patch\nfor?\n\n\nCheers,\n\nN\n\n1. http://github.com/wu-lee/git-cvs\n"},{"id":"128306","messageId":"4B0D2BC5.1000002@drmicha.warpmail.net","threadId":"21747","inReplyTo":"4B0D1C1A.60707@yahoo.co.uk","subject":"Re: cvsexportcommit dies when applying an (empty) merge commit","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-11-25T13:06:13Z","receivedAt":"2009-11-25T13:06:13Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Nick Woolley venit, vidit, dixit 25.11.2009 12:59:\n> Hi,\n> \n> I have a git repository with a merge point on the master branch.  This merge\n> commit is empty, and just contains a commit message:\n> \n>   Merge commit 'otherbranch'\n> \n> I'm trying to export this branch into CVS using git-cvsexportcommit (the latest\n> version from the master branch). It's actually done in a wrapper script [1] but\n> the command that gets invoked is essentially:\n> \n>  git cvsexportcommit -p -v -u -w  'cvscheckout/HEAD/my-cvs-module' -c \\\n>     <parent commit> <commit>\n> \n> Where <commit> is the empty merge commit.  However this invocation dies and\n> aborts the process of exporting the branch half way.\n> \n> The fatal error I get is:\n> \n>  Applying to CVS commit <commit> from parent <parent commit>\n>  Checking if patch will apply\n>  Applying\n>  error: No changes\n>  cannot patch at /usr/lib/git-core/git-cvsexportcommit line 324.\n> \n> The vicinity of line 324 is (with some lines wrapped):\n> \n>  print \"Applying\\n\";\n>  if ($opt_W) {\n>      system(\"git checkout -q $commit^0\") && die \"cannot patch\";\n>  } else {\n>      `GIT_DIR= git-apply $context --summary --numstat --apply\n> <.cvsexportcommit.diff` || die \"cannot patch\";\n>  }\n> \n> It seems that the file .cvsexportcommit.diff is empty, so git-apply is refusing\n> to apply it.\n> \n> Presumably the application would be a no-op, so this git-apply step could be\n> skipped.  So I tried modifying the script to do that and it seems to work:\n> \n>  print \"Applying\\n\";\n>  if ($opt_W) {\n>      system(\"git checkout -q $commit^0\") && die \"cannot patch\";\n>  } elsif (-s \".cvsexportcommit.diff\") {\n>      `GIT_DIR= git-apply $context --summary --numstat --apply\n> <.cvsexportcommit.diff` || die \"cannot patch\";\n>  } else {\n>     print \"No changes\\n\";\n>  }\n> \n> The modified git-cvsexportcommit script completes without errors, but\n> unsurprisingly, seems to export nothing, so that when imported back into git,\n> there is no empty commit.  There appears to be no log message added in CVS, either.\n> \n> This does seem more acceptable than dying, although it doesn't faithfully\n> reproduce the git history.  However I'm not sure if that would be possible in\n> this case.\n> \n> Is the existing behaviour deliberately fatal, or is this worth supplying a patch\n> for?\n\nI think the behavior is correct in the sense that you're telling git\ncvsexportcommit to make a commit to cvs, and it can't, because there is\nno change to commit. A merge can't be represented.\n\nIt leaves you the choice between omitting the trivial merge from cvs\nhistory (that's what one would do for a merge based cvs<->git workflow)\nand generating a fake commit in cvs. I don't know if it has something\nlike --allow-empty - it's file base, after all.\n\nMichael\n"},{"id":"128363","messageId":"4B0DB70B.1090405@yahoo.co.uk","threadId":"21747","inReplyTo":"4B0D2BC5.1000002@drmicha.warpmail.net","subject":"Re: cvsexportcommit dies when applying an (empty) merge commit","fromName":"Nick Woolley","fromEmail":"nickwoolley@yahoo.co.uk","sentAt":"2009-11-25T23:00:27Z","receivedAt":"2009-11-25T23:00:27Z","isPatch":false,"sender":{"key":"nick@noodlefactory.co.uk","avatar":null},"body":"Michael J Gruber wrote:\n> I think the behavior is correct in the sense that you're telling git\n> cvsexportcommit to make a commit to cvs, and it can't, because there is\n> no change to commit. A merge can't be represented.\n\nThe main problem with this is that by default it aborts the whole process with\nan error.  I'd prefer a non-fatal warning rather than having to catch the error\nand decide if it's ignorable or not, although for now I guess I'll have to, or\nmake a fork of git-cvsexportcommit.\n\nCVS doesn't has an --allow-empty equivalent I know of, and nor does\ngit-cvsexportcommit.\n\nCheers,\n\nN\n"},{"id":"128440","messageId":"200911260751.06377.robin.rosenberg.lists@dewire.com","threadId":"21747","inReplyTo":"4B0D1C1A.60707@yahoo.co.uk","subject":"Re: cvsexportcommit dies when applying an (empty) merge commit","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2009-11-26T06:51:05Z","receivedAt":"2009-11-26T06:51:05Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"onsdag 25 november 2009 12:59:22 skrev  Nick Woolley:\n> Hi,\n>\n> I have a git repository with a merge point on the master branch.  This\n> merge commit is empty, and just contains a commit message:\n>\n>   Merge commit 'otherbranch'\n>\n> I'm trying to export this branch into CVS using git-cvsexportcommit (the\n> latest version from the master branch). It's actually done in a wrapper\n> script [1] but the command that gets invoked is essentially:\n>\n>  git cvsexportcommit -p -v -u -w  'cvscheckout/HEAD/my-cvs-module' -c \\\n>     <parent commit> <commit>\n>\n> Where <commit> is the empty merge commit.  However this invocation dies and\n> aborts the process of exporting the branch half way.\n>\n> The fatal error I get is:\n>\n>  Applying to CVS commit <commit> from parent <parent commit>\n>  Checking if patch will apply\n>  Applying\n>  error: No changes\n>  cannot patch at /usr/lib/git-core/git-cvsexportcommit line 324.\n>\n[....]\n> Is the existing behaviour deliberately fatal, or is this worth supplying a\n> patch for?\n\nI'm not the only contributor, but I'd say its a omission. cvsexportcommit \ndoesn't export commits. It export deltas, that is the change relative to one\nof the parents. It is reasonable that cvsexportcommit can \"export\" an\nempty commit by doing nothing and exiting with 0. Printing some kind of \nwarning seems reasonable too.\n\n- robin\n"}]}