{"thread":{"id":"20039","subject":"Re: Checking for fast-forward","startedAt":"2009-07-06T21:26:14Z","lastAt":"2009-07-08T17:36:30Z","messageCount":5,"participants":["Florian Mickler","Michael J Gruber","Lee Griffiths"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"117518","messageId":"20090706232614.32602ccc@schatten","threadId":"20039","inReplyTo":"ca4f67be0907060936v7bf7c44y4395717fff854fd4@mail.gmail.com","subject":"Re: Checking for fast-forward","fromName":"Florian Mickler","fromEmail":"florian@mickler.org","sentAt":"2009-07-06T21:26:14Z","receivedAt":"2009-07-06T21:26:14Z","isPatch":false,"sender":{"key":"florian@mickler.org","avatar":null},"body":"this is more of a git question, than smth special to msysgit. \n\n(git ml cc'd)\n\nOn Mon, 6 Jul 2009 17:36:54 +0100\nLee Griffiths <poddster@gmail.com> wrote:\n\n> \n> I have a script that checks for fast-forwarding by doing a git push\n> --dry-run. This strikes me as the wrong way to do it as it does _all_\n> of the stuff a git push would normally do i.e., packing and so on, and\n> I'm only really after the fast-forward check. Seeing as I already do a\n> git push at the end of the script (actualy two, as I do a --tags one\n> as well[1]), it seems like a big waste of time. Is there anyother way\n> to check and see if the git push would work? (I want the script to\n> avoid doing a git pull if possible).\n> \n> \n> Thanks,\n> Lee\n> \n> \n> \n> [1] I originally assumed --tags would push the data AND the tags, but\n> that doesn't seem to be the case.... Am I wrong in this?\n> \n"},{"id":"117545","messageId":"4A530594.20100@drmicha.warpmail.net","threadId":"20039","inReplyTo":"20090706232614.32602ccc@schatten","subject":"Re: Checking for fast-forward","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-07-07T08:21:40Z","receivedAt":"2009-07-07T08:21:40Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Florian Mickler venit, vidit, dixit 06.07.2009 23:26:\n> this is more of a git question, than smth special to msysgit. \n> \n> (git ml cc'd)\n> \n> On Mon, 6 Jul 2009 17:36:54 +0100\n> Lee Griffiths <poddster@gmail.com> wrote:\n> \n>>\n>> I have a script that checks for fast-forwarding by doing a git push\n>> --dry-run. This strikes me as the wrong way to do it as it does _all_\n>> of the stuff a git push would normally do i.e., packing and so on, and\n>> I'm only really after the fast-forward check. Seeing as I already do a\n>> git push at the end of the script (actualy two, as I do a --tags one\n>> as well[1]), it seems like a big waste of time. Is there anyother way\n>> to check and see if the git push would work? (I want the script to\n>> avoid doing a git pull if possible).\n\nNo. (I infer your question is how to find out whether a push is a\nfast-forward.)\n\nIf you don't know the state of the branch head in the remote repo you\nsimply cannot know whether the push will be a fast-forward.\n\nIf you know that your corresponding remote branch (say\nremotes/origin/foo) is up-to-date with the destination branch (say foo)\nin the remote repo (e.g., because you know you've fetched before and\nnobody else is allowed to push there) then you can compare your branch\nto be pushed (say foo) with your remote branch:\n\nIf $(git rev-list bar..remotes/origin/foo) is empty then the branch foo\nin the remote repo can be fast-forwarded to bar.\n\nChhers,\nMichael\n"},{"id":"117550","messageId":"20090707124657.1b0fe4df@schatten","threadId":"20039","inReplyTo":"4A530594.20100@drmicha.warpmail.net","subject":"Re: Checking for fast-forward","fromName":"Florian Mickler","fromEmail":"florian@mickler.org","sentAt":"2009-07-07T10:46:57Z","receivedAt":"2009-07-07T10:46:57Z","isPatch":false,"sender":{"key":"florian@mickler.org","avatar":null},"body":"On Tue, 07 Jul 2009 10:21:40 +0200\nMichael J Gruber <git@drmicha.warpmail.net> wrote:\n\n> If $(git rev-list bar..remotes/origin/foo) is empty then the branch\n> foo in the remote repo can be fast-forwarded to bar.\n> \n> Chhers,\n> Michael\n\nin that case you could also do \n'git cherry bar origin/foo'\n\nthat shows you all commits that are in origin/foo but not in bar. \n\nSincerely,\nFlorian\n"},{"id":"117551","messageId":"4A532B0A.5090405@drmicha.warpmail.net","threadId":"20039","inReplyTo":"20090707124657.1b0fe4df@schatten","subject":"Re: Checking for fast-forward","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2009-07-07T11:01:30Z","receivedAt":"2009-07-07T11:01:30Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Florian Mickler venit, vidit, dixit 07.07.2009 12:46:\n> On Tue, 07 Jul 2009 10:21:40 +0200\n> Michael J Gruber <git@drmicha.warpmail.net> wrote:\n> \n>> If $(git rev-list bar..remotes/origin/foo) is empty then the branch\n>> foo in the remote repo can be fast-forwarded to bar.\n>>\n>> Chhers,\n>> Michael\n> \n> in that case you could also do \n> 'git cherry bar origin/foo'\n> \n> that shows you all commits that are in origin/foo but not in bar. \n\nWell, that goes through all commits \"bar..remotes/origin/foo\" and\ncomputes patch-ids. It is porcelain. Don't use it for scripting.\n\nMichael\n"},{"id":"117624","messageId":"ca4f67be0907081036j38724491n6c4c0e9aa995ee51@mail.gmail.com","threadId":"20039","inReplyTo":"4A530594.20100@drmicha.warpmail.net","subject":"Re: Checking for fast-forward","fromName":"Lee Griffiths","fromEmail":"poddster@gmail.com","sentAt":"2009-07-08T17:36:30Z","receivedAt":"2009-07-08T17:36:30Z","isPatch":false,"sender":{"key":"poddster@gmail.com","avatar":null},"body":"Thanks for the answers :)\n\nAfter seeing that git push skips the packing (and potentially other\nthings) when doing a dry run, and given that:\n\tgit push --dry-run\ntakes 1.5s on average and that:\n\tgit fetch\n\tgit rev-list master..remotes/origin/master\nOR\n\tgit ls-remote origin refs/remotes/origin/master\n\ntake 4s on average, I think I'll stick with the dry-run & checking for\nexception method.\n\nThanks though :)\n\n2009/7/7 Michael J Gruber <git@drmicha.warpmail.net>:\n> If $(git rev-list bar..remotes/origin/foo) is empty then the branch foo\n> in the remote repo can be fast-forwarded to bar.\n"}]}