git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* specifying "fast-forward" only in git-pull
@ 2007-03-28 21:12 David Tweed
  2007-03-28 21:26 ` Junio C Hamano
  2007-03-28 21:30 ` Shawn O. Pearce
  0 siblings, 2 replies; 3+ messages in thread
From: David Tweed @ 2007-03-28 21:12 UTC (permalink / raw)
  To: git

Hi, I'm looking through the documentation on git-pull and
I see that I can specify a particular (sequence of) merge
strategies, but I can't see a way to say "only do a fast
forward, stopping if a fast forward doesn't apply".
(Fast-forward doesn't appear to be a named strategy,
which is why I can't use it with -s). Is there a way to
do this?

Rationale: I have a repository on several machines that
are synchronised via usb-stick. 99.9% of the time a fast
forward is all that is needed, and for scripting the
synchronisation I'd like to restrict it so that only
fast-forwards can happen automatically and everything
else I have to do by invoking git myself. (Somehow I managed to get
a merge that gave a weird result without me actually
noticing for a couple of days, which combined with
my chronological version scripts seemed to put new
trees onto an unnamed branch. I've got the repo sorted
out now, but I want to avoid the same issue in future.)

Many thanks for any help.
-- 
cheers, dave tweed__________________________
david.tweed@gmail.com
Rm 124, School of Systems Engineering, University of Reading.
Details are all that matters; God dwells there, and you never get to
see Him if you don't struggle to get them right. -- Stephen Jay Gould

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: specifying "fast-forward" only in git-pull
  2007-03-28 21:12 specifying "fast-forward" only in git-pull David Tweed
@ 2007-03-28 21:26 ` Junio C Hamano
  2007-03-28 21:30 ` Shawn O. Pearce
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2007-03-28 21:26 UTC (permalink / raw)
  To: David Tweed; +Cc: git

"David Tweed" <david.tweed@gmail.com> writes:

> Hi, I'm looking through the documentation on git-pull and
> I see that I can specify a particular (sequence of) merge
> strategies, but I can't see a way to say "only do a fast
> forward, stopping if a fast forward doesn't apply".
> (Fast-forward doesn't appear to be a named strategy,
> which is why I can't use it with -s). Is there a way to
> do this?
>
> Rationale: I have a repository on several machines that
> are synchronised via usb-stick. 99.9% of the time a fast
> forward is all that is needed, and for scripting the
> synchronisation I'd like to restrict it so that only
> fast-forwards can happen automatically and everything
> else I have to do by invoking git myself.

Presumably you are scripting around "git pull" and wondering
if there is a way to let you say "git pull -s ffonly $stick".

Why don't you script around "git fetch" instead?

	#!/bin/sh
 	stick=$1
       
	git fetch "$stick"
        not_in_stick=$(git rev-list FETCH_HEAD..HEAD)
        if test -z "$not_in_stick"
        then
        	: stick fast forwards
                git merge FETCH_HEAD
	else
        	echo >&2 "Our HEAD has things the stick does not."
		exit 1
	fi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: specifying "fast-forward" only in git-pull
  2007-03-28 21:12 specifying "fast-forward" only in git-pull David Tweed
  2007-03-28 21:26 ` Junio C Hamano
@ 2007-03-28 21:30 ` Shawn O. Pearce
  1 sibling, 0 replies; 3+ messages in thread
From: Shawn O. Pearce @ 2007-03-28 21:30 UTC (permalink / raw)
  To: David Tweed; +Cc: git

David Tweed <david.tweed@gmail.com> wrote:
> Hi, I'm looking through the documentation on git-pull and
> I see that I can specify a particular (sequence of) merge
> strategies, but I can't see a way to say "only do a fast
> forward, stopping if a fast forward doesn't apply".
> (Fast-forward doesn't appear to be a named strategy,
> which is why I can't use it with -s). Is there a way to
> do this?
> 
> Rationale: I have a repository on several machines that
> are synchronised via usb-stick. 99.9% of the time a fast
> forward is all that is needed, and for scripting the
> synchronisation I'd like to restrict it so that only
> fast-forwards can happen automatically and everything
> else I have to do by invoking git myself. (Somehow I managed to get
> a merge that gave a weird result without me actually
> noticing for a couple of days, which combined with
> my chronological version scripts seemed to put new
> trees onto an unnamed branch. I've got the repo sorted
> out now, but I want to avoid the same issue in future.)

If you are running a pull automatically and want to make sure its
strictly a fast-forward, use something like:

	git fetch &&
	b=$(git merge-base FETCH_HEAD HEAD) &&
	test $b = $(git rev-parse HEAD^0) &&
	git merge FETCH_HEAD

The idea here is that if the merge base of the current branch and
the incoming branch is the current branch, then the incoming branch
is a superset of the current branch, and git-merge will perform
a fast-forward.

-- 
Shawn.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-03-28 21:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-28 21:12 specifying "fast-forward" only in git-pull David Tweed
2007-03-28 21:26 ` Junio C Hamano
2007-03-28 21:30 ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).