{"thread":{"id":"7457","subject":"specifying \"fast-forward\" only in git-pull","startedAt":"2007-03-28T21:12:31Z","lastAt":"2007-03-28T21:30:07Z","messageCount":3,"participants":["David Tweed","Junio C Hamano","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"38268","messageId":"e1dab3980703281412m78c2481bj9b9f7ec885dbbe4f@mail.gmail.com","threadId":"7457","inReplyTo":null,"subject":"specifying \"fast-forward\" only in git-pull","fromName":"David Tweed","fromEmail":"david.tweed@gmail.com","sentAt":"2007-03-28T21:12:31Z","receivedAt":"2007-03-28T21:12:31Z","isPatch":false,"sender":{"key":"david.tweed@gmail.com","avatar":null},"body":"Hi, I'm looking through the documentation on git-pull and\nI see that I can specify a particular (sequence of) merge\nstrategies, but I can't see a way to say \"only do a fast\nforward, stopping if a fast forward doesn't apply\".\n(Fast-forward doesn't appear to be a named strategy,\nwhich is why I can't use it with -s). Is there a way to\ndo this?\n\nRationale: I have a repository on several machines that\nare synchronised via usb-stick. 99.9% of the time a fast\nforward is all that is needed, and for scripting the\nsynchronisation I'd like to restrict it so that only\nfast-forwards can happen automatically and everything\nelse I have to do by invoking git myself. (Somehow I managed to get\na merge that gave a weird result without me actually\nnoticing for a couple of days, which combined with\nmy chronological version scripts seemed to put new\ntrees onto an unnamed branch. I've got the repo sorted\nout now, but I want to avoid the same issue in future.)\n\nMany thanks for any help.\n-- \ncheers, dave tweed__________________________\ndavid.tweed@gmail.com\nRm 124, School of Systems Engineering, University of Reading.\nDetails are all that matters; God dwells there, and you never get to\nsee Him if you don't struggle to get them right. -- Stephen Jay Gould\n"},{"id":"38269","messageId":"7vbqidf4a8.fsf@assigned-by-dhcp.cox.net","threadId":"7457","inReplyTo":"e1dab3980703281412m78c2481bj9b9f7ec885dbbe4f@mail.gmail.com","subject":"Re: specifying \"fast-forward\" only in git-pull","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-28T21:26:39Z","receivedAt":"2007-03-28T21:26:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"David Tweed\" <david.tweed@gmail.com> writes:\n\n> Hi, I'm looking through the documentation on git-pull and\n> I see that I can specify a particular (sequence of) merge\n> strategies, but I can't see a way to say \"only do a fast\n> forward, stopping if a fast forward doesn't apply\".\n> (Fast-forward doesn't appear to be a named strategy,\n> which is why I can't use it with -s). Is there a way to\n> do this?\n>\n> Rationale: I have a repository on several machines that\n> are synchronised via usb-stick. 99.9% of the time a fast\n> forward is all that is needed, and for scripting the\n> synchronisation I'd like to restrict it so that only\n> fast-forwards can happen automatically and everything\n> else I have to do by invoking git myself.\n\nPresumably you are scripting around \"git pull\" and wondering\nif there is a way to let you say \"git pull -s ffonly $stick\".\n\nWhy don't you script around \"git fetch\" instead?\n\n\t#!/bin/sh\n \tstick=$1\n       \n\tgit fetch \"$stick\"\n        not_in_stick=$(git rev-list FETCH_HEAD..HEAD)\n        if test -z \"$not_in_stick\"\n        then\n        \t: stick fast forwards\n                git merge FETCH_HEAD\n\telse\n        \techo >&2 \"Our HEAD has things the stick does not.\"\n\t\texit 1\n\tfi\n"},{"id":"38271","messageId":"20070328213006.GO13247@spearce.org","threadId":"7457","inReplyTo":"e1dab3980703281412m78c2481bj9b9f7ec885dbbe4f@mail.gmail.com","subject":"Re: specifying \"fast-forward\" only in git-pull","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-03-28T21:30:07Z","receivedAt":"2007-03-28T21:30:07Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"David Tweed <david.tweed@gmail.com> wrote:\n> Hi, I'm looking through the documentation on git-pull and\n> I see that I can specify a particular (sequence of) merge\n> strategies, but I can't see a way to say \"only do a fast\n> forward, stopping if a fast forward doesn't apply\".\n> (Fast-forward doesn't appear to be a named strategy,\n> which is why I can't use it with -s). Is there a way to\n> do this?\n> \n> Rationale: I have a repository on several machines that\n> are synchronised via usb-stick. 99.9% of the time a fast\n> forward is all that is needed, and for scripting the\n> synchronisation I'd like to restrict it so that only\n> fast-forwards can happen automatically and everything\n> else I have to do by invoking git myself. (Somehow I managed to get\n> a merge that gave a weird result without me actually\n> noticing for a couple of days, which combined with\n> my chronological version scripts seemed to put new\n> trees onto an unnamed branch. I've got the repo sorted\n> out now, but I want to avoid the same issue in future.)\n\nIf you are running a pull automatically and want to make sure its\nstrictly a fast-forward, use something like:\n\n\tgit fetch &&\n\tb=$(git merge-base FETCH_HEAD HEAD) &&\n\ttest $b = $(git rev-parse HEAD^0) &&\n\tgit merge FETCH_HEAD\n\nThe idea here is that if the merge base of the current branch and\nthe incoming branch is the current branch, then the incoming branch\nis a superset of the current branch, and git-merge will perform\na fast-forward.\n\n-- \nShawn.\n"}]}