{"thread":{"id":"22198","subject":"discussion: an option to fail git fetch if a pulled branch tip is not a fast forward of the existing remote tip?","startedAt":"2010-01-13T11:54:44Z","lastAt":"2010-01-13T17:14:26Z","messageCount":3,"participants":["Jon Seymour","Thomas Rast"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"131462","messageId":"2cfc40321001130354w626ec0fat7abdfaff9771c29f@mail.gmail.com","threadId":"22198","inReplyTo":null,"subject":"discussion: an option to fail git fetch if a pulled branch tip is not a fast forward of the existing remote tip?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-01-13T11:54:44Z","receivedAt":"2010-01-13T11:54:44Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"I spent a little while this afternoon debugging an issue where an\nupstream publisher had backtracked and published a branch tip which\nwas not a descendant of a previously published (and fetched) branch\ntip. The net result was that the backtracked changes were preserved in\nthe downstream branch once the 2nd tip was pulled.\n\nNow clearly the upstream developer should not have backtracked. That\nsaid, it would have been nice if I could have easily configured my\nporcelain to detect the backtracking condition. An option on git fetch\nthat implemented something similar to the git push check would have\nmade this easy to achieve.\n\nHas any consideration been given to such an option? Is there a\nwell-known alternative pattern for detecting this case?\n\njon.\n"},{"id":"131465","messageId":"201001131359.09613.trast@student.ethz.ch","threadId":"22198","inReplyTo":"2cfc40321001130354w626ec0fat7abdfaff9771c29f@mail.gmail.com","subject":"Re: discussion: an option to fail git fetch if a pulled branch tip is not a fast forward of the existing remote tip?","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-01-13T12:59:08Z","receivedAt":"2010-01-13T12:59:08Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Jon Seymour wrote:\n[discussion of a case of branch rewriting, called \"backtracking\" here]\n> Now clearly the upstream developer should not have backtracked. That\n> said, it would have been nice if I could have easily configured my\n> porcelain to detect the backtracking condition. An option on git fetch\n> that implemented something similar to the git push check would have\n> made this easy to achieve.\n\nThis is an instance of a non-fast-foward update, which is indicated by\nthe little \"+\" in git-fetch's output.  E.g., fetching git.git a moment\nago gave me\n\n>From git://git.kernel.org/pub/scm/git/git\n   fbb9971..8efa5f6  maint      -> origin/maint\n   c0eb604..054d2fa  master     -> origin/master\n   e295b7f..e84eab0  next       -> origin/next\n + 10659b7...6a048fc pu         -> origin/pu  (forced update)\n\nwhich means that the 'pu' branch was a non-fast-forward update.\n\nIf you do not want to rely on checking the results manually, you can\nedit the remote configuration.  Normally, it will look like\n\n[remote \"origin\"]\n        url = git://git.kernel.org/pub/scm/git/git.git\n        fetch = +refs/heads/*:refs/remotes/origin/*\n\nNote the \"+\" in the 'fetch' line, which means \"allow non-fast-forward\nupdates\".  Removing the + (leaving the rest intact) results in\n\n>From git://git.kernel.org/pub/scm/git/git\n ! [rejected]        pu         -> origin/pu  (non-fast-forward)\n\nYou can then manually add lines _with_ the \"+\" for branches where you\ndo want to allow non-ff updates, e.g., for git.git I might say\n\n[remote \"origin\"]\n        url = git://git.kernel.org/pub/scm/git/git.git\n        fetch = +refs/heads/pu:refs/remotes/origin/pu\n        fetch = refs/heads/*:refs/remotes/origin/*\n\nsince only 'pu' will be rewritten regularly. ('next' gets the\noccasional treatment too, so that config would not be very\nfutureproof.)\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"131521","messageId":"230F8BFF-7F59-47DB-9E97-D8E081D2597B@gmail.com","threadId":"22198","inReplyTo":"201001131359.09613.trast@student.ethz.ch","subject":"Re: discussion: an option to fail git fetch if a pulled branch tip is not a fast forward of the existing remote tip?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2010-01-13T17:14:26Z","receivedAt":"2010-01-13T17:14:26Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Thomas,\n\nAh - thanks for your very helpful response!\n\njon.\n\nOn 13/01/2010, at 23:59, Thomas Rast <trast@student.ethz.ch> wrote:\n\n> Jon Seymour wrote:\n> [discussion of a case of branch rewriting, called \"backtracking\" here]\n>> Now clearly the upstream developer should not have backtracked. That\n>> said, it would have been nice if I could have easily configured my\n>> porcelain to detect the backtracking condition. An option on git  \n>> fetch\n>> that implemented something similar to the git push check would have\n>> made this easy to achieve.\n>\n> This is an instance of a non-fast-foward update, which is indicated by\n> the little \"+\" in git-fetch's output.  E.g., fetching git.git a moment\n> ago gave me\n>\n> From git://git.kernel.org/pub/scm/git/git\n>   fbb9971..8efa5f6  maint      -> origin/maint\n>   c0eb604..054d2fa  master     -> origin/master\n>   e295b7f..e84eab0  next       -> origin/next\n> + 10659b7...6a048fc pu         -> origin/pu  (forced update)\n>\n> which means that the 'pu' branch was a non-fast-forward update.\n>\n> If you do not want to rely on checking the results manually, you can\n> edit the remote configuration.  Normally, it will look like\n>\n> [remote \"origin\"]\n>        url = git://git.kernel.org/pub/scm/git/git.git\n>        fetch = +refs/heads/*:refs/remotes/origin/*\n>\n> Note the \"+\" in the 'fetch' line, which means \"allow non-fast-forward\n> updates\".  Removing the + (leaving the rest intact) results in\n>\n> From git://git.kernel.org/pub/scm/git/git\n> ! [rejected]        pu         -> origin/pu  (non-fast-forward)\n>\n> You can then manually add lines _with_ the \"+\" for branches where you\n> do want to allow non-ff updates, e.g., for git.git I might say\n>\n> [remote \"origin\"]\n>        url = git://git.kernel.org/pub/scm/git/git.git\n>        fetch = +refs/heads/pu:refs/remotes/origin/pu\n>        fetch = refs/heads/*:refs/remotes/origin/*\n>\n> since only 'pu' will be rewritten regularly. ('next' gets the\n> occasional treatment too, so that config would not be very\n> futureproof.)\n>\n> -- \n> Thomas Rast\n> trast@{inf,student}.ethz.ch\n"}]}