{"thread":{"id":"62802","subject":"Should 'git replace' respect GIT_NAMESPACE?","startedAt":"2025-01-14T05:17:03Z","lastAt":"2025-01-15T09:21:53Z","messageCount":4,"participants":["Josh Bleecher Snyder","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"510479","messageId":"CAFAcib9rWO8WFmaAwf+1Ng85+N7O3Y=QM6wG5xEz0r4tGXJ8TQ@mail.gmail.com","threadId":"62802","inReplyTo":null,"subject":"Should 'git replace' respect GIT_NAMESPACE?","fromName":"Josh Bleecher Snyder","fromEmail":"josharian@gmail.com","sentAt":"2025-01-14T05:16:26Z","receivedAt":"2025-01-14T05:17:03Z","isPatch":false,"sender":{"key":"josharian@gmail.com","avatar":"https://gravatar.com/avatar/df58f649b62f4d66e2e635810212cb54403228630fabfa080eb5847a6f4cc01b?d=mp&s=160"},"body":"I was hoping it would, so I could have different replacements in\ndifferent namespaces, but it doesn't look like it does as of ~now:\n\n\n$ git version\ngit version 2.47.1\n\n$ GIT_NAMESPACE=foo git replace\n751eeb3b4d23c7fbde919aedde8c091f04f4f819\na9dfd084086ee4d6bf00a33b0976f28c0997457e\n\n$ git rev-parse refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\na9dfd084086ee4d6bf00a33b0976f28c0997457e\n\n$ git rev-parse\nrefs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\nrefs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\nfatal: ambiguous argument\n'refs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819':\nunknown revision or path not in the working tree.\n\n$ git log -n 1 --oneline 751eeb3b4d23c7fbde919aedde8c091f04f4f819\n751eeb3 (replaced) add go.mod\n\n$ GIT_NAMESPACE=foo git log -n 1 --oneline\n751eeb3b4d23c7fbde919aedde8c091f04f4f819\n751eeb3 (replaced) add go.mod\n\n\nIs this a bug in which case I might hope for a fix, or is it working\nas intended?\n\n-josh\n"},{"id":"510482","messageId":"CAP8UFD206mL+CYxOUKOPWFj7tX1Y79Moc7UjvH4BsLVLbAk-JA@mail.gmail.com","threadId":"62802","inReplyTo":"CAFAcib9rWO8WFmaAwf+1Ng85+N7O3Y=QM6wG5xEz0r4tGXJ8TQ@mail.gmail.com","subject":"Re: Should 'git replace' respect GIT_NAMESPACE?","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2025-01-14T08:36:38Z","receivedAt":"2025-01-14T08:36:52Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tue, Jan 14, 2025 at 6:17 AM Josh Bleecher Snyder\n<josharian@gmail.com> wrote:\n>\n> I was hoping it would, so I could have different replacements in\n> different namespaces, but it doesn't look like it does as of ~now:\n\nIt might be interesting to know what you wanted to do with different\nreplacements in different namespaces.\n\nWhen replace refs were introduced, there were discussions about\nextending replace refs to be able to have different sets of replace\nrefs used at different times, so that it would be possible to have\ndifferent \"views\" of a repository. For example there could be the\nfollowing views:\n\n  - the \"default\" or \"canonical\" view where no replace refs are used,\n  - the \"timestamp fixed\" view where some replace refs to fix\ntimestamp issues are used,\n  - the \"authorship fixed\" view where some replace refs to fix\nauthorship and committership issues are used,\n  - the \"build fixed\" view where some replace refs are used so that\nthe build work on all commits (which should help with bisecting),\n  - the \"old history\" view where some old history of the code (that\nwas not imported when Git started to be used) is linked by some\nreplace refs,\netc.\n\n> $ git version\n> git version 2.47.1\n>\n> $ GIT_NAMESPACE=foo git replace\n> 751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> a9dfd084086ee4d6bf00a33b0976f28c0997457e\n>\n> $ git rev-parse refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> a9dfd084086ee4d6bf00a33b0976f28c0997457e\n>\n> $ git rev-parse\n> refs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> refs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> fatal: ambiguous argument\n> 'refs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819':\n> unknown revision or path not in the working tree.\n>\n> $ git log -n 1 --oneline 751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> 751eeb3 (replaced) add go.mod\n>\n> $ GIT_NAMESPACE=foo git log -n 1 --oneline\n> 751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> 751eeb3 (replaced) add go.mod\n>\n> Is this a bug in which case I might hope for a fix, or is it working\n> as intended?\n\nI don't think anyone mentioned using both namespaces and replace refs\ntogether before, so it's hard to say.\n\nI think namespaces are considered a server side thing to avoid\nduplicating objects in the common case where different users have\ndifferent forks of the same original repo. And namespaces might not\neven be used much on the server side as there is the \"alternates\"\nmechanism that can be used for the same purpose. Also on the server\nside, you generally want to disable ref replacement entirely as it's\njust simpler, and most often what users want, to use the default view\nwithout any replacement. So it might just happen very rarely that\npeople want to use both namespaces and replace refs together.\n"},{"id":"510547","messageId":"CAFAcib9cJOp26J=PxU3XwmLT0hQVqCb8vcS7MdGpFd5TNVfDzw@mail.gmail.com","threadId":"62802","inReplyTo":"CAP8UFD206mL+CYxOUKOPWFj7tX1Y79Moc7UjvH4BsLVLbAk-JA@mail.gmail.com","subject":"Re: Should 'git replace' respect GIT_NAMESPACE?","fromName":"Josh Bleecher Snyder","fromEmail":"josharian@gmail.com","sentAt":"2025-01-14T22:39:55Z","receivedAt":"2025-01-14T22:40:31Z","isPatch":false,"sender":{"key":"josharian@gmail.com","avatar":"https://gravatar.com/avatar/df58f649b62f4d66e2e635810212cb54403228630fabfa080eb5847a6f4cc01b?d=mp&s=160"},"body":"> > I was hoping it would, so I could have different replacements in\n> > different namespaces, but it doesn't look like it does as of ~now:\n>\n> It might be interesting to know what you wanted to do with different\n> replacements in different namespaces.\n>\n> When replace refs were introduced, there were discussions about\n> extending replace refs to be able to have different sets of replace\n> refs used at different times, so that it would be possible to have\n> different \"views\" of a repository. For example there could be the\n> following views:\n>\n>   - the \"default\" or \"canonical\" view where no replace refs are used,\n>   - the \"timestamp fixed\" view where some replace refs to fix\n> timestamp issues are used,\n>   - the \"authorship fixed\" view where some replace refs to fix\n> authorship and committership issues are used,\n>   - the \"build fixed\" view where some replace refs are used so that\n> the build work on all commits (which should help with bisecting),\n>   - the \"old history\" view where some old history of the code (that\n> was not imported when Git started to be used) is linked by some\n> replace refs,\n> etc.\n\nThat is indeed roughly what I had in mind: a bunch of different views\nof the repo.\n\n\n> > $ git version\n> > git version 2.47.1\n> >\n> > $ GIT_NAMESPACE=foo git replace\n> > 751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> > a9dfd084086ee4d6bf00a33b0976f28c0997457e\n> >\n> > $ git rev-parse refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> > a9dfd084086ee4d6bf00a33b0976f28c0997457e\n> >\n> > $ git rev-parse\n> > refs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> > refs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> > fatal: ambiguous argument\n> > 'refs/namespaces/foo/refs/replace/751eeb3b4d23c7fbde919aedde8c091f04f4f819':\n> > unknown revision or path not in the working tree.\n> >\n> > $ git log -n 1 --oneline 751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> > 751eeb3 (replaced) add go.mod\n> >\n> > $ GIT_NAMESPACE=foo git log -n 1 --oneline\n> > 751eeb3b4d23c7fbde919aedde8c091f04f4f819\n> > 751eeb3 (replaced) add go.mod\n> >\n> > Is this a bug in which case I might hope for a fix, or is it working\n> > as intended?\n>\n> I don't think anyone mentioned using both namespaces and replace refs\n> together before, so it's hard to say.\n>\n> I think namespaces are considered a server side thing to avoid\n> duplicating objects in the common case where different users have\n> different forks of the same original repo. And namespaces might not\n> even be used much on the server side as there is the \"alternates\"\n> mechanism that can be used for the same purpose. Also on the server\n> side, you generally want to disable ref replacement entirely as it's\n> just simpler, and most often what users want, to use the default view\n> without any replacement. So it might just happen very rarely that\n> people want to use both namespaces and replace refs together.\n\nGot it. Thanks.\n\nDo you have suggestions for alternative mechanisms I might use?\n\nI want to be able to easily enable/disable a set of replace directives\nfor the purposes of running other git commands, without globally\naltering the repository. Otherwise I have to worry about locking,\ncleanup when something goes wrong, and state visibility and\nmanagement. All possible to fix, but messy compared with something\nlike namespaces.\n\n-josh\n"},{"id":"510560","messageId":"CAP8UFD1ioX4R6J+Spb2oPEeTHvUBrt62iBqvRgMNJVbp45sw_Q@mail.gmail.com","threadId":"62802","inReplyTo":"CAFAcib9cJOp26J=PxU3XwmLT0hQVqCb8vcS7MdGpFd5TNVfDzw@mail.gmail.com","subject":"Re: Should 'git replace' respect GIT_NAMESPACE?","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2025-01-15T09:21:39Z","receivedAt":"2025-01-15T09:21:53Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Tue, Jan 14, 2025 at 11:40 PM Josh Bleecher Snyder\n<josharian@gmail.com> wrote:\n\n> Do you have suggestions for alternative mechanisms I might use?\n>\n> I want to be able to easily enable/disable a set of replace directives\n> for the purposes of running other git commands, without globally\n> altering the repository. Otherwise I have to worry about locking,\n> cleanup when something goes wrong, and state visibility and\n> management. All possible to fix, but messy compared with something\n> like namespaces.\n\nThe simplest would likely be to develop a small set of shell\nscripts/commands to move or copy replace refs around. These scripts or\ncommands could use `git for-each-ref` to get replace ref information\nand then `git update-ref` to create and/or delete replace refs.\n\nFor example a 'mv-rep-refs <src> <dst>' command would move all the\nrefs under \"refs/replace/views/<src>/\" to \"refs/replace/views/<dst>/\"\nexcept if <src> or <dst> is '.' which would mean \"refs/replace/\". Then\n`mv-rep-refs build-fixes .` could activate the replace refs that fix\nthe build.\n\nAlternatively you could work on implementing a similar \"view\"\nmechanism in Git itself and submit your patches here.\n"}]}