{"thread":{"id":"41440","subject":"[PATCH] git-p4.py: Don't try to rebase on submit from bare repository","startedAt":"2016-02-17T22:46:00Z","lastAt":"2016-06-07T20:32:35Z","messageCount":20,"participants":["Amadeusz Żołnowski","Luke Diamand","Junio C Hamano","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"278590","messageId":"1455749160-2017-1-git-send-email-aidecoe@aidecoe.name","threadId":"41440","inReplyTo":null,"subject":"[PATCH] git-p4.py: Don't try to rebase on submit from bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-02-17T22:46:00Z","receivedAt":"2016-02-17T22:46:00Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"git-p4 can be successfully used from bare repository (which acts as a\nbridge between Perforce repository and pure Git repositories). On submit\ngit-p4 performs unconditional rebase. Do rebase only on non-bare\nrepositories.\n---\n git-p4.py | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex c33dece..e00cd02 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -2059,8 +2059,9 @@ class P4Submit(Command, P4UserMap):\n                 sync.branch = self.branch\n             sync.run([])\n \n-            rebase = P4Rebase()\n-            rebase.rebase()\n+            if not gitConfigBool(\"core.bare\"):\n+                rebase = P4Rebase()\n+                rebase.rebase()\n \n         else:\n             if len(applied) == 0:\n-- \n2.7.0\n"},{"id":"278633","messageId":"CAE5ih78G1JczQvUEwzz3TmVPZuKUJVcxwZAsDdNzUbqAyHcqqA@mail.gmail.com","threadId":"41440","inReplyTo":"1455749160-2017-1-git-send-email-aidecoe@aidecoe.name","subject":"Re: [PATCH] git-p4.py: Don't try to rebase on submit from bare repository","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-02-19T09:47:13Z","receivedAt":"2016-02-19T09:47:13Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 17 February 2016 at 22:46, Amadeusz Żołnowski <aidecoe@aidecoe.name> wrote:\n> git-p4 can be successfully used from bare repository (which acts as a\n> bridge between Perforce repository and pure Git repositories). On submit\n> git-p4 performs unconditional rebase. Do rebase only on non-bare\n> repositories.\n\nThis looks obviously sensible and good to me, ack.\n\nThanks!\nLuke\n\n\n\n> ---\n>  git-p4.py | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-p4.py b/git-p4.py\n> index c33dece..e00cd02 100755\n> --- a/git-p4.py\n> +++ b/git-p4.py\n> @@ -2059,8 +2059,9 @@ class P4Submit(Command, P4UserMap):\n>                  sync.branch = self.branch\n>              sync.run([])\n>\n> -            rebase = P4Rebase()\n> -            rebase.rebase()\n> +            if not gitConfigBool(\"core.bare\"):\n> +                rebase = P4Rebase()\n> +                rebase.rebase()\n>\n>          else:\n>              if len(applied) == 0:\n> --\n> 2.7.0\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"},{"id":"278672","messageId":"xmqqy4agd3b1.fsf@gitster.mtv.corp.google.com","threadId":"41440","inReplyTo":"CAE5ih78G1JczQvUEwzz3TmVPZuKUJVcxwZAsDdNzUbqAyHcqqA@mail.gmail.com","subject":"Re: [PATCH] git-p4.py: Don't try to rebase on submit from bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-19T17:21:06Z","receivedAt":"2016-02-19T17:21:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luke Diamand <luke@diamand.org> writes:\n\n> On 17 February 2016 at 22:46, Amadeusz Żołnowski <aidecoe@aidecoe.name> wrote:\n>> git-p4 can be successfully used from bare repository (which acts as a\n>> bridge between Perforce repository and pure Git repositories). On submit\n>> git-p4 performs unconditional rebase. Do rebase only on non-bare\n>> repositories.\n>\n> This looks obviously sensible and good to me, ack.\n>\n> Thanks!\n> Luke\n\nLuke, thanks for a prompt feedback.\n\nAmadeusz, can you sign off your patch (cf. Documentation/SubmittingPatches)?\n\n\n\n>\n>\n>\n>> ---\n>>  git-p4.py | 5 +++--\n>>  1 file changed, 3 insertions(+), 2 deletions(-)\n>>\n>> diff --git a/git-p4.py b/git-p4.py\n>> index c33dece..e00cd02 100755\n>> --- a/git-p4.py\n>> +++ b/git-p4.py\n>> @@ -2059,8 +2059,9 @@ class P4Submit(Command, P4UserMap):\n>>                  sync.branch = self.branch\n>>              sync.run([])\n>>\n>> -            rebase = P4Rebase()\n>> -            rebase.rebase()\n>> +            if not gitConfigBool(\"core.bare\"):\n>> +                rebase = P4Rebase()\n>> +                rebase.rebase()\n>>\n>>          else:\n>>              if len(applied) == 0:\n>> --\n>> 2.7.0\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"},{"id":"278688","messageId":"1455906431-32140-1-git-send-email-aidecoe@aidecoe.name","threadId":"41440","inReplyTo":"xmqqy4agd3b1.fsf@gitster.mtv.corp.google.com","subject":"[PATCH] git-p4.py: Don't try to rebase on submit from bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-02-19T18:27:11Z","receivedAt":"2016-02-19T18:27:11Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"git-p4 can be successfully used from bare repository (which acts as a\nbridge between Perforce repository and pure Git repositories). On submit\ngit-p4 performs unconditional rebase. Do rebase only on non-bare\nrepositories.\n\nSigned-off-by: Amadeusz Żołnowski <aidecoe@aidecoe.name>\n---\n git-p4.py | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex c33dece..e00cd02 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -2059,8 +2059,9 @@ class P4Submit(Command, P4UserMap):\n                 sync.branch = self.branch\n             sync.run([])\n \n-            rebase = P4Rebase()\n-            rebase.rebase()\n+            if not gitConfigBool(\"core.bare\"):\n+                rebase = P4Rebase()\n+                rebase.rebase()\n \n         else:\n             if len(applied) == 0:\n-- \n2.7.0\n"},{"id":"278690","messageId":"CAPig+cQA4sJ2RneG8zRsUx+bDPAMYVtmhFjZx5SOGDqnsKNUaQ@mail.gmail.com","threadId":"41440","inReplyTo":"1455906431-32140-1-git-send-email-aidecoe@aidecoe.name","subject":"Re: [PATCH] git-p4.py: Don't try to rebase on submit from bare repository","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-02-19T18:40:45Z","receivedAt":"2016-02-19T18:40:45Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Fri, Feb 19, 2016 at 1:27 PM, Amadeusz Żołnowski\n<aidecoe@aidecoe.name> wrote:\n> git-p4 can be successfully used from bare repository (which acts as a\n> bridge between Perforce repository and pure Git repositories). On submit\n> git-p4 performs unconditional rebase. Do rebase only on non-bare\n> repositories.\n\nAs a person who does not use Perforce, it is not obvious to me from\nthe commit message why this change is beneficial or even what the\nconsequences are. Will Perforce users understand this change given\nonly the explanation above? If not, perhaps it would be helpful to\nexpand the commit message to explain more thoroughly the impact of\nthis change and why it is a good idea.\n\nThanks.\n\n> Signed-off-by: Amadeusz Żołnowski <aidecoe@aidecoe.name>\n> ---\n>  git-p4.py | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-p4.py b/git-p4.py\n> index c33dece..e00cd02 100755\n> --- a/git-p4.py\n> +++ b/git-p4.py\n> @@ -2059,8 +2059,9 @@ class P4Submit(Command, P4UserMap):\n>                  sync.branch = self.branch\n>              sync.run([])\n>\n> -            rebase = P4Rebase()\n> -            rebase.rebase()\n> +            if not gitConfigBool(\"core.bare\"):\n> +                rebase = P4Rebase()\n> +                rebase.rebase()\n>\n>          else:\n>              if len(applied) == 0:\n> --\n> 2.7.0\n"},{"id":"278705","messageId":"1455919074-5683-1-git-send-email-aidecoe@aidecoe.name","threadId":"41440","inReplyTo":"CAPig+cQA4sJ2RneG8zRsUx+bDPAMYVtmhFjZx5SOGDqnsKNUaQ@mail.gmail.com","subject":"[PATCH] git-p4.py: Make submit working on bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-02-19T21:57:54Z","receivedAt":"2016-02-19T21:57:54Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"git-p4 can be successfully used from bare repository (which may act as a\nbridge between Perforce repository and pure Git repositories). After\nsubmitting changelist to Perforce, git-p4 performs unconditional rebase\nwhich obviously fails.\n\nPerform rebase only on non-bare repositories, so submit command can be\nsuccessful on bare repository.\n\nSigned-off-by: Amadeusz Żołnowski <aidecoe@aidecoe.name>\n---\n git-p4.py | 5 +++--\n 1 file changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex c33dece..e00cd02 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -2059,8 +2059,9 @@ class P4Submit(Command, P4UserMap):\n                 sync.branch = self.branch\n             sync.run([])\n \n-            rebase = P4Rebase()\n-            rebase.rebase()\n+            if not gitConfigBool(\"core.bare\"):\n+                rebase = P4Rebase()\n+                rebase.rebase()\n \n         else:\n             if len(applied) == 0:\n-- \n2.7.0\n"},{"id":"278708","messageId":"xmqq7fi0b9rt.fsf@gitster.mtv.corp.google.com","threadId":"41440","inReplyTo":"1455919074-5683-1-git-send-email-aidecoe@aidecoe.name","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-19T22:44:22Z","receivedAt":"2016-02-19T22:44:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:\n\n> git-p4 can be successfully used from bare repository (which may act as a\n> bridge between Perforce repository and pure Git repositories). After\n> submitting changelist to Perforce, git-p4 performs unconditional rebase\n> which obviously fails.\n>\n> Perform rebase only on non-bare repositories, so submit command can be\n> successful on bare repository.\n\nIt is obvious that an attempt to run rebase would fail in a bare\nrepository, and skipping it would obviously make it not fail.\n\nI think that part is well understood.\n\nWhat is unclear is what the ramification of _not_ rebasing after\nsubmitting is.\n\nIn other words, why do we have to rebase after submitting when we\nare in a non-bare repository?  There must be a reason behind it,\ni.e. \"If we do not rebase, then the repository would be in a state\nwhere future operations like X and Y do not work correctly because\nof Z\".\n\nAnd why does that same reason Z not apply when we submit from a bare\nrepository?\n\nA possible explanation might be that X and Y are operations that\nhappen only in a non-bare repository that we do not have to worry\nabout happening in a bare repository after we finish submitting.\n\nBut these X, Y and Z are left unexplained--that is what is unclear\nin the original proposed log message, and it is still unclear in the\nabove update.\n\nThanks.\n\n\n\n> Signed-off-by: Amadeusz Żołnowski <aidecoe@aidecoe.name>\n> ---\n>  git-p4.py | 5 +++--\n>  1 file changed, 3 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-p4.py b/git-p4.py\n> index c33dece..e00cd02 100755\n> --- a/git-p4.py\n> +++ b/git-p4.py\n> @@ -2059,8 +2059,9 @@ class P4Submit(Command, P4UserMap):\n>                  sync.branch = self.branch\n>              sync.run([])\n>  \n> -            rebase = P4Rebase()\n> -            rebase.rebase()\n> +            if not gitConfigBool(\"core.bare\"):\n> +                rebase = P4Rebase()\n> +                rebase.rebase()\n>  \n>          else:\n>              if len(applied) == 0:\n"},{"id":"278730","messageId":"87fuwnd4u7.fsf@freja.aidecoe.name","threadId":"41440","inReplyTo":"xmqq7fi0b9rt.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-02-20T11:00:16Z","receivedAt":"2016-02-20T11:00:16Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"Hi Junio,\n\nTo submit changes from master branch to Perforce, new commits should be\nbased on a remote branch p4/master:\n\n(1)\n                  E'---F' master\n                 /\n    A---B---C---D p4/master\n\nCommits from A to D map to Perforce changelists. These commits include\nadditional metadata in commit message which most important is changelist\nnumber.\n\nOn submit git-p4 prepares changelists for commits E'-F' and submits\nthese to Perforce repository. After this operation it syncs back remote\nbranch p4/master. This is the common part for both bare and non-bare\nrepository.\n\n(2)\n                  E'---F' master\n                 /\n    A---B---C---D---E---F p4/master\n\nIn non-bare repository git rebase is performed and it results in\nfollowing state:\n\n(3)\n    A---B---C---D---E---F p4/master, master\n\nIn bare repository this operation cannot be performed, so it remains in\nstate (2).\n\nWith special care state (2) can be transformed to state (3) with manual\nupdate of refs/heads/master with refs/remotes/p4/master.\n\nI understand that implementing rebase for bare repository is unsafe and\nit wouldn't be appreciated. Therefore we have to resort to such a\nbarbarity and git-p4 submit shouldn't attempt to perform a rebase\noperation itself. Especially because it performs other operations before\nand we end up in the intermediate state (2) anyway.\n\nIs this explanation satisfactory? If yes, I'll include it in patch\ndescription.\n\n\nKind regards,\n\n-- \nAmadeusz Żołnowski\n"},{"id":"278755","messageId":"xmqqbn7aa522.fsf@gitster.mtv.corp.google.com","threadId":"41440","inReplyTo":"87fuwnd4u7.fsf@freja.aidecoe.name","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-21T07:36:05Z","receivedAt":"2016-02-21T07:36:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:\n\n> To submit changes from master branch to Perforce, new commits should be\n> based on a remote branch p4/master:\n>\n> (1)\n>                   E'---F' master\n>                  /\n>     A---B---C---D p4/master\n>\n> Commits from A to D map to Perforce changelists. These commits include\n> additional metadata in commit message which most important is changelist\n> number.\n>\n> On submit git-p4 prepares changelists for commits E'-F' and submits\n> these to Perforce repository. After this operation it syncs back remote\n> branch p4/master. This is the common part for both bare and non-bare\n> repository.\n>\n> (2)\n>                   E'---F' master\n>                  /\n>     A---B---C---D---E---F p4/master\n>\n> In non-bare repository git rebase is performed and it results in\n> following state:\n>\n> (3)\n>     A---B---C---D---E---F p4/master, master\n\nThat is because you would want your further work to be built on top\nof F, not F'.\n\n> In bare repository this operation cannot be performed, so it remains in\n> state (2).\n\nAnd that is what made me wonder.\n\n> With special care state (2) can be transformed to state (3) with manual\n> update of refs/heads/master with refs/remotes/p4/master.\n\nWhat do you mean by transforming with special care?  Do you mean running\n\n    $ git update-ref master remotes/p4/master\n\nor does it involve something else?  Is it a fairly involved\nprocedure, I wonder if it makes sense to just silently allowing\nsubmit without rebasing, and without telling the user how to clean\nit up.\n\nAnd if it is really is the matter of update-ref, wouldn't that\nprocedure apply equally well to a submit made from a non-bare\nrepository?\n\n> I understand that implementing rebase for bare repository is unsafe and\n> it wouldn't be appreciated. Therefore we have to resort to such a\n> barbarity and git-p4 submit shouldn't attempt to perform a rebase\n> operation itself. Especially because it performs other operations before\n> and we end up in the intermediate state (2) anyway.\n>\n> Is this explanation satisfactory?\n\nNot quite yet.  It is better than no explanation, but it does not\nquite convince me (a non-git-p4 user) that it makes sense to allow\nsubmitting in a bare repository in the first place.\n\nThis is not an informed objection; I want to first understand why\ndoing this is safe and does not hurt the end users.\n"},{"id":"278959","messageId":"877fhwd1g0.fsf@freja.aidecoe.name","threadId":"41440","inReplyTo":"xmqqbn7aa522.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-02-22T18:50:23Z","receivedAt":"2016-02-22T18:50:23Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n> I wonder if it makes sense to just silently allowing submit without\n> rebasing, and without telling the user how to clean it up.\n\nIt is a good point. Maybe submit shouldn't be allowed by default at all\nFrom bare repository. What do you think about following approach?  If\ncore.base is true, then if git-p4.submitFromBare is also true then\nsubmit without performing proper rebase, but update master ref from\np4/master. If core.base is true, but git-p4.submitFromBare is false,\nabort immediately. Submitting from bare repository would require aware\ndecision from a user.\n\nKind regards,\n\n-- \nAmadeusz Żołnowski\n"},{"id":"278978","messageId":"xmqqegc33oal.fsf@gitster.mtv.corp.google.com","threadId":"41440","inReplyTo":"877fhwd1g0.fsf@freja.aidecoe.name","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-23T06:59:14Z","receivedAt":"2016-02-23T06:59:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>> I wonder if it makes sense to just silently allowing submit without\n>> rebasing, and without telling the user how to clean it up.\n>\n> It is a good point. Maybe submit shouldn't be allowed by default at all\n> From bare repository. What do you think about following approach?  If\n> core.base is true, then if git-p4.submitFromBare is also true then\n> submit without performing proper rebase, but update master ref from\n> p4/master. If core.base is true, but git-p4.submitFromBare is false,\n> abort immediately. Submitting from bare repository would require aware\n> decision from a user.\n\n(I think you meant \"bare\" where you wrote \"base\" in the above).\n\nAs a non user of git-p4, the above sounds a safe and sensible\napproach, but I'd like to hear from Luke, who has been active in\nthis area and is far more expert than I am ;-)\n\nThanks.\n"},{"id":"278997","messageId":"CAE5ih7_vBMsi+zRZRTCaO56VrOYZUR0NQ0CSSE+Do48xkJ_BwA@mail.gmail.com","threadId":"41440","inReplyTo":"xmqqegc33oal.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-02-23T12:05:34Z","receivedAt":"2016-02-23T12:05:34Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 23 February 2016 at 06:59, Junio C Hamano <gitster@pobox.com> wrote:\n> Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:\n>\n>> Junio C Hamano <gitster@pobox.com> writes:\n>>> I wonder if it makes sense to just silently allowing submit without\n>>> rebasing, and without telling the user how to clean it up.\n>>\n>> It is a good point. Maybe submit shouldn't be allowed by default at all\n>> From bare repository. What do you think about following approach?  If\n>> core.base is true, then if git-p4.submitFromBare is also true then\n>> submit without performing proper rebase, but update master ref from\n>> p4/master. If core.base is true, but git-p4.submitFromBare is false,\n>> abort immediately. Submitting from bare repository would require aware\n>> decision from a user.\n>\n> (I think you meant \"bare\" where you wrote \"base\" in the above).\n>\n> As a non user of git-p4, the above sounds a safe and sensible\n> approach, but I'd like to hear from Luke, who has been active in\n> this area and is far more expert than I am ;-)\n\nSorry, I've been travelling so not been able to reply earlier. Jetlag\nhas now kicked-in, and 4am is the perfect time to reply to this!\n\nI think it would help to understand why we're doing a git-p4 submit\nfrom a bare repo in the first place.\n\nThe usual workflow is you have a normal repo and submit from that.\n\nI'm guessing that the reason for using a bare repo is so that changes\ncan be pushed to it from several different git repos. This then saves\ndoing the initial git-p4 clone multiple times.\n\nAs Amadeusz pointed out, the submit fails:\n\n$ git p4 submit --git-dir=/path/to/bare/repo\n...\n...\nfatal: This operation must be run in a work tree\nSome files in your working directory are modified and different than\nwhat is in your index. You can use git update-index <filename> to\nbring the index up-to-date or stash away all your changes with git\nstash.\n\nIf this had actually worked, I think the next thing I would want to do\nis to rebase one or more branches in the bare repo against p4/master.\nI don't think there's any way that git-p4 can work out which branches\nwould be rebased, and nor should it.\n\nI think the approach of using a submitFromBare config variable to\nforce the user to make a choice feels a bit bogus, since they clearly\n*want* to submit from this bare repo, as otherwise they wouldn't have\ndone \"git-p4 submit\" in the first place.\n\nIt might make sense to have a command-line or config option\n(\"--skip-rebase\" ?) to tell \"submit\" to only do the submit part, and\nskip the rebase stage (and get the rebase stage to give a more useful\nerror message on a bare repo when the option isn't used). That would\nthen mean that git-p4 does not have to know if it's running in a bare\nrepo or not, and the submit-without-rebase functionality is available\nto people doing other different things not involving bare repos (which\nwe haven't though of yet) but still requiring submit without rebase.\n\nLuke\n\n>\n> Thanks.\n>\n"},{"id":"279091","messageId":"871t83cfi7.fsf@freja.aidecoe.name","threadId":"41440","inReplyTo":"CAE5ih7_vBMsi+zRZRTCaO56VrOYZUR0NQ0CSSE+Do48xkJ_BwA@mail.gmail.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-02-23T20:56:32Z","receivedAt":"2016-02-23T20:56:32Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"Hi Luke,\n\nLuke Diamand <luke@diamand.org> writes:\n> I'm guessing that the reason for using a bare repo is so that changes\n> can be pushed to it from several different git repos. This then saves\n> doing the initial git-p4 clone multiple times.\n\nI have created a Git repository acting as a bridge between Perforce and\npure Git repos. Changes pushed to master branch on this bridge repo get\nsubmitted to Perforce repository (referenced via remote p4/master).\n\n\n> If this had actually worked, I think the next thing I would want to do\n> is to rebase one or more branches in the bare repo against p4/master.\n> I don't think there's any way that git-p4 can work out which branches\n> would be rebased, and nor should it.\n\nIt actually has all information needed. It submits commits from a given\nbranch to a branch specified with --branch option (or default p4\nremote). When submitting from a non-bare repo git-p4 has the same set of\ninformation: the current branch and a branch specified with --branch (or\ndefault p4 remote).\n\n\n> I think the approach of using a submitFromBare config variable to\n> force the user to make a choice feels a bit bogus, since they clearly\n> *want* to submit from this bare repo, as otherwise they wouldn't have\n> done \"git-p4 submit\" in the first place.\n\nI agree, a good point.\n\n\n> It might make sense to have a command-line or config option\n> (\"--skip-rebase\" ?) to tell \"submit\" to only do the submit part, and\n> skip the rebase stage (and get the rebase stage to give a more useful\n> error message on a bare repo when the option isn't used). That would\n> then mean that git-p4 does not have to know if it's running in a bare\n> repo or not, and the submit-without-rebase functionality is available\n> to people doing other different things not involving bare repos (which\n> we haven't though of yet) but still requiring submit without rebase.\n\nWhile having additional --skip-rebase is a good idea, having git-p4\ndoing rebase would be more elegant for those who actually use GitP4 in\nbare repository. In message 87fuwnd4u7.fsf@freja.aidecoe.name I have\ndescribed how state of branches changes during submit. It clearly shows\nthat in case of a bare repository it ends up in undesired state.\n\nTo simplify things, why not just update ref during submit from bare\nrepository? As you have pointed out, if user invokes submit in this\ncontext he/she actually wants to submit from bare repo and probably\nknows what he/she is doing - especially if he/she reads man page. (-:\n\n\nKind regards,\n\n-- \nAmadeusz Żołnowski\n"},{"id":"279680","messageId":"CAE5ih7-rBuipoAGEnK60iidi1nYA9xWZQV6jRMHTVQe6f=cQag@mail.gmail.com","threadId":"41440","inReplyTo":"871t83cfi7.fsf@freja.aidecoe.name","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-02-28T04:26:31Z","receivedAt":"2016-02-28T04:26:31Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 23 February 2016 at 20:56, Amadeusz Żołnowski <aidecoe@aidecoe.name> wrote:\n>\n> To simplify things, why not just update ref during submit from bare\n> repository? As you have pointed out, if user invokes submit in this\n> context he/she actually wants to submit from bare repo and probably\n> knows what he/she is doing - especially if he/she reads man page. (-:\n\nWill it do something sensible if anything goes wrong?\n\nI'm thinking about what happens if you submit and one of the commits\nfails to go to P4 due to a merge conflict.\n\nBut I guess just doing an update-ref could be an OK thing to do.\nWithout actually trying it out for real though I can't be sure. It\nmight make sense to get some practical experience of how this works\nout.\n\nLuke\n"},{"id":"279732","messageId":"87si0cpnpn.fsf@freja.aidecoe.name","threadId":"41440","inReplyTo":"CAE5ih7-rBuipoAGEnK60iidi1nYA9xWZQV6jRMHTVQe6f=cQag@mail.gmail.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-02-28T20:46:44Z","receivedAt":"2016-02-28T20:46:44Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"Luke Diamand <luke@diamand.org> writes:\n\n> On 23 February 2016 at 20:56, Amadeusz Żołnowski <aidecoe@aidecoe.name> wrote:\n>>\n>> To simplify things, why not just update ref during submit from bare\n>> repository? As you have pointed out, if user invokes submit in this\n>> context he/she actually wants to submit from bare repo and probably\n>> knows what he/she is doing - especially if he/she reads man page. (-:\n>\n> Will it do something sensible if anything goes wrong?\n>\n> I'm thinking about what happens if you submit and one of the commits\n> fails to go to P4 due to a merge conflict.\n\nHandling failures in this case is a bit tricky, indeed.\n\n\n> But I guess just doing an update-ref could be an OK thing to do.\n> Without actually trying it out for real though I can't be sure. It\n> might make sense to get some practical experience of how this works\n> out.\n\nTrue. For now I have these cases covered by wrapper scripts. The minimum\nI need from git-p4 is just not to fail on git submit from bare\nrepository which is covered by patch I have submitted. If I get my\nsolution enough testing, I'd think of transforming it into patch for\ngit-p4.py as well.\n\n-- \nAmadeusz Żołnowski\n"},{"id":"279785","messageId":"CAE5ih7-q_PwF-T6nsu=FyyN9wO6o0Jcfkg=gKy5mhOXRGFZ+VA@mail.gmail.com","threadId":"41440","inReplyTo":"87si0cpnpn.fsf@freja.aidecoe.name","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2016-02-29T15:29:02Z","receivedAt":"2016-02-29T15:29:02Z","isPatch":true,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"On 28 February 2016 at 20:46, Amadeusz Żołnowski <aidecoe@aidecoe.name> wrote:\n\n>\n> True. For now I have these cases covered by wrapper scripts. The minimum\n> I need from git-p4 is just not to fail on git submit from bare\n> repository which is covered by patch I have submitted. If I get my\n> solution enough testing, I'd think of transforming it into patch for\n> git-p4.py as well.\n\nCould you change the patch to add a command-line option to suppress\nthe rebase? I think this would be a bit more obvious: instead of\nhaving some special magical behaviour kick-in on a bare repo, git-p4\njust does what it's told on the command-line.\n\nIt means that if we find another situation where we don't want to\nrebase, we don't have an ever-growing list of special-case\ncircumstances, which could become hard to make sense of in future.\nInstead, the user (who hopefully knows better) just tells git-p4 what\nto do.\n\nThanks!\nLuke\n"},{"id":"283248","messageId":"xmqqtwj6mmtu.fsf@gitster.mtv.corp.google.com","threadId":"41440","inReplyTo":"CAE5ih7-q_PwF-T6nsu=FyyN9wO6o0Jcfkg=gKy5mhOXRGFZ+VA@mail.gmail.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-12T23:25:33Z","receivedAt":"2016-04-12T23:25:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Luke Diamand <luke@diamand.org> writes:\n\n> On 28 February 2016 at 20:46, Amadeusz Żołnowski <aidecoe@aidecoe.name> wrote:\n>\n>>\n>> True. For now I have these cases covered by wrapper scripts. The minimum\n>> I need from git-p4 is just not to fail on git submit from bare\n>> repository which is covered by patch I have submitted. If I get my\n>> solution enough testing, I'd think of transforming it into patch for\n>> git-p4.py as well.\n>\n> Could you change the patch to add a command-line option to suppress\n> the rebase? I think this would be a bit more obvious: instead of\n> having some special magical behaviour kick-in on a bare repo, git-p4\n> just does what it's told on the command-line.\n>\n> It means that if we find another situation where we don't want to\n> rebase, we don't have an ever-growing list of special-case\n> circumstances, which could become hard to make sense of in future.\n> Instead, the user (who hopefully knows better) just tells git-p4 what\n> to do.\n\nHas anything happened to this topic after this?  I am wondering if I\nshould discard the topic az/p4-bare-no-rebase without prejudice.\n\nThanks.\n"},{"id":"283407","messageId":"87d1pt5k53.fsf@freja.aidecoe.name","threadId":"41440","inReplyTo":"xmqqtwj6mmtu.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-04-13T20:27:52Z","receivedAt":"2016-04-13T20:27:52Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"Hi,\n\nJunio C Hamano <gitster@pobox.com> writes:\n> Has anything happened to this topic after this?  I am wondering if I\n> should discard the topic az/p4-bare-no-rebase without prejudice.\n\nSorry, I haven't got time to take a loot at this, but I'll return to\nthat soon, OK? I'll prepare a patch with an option to skip rebase rather\nthan do it only for bare repos.\n\n-- \nAmadeusz Żołnowski\n"},{"id":"283414","messageId":"xmqqfuupji4m.fsf@gitster.mtv.corp.google.com","threadId":"41440","inReplyTo":"87d1pt5k53.fsf@freja.aidecoe.name","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-13T21:47:37Z","receivedAt":"2016-04-13T21:47:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:\n\n>> Has anything happened to this topic after this?  I am wondering if I\n>> should discard the topic az/p4-bare-no-rebase without prejudice.\n>\n> Sorry, I haven't got time to take a loot at this, but I'll return to\n> that soon, OK? I'll prepare a patch with an option to skip rebase rather\n> than do it only for bare repos.\n\nNo hurries.\n\nWith or without an option, I think the documentation needs to\nclarify when it is safe to omit rebase and why.\n"},{"id":"288643","messageId":"87fusopwnw.fsf@freja.aidecoe.name","threadId":"41440","inReplyTo":"xmqqfuupji4m.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] git-p4.py: Make submit working on bare repository","fromName":"Amadeusz Żołnowski","fromEmail":"aidecoe@aidecoe.name","sentAt":"2016-06-07T20:32:35Z","receivedAt":"2016-06-07T20:32:35Z","isPatch":true,"sender":{"key":"aidecoe@aidecoe.name","avatar":"https://gravatar.com/avatar/05d2eea6c7cf79acb630359def9f9496d03f0cc6b78b7519e453034dc0cb9582?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Amadeusz Żołnowski <aidecoe@aidecoe.name> writes:\n>\n>>> Has anything happened to this topic after this?  I am wondering if I\n>>> should discard the topic az/p4-bare-no-rebase without prejudice.\n\nI think you can discard the topic, because we're moving away from\nPerforce and while I have tested my original patch I haven't found time\nto change it to --skip-rebase option as suggested and test it.\n\nThanks,\n-- \nAmadeusz Żołnowski\n"}]}