Commit graph

12 commits

Author SHA1 Message Date
Jeff King 19a7fcbf16 allow pull --rebase on branch yet to be born
When doing a "pull --rebase", we check to make sure that the index and
working tree are clean. The index-clean check compares the index against
HEAD. The test erroneously reports dirtiness if we don't have a HEAD yet.

In such an "unborn branch" case, by definition, a non-empty index won't
be based on whatever we are pulling down from the remote, and will lose
the local change.  Just check if $GIT_DIR/index exists and error out.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-08-12 15:50:09 -07:00
Santi Béjar d44e71261f pull: support rebased upstream + fetch + pull --rebase
You cannot do a "git pull --rebase" with a rebased upstream, if you have
already run "git fetch".  Try to behave as if the "git fetch" was not run.

In other words, find the fork point of the current branch, where
the tip of upstream branch used to be, and use it as the upstream
parameter of "git rebase".

This patch computes the fork point by walking the reflog to find the first
commit which is an ancestor of the current branch.  Maybe there are
smarter ways to compute it, but this is a straight forward implementation.

Signed-off-by: Santi Béjar <santi@agolina.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-07-19 10:29:38 -07:00
Santi Béjar a418441b4e t5520-pull: Test for rebased upstream + fetch + pull --rebase
If your upstream has rebased you can do:

git pull --rebase

but only if you haven't fetch before.

Mark this case as test_expect_failure, in a later patch it will be
changed to test_expect_success.

Signed-off-by: Santi Béjar <santi@agolina.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-07-19 10:28:50 -07:00
Santi Béjar e9460a66e0 parse-remote: support default reflist in get_remote_merge_branch
Expand get_remote_merge_branch to compute the tracking branch to merge
when called without arguments (or only the remote name). This allows
"git pull --rebase" without arguments (default upstream branch) to
work with a rebased upstream. With explicit arguments it already worked.

Also add a test to check for this case.

Signed-off-by: Santi Béjar <santi@agolina.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-06-11 19:50:34 -07:00
Junio C Hamano b0ad11ea16 pull: allow "git pull origin $something:$current_branch" into an unborn branch
Some misguided documents floating on the Net suggest this sequence:

    mkdir newdir && cd newdir
    git init
    git remote add origin $url
    git pull origin master:master

"git pull" has known about misguided "pull" that lets the underlying fetch
update the current branch for a long time.  It also has known about
"git pull origin master" into a branch yet to be born.

These two workarounds however were not aware of the existence of each
other and did not work well together.  This fixes it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-17 11:26:20 -07:00
Johannes Schindelin f9189cf8f2 pull --rebase: exit early when the working directory is dirty
When rebasing fails during "pull --rebase", you cannot just clean up the
working directory and call "pull --rebase" again, since the remote branch
was already fetched.

Therefore, die early when the working directory is dirty.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-05-22 23:05:11 -07:00
Johannes Schindelin c85c79279d pull --rebase: be cleverer with rebased upstream branches
When the upstream branch is tracked, we can detect if that branch
was rebased since it was last fetched.  Teach git to use that
information to rebase from the old remote head onto the new remote head.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-01-26 18:24:24 -08:00
Johannes Schindelin cd67e4d46b Teach 'git pull' about --rebase
When calling 'git pull' with the '--rebase' option, it performs a
fetch + rebase instead of a fetch + merge.

This behavior is more desirable than fetch + pull when a topic branch
is ready to be submitted and needs to be update.

fetch + rebase might also be considered a better workflow with shared
repositories in any case, or for contributors to a centrally managed
repository, such as WINE's.

As a convenience, you can set the default behavior for a branch by
defining the config variable branch.<name>.rebase, which is
interpreted as a bool.  This setting can be overridden on the command
line by --rebase and --no-rebase.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-11-28 17:32:23 -08:00
Junio C Hamano a6080a0a44 War on whitespace
This uses "git-apply --whitespace=strip" to fix whitespace errors that have
crept in to our source files over time.  There are a few files that need
to have trailing whitespaces (most notably, test vectors).  The results
still passes the test, and build result in Documentation/ area is unchanged.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-06-07 00:04:01 -07:00
Paolo Bonzini 9debc3241b git-fetch, git-branch: Support local --track via a special remote '.'
This patch adds support for a dummy remote '.' to avoid having
to declare a fake remote like

        [remote "local"]
                url = .
                fetch = refs/heads/*:refs/heads/*

Such a builtin remote simplifies the operation of "git-fetch",
which will populate FETCH_HEAD but will not pretend that two
repositories are in use, will not create a thin pack, and will
not perform any useless remapping of names.  The speed
improvement is around 20%, and it should improve more if
"git-fetch" is converted to a builtin.

To this end, git-parse-remote is grown with a new kind of
remote, 'builtin'.  In git-fetch.sh, we treat the builtin remote
specially in that it needs no pack/store operations.  In fact,
doing git-fetch on a builtin remote will simply populate
FETCH_HEAD appropriately.

The patch also improves of the --track/--no-track support,
extending it so that branch.<name>.remote items referring '.'
can be created.  Finally, it fixes a typo in git-checkout.sh.

Signed-off-by: Paolo Bonzini  <bonzini@gnu.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-03-16 02:10:12 -07:00
Nicolas Pitre 5c94f87e6b use 'init' instead of 'init-db' for shipped docs and tools
While 'init-db' still is and probably will always remain a valid git
command for obvious backward compatibility reasons, it would be a good
idea to move shipped tools and docs to using 'init' instead.

Signed-off-by: Nicolas Pitre <nico@cam.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2007-01-12 13:36:16 -08:00
Linus Torvalds d09e79cb1c git-pull: allow pulling into an empty repository
We used to complain that we cannot merge anything we fetched
with a local branch that does not exist yet.  Just treat the
case as a natural extension of fast forwarding and make the
local branch'es tip point at the same commit we just fetched.
After all an empty repository without an initial commit is an
ancestor of any commit.

[jc: I added a trivial test.  We've become sloppy but we should
 stick to the discipline of covering new behaviour with new
 tests. ]

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-16 23:45:48 -08:00