Merge branch 'master' into next

* master:
  Update clone/fetch documentation with --depth (shallow clone) option
  Strongly discourage --update-head-ok in fetch-options documentation.
  Documentation: remove master:origin example from pull-fetch-param.txt
  Documentation: update git-pull.txt for new clone behavior
  git-fetch: remove .keep file at the end.
  fail pull/merge early in the middle of conflicted merge
  Update send-pack pipeline documentation.
  git-svn: t/t91??-*: optimize the tests a bit
  git-svn: t/t9100-git-svn-basic: remove old check for NO_SYMLINK
  git-svn: remove svnadmin dependency from the tests
This commit is contained in:
Junio C Hamano
2007-01-01 15:09:06 -08:00
13 changed files with 141 additions and 212 deletions

View File

@@ -36,6 +36,13 @@
-u, \--update-head-ok::
By default `git-fetch` refuses to update the head which
corresponds to the current branch. This flag disables the
check. Note that fetching into the current branch will not
update the index and working directory, so use it with care.
check. This is purely for the internal use for `git-pull`
to communicate with `git-fetch`, and unless you are
implementing your own Porcelain you are not supposed to
use it.
\--depth=<depth>::
Deepen the history of a 'shallow' repository created by
`git clone` with `--depth=<depth>` option (see gitlink:git-clone[1])
by the specified number of commits.

View File

@@ -11,7 +11,7 @@ SYNOPSIS
[verse]
'git-clone' [--template=<template_directory>] [-l [-s]] [-q] [-n] [--bare]
[-o <name>] [-u <upload-pack>] [--reference <repository>]
<repository> [<directory>]
[--depth=<depth>] <repository> [<directory>]
DESCRIPTION
-----------
@@ -31,6 +31,7 @@ the remote branch heads under `$GIT_DIR/refs/remotes/origin` and
by initializing `remote.origin.url` and `remote.origin.fetch`
configuration variables.
OPTIONS
-------
--local::
@@ -95,6 +96,15 @@ OPTIONS
if unset the templates are taken from the installation
defined default, typically `/usr/share/git-core/templates`.
--depth=<depth>::
Create a 'shallow' clone with a history truncated to the
specified number of revs. A shallow repository has
number of limitations (you cannot clone or fetch from
it, nor push from nor into it), but is adequate if you
want to only look at near the tip of a large project
with a long history, and would want to send in a fixes
as patches.
<repository>::
The (possibly remote) repository to clone from. It can
be any URL git-fetch supports.

View File

@@ -37,17 +37,27 @@ EXAMPLES
--------
git pull, git pull origin::
Fetch the default head from the repository you cloned
from and merge it into your current branch.
Update the remote-tracking branches for the repository
you cloned from, then merge one of them into your
current branch. Normally the branch merged in is
the HEAD of the remote repository, but the choice is
determined by the branch.<name>.remote and
branch.<name>.merge options; see gitlink:git-repo-config[1]
for details.
git pull -s ours . obsolete::
Merge local branch `obsolete` into the current branch,
using `ours` merge strategy.
git pull origin next::
Merge into the current branch the remote branch `next`;
leaves a copy of `next` temporarily in FETCH_HEAD, but
does not update any remote-tracking branches.
git pull . fixes enhancements::
Bundle local branch `fixes` and `enhancements` on top of
the current branch, making an Octopus merge.
git pull -s ours . obsolete::
Merge local branch `obsolete` into the current branch,
using `ours` merge strategy.
git pull --no-commit . maint::
Merge local branch `maint` into the current branch, but
do not make a commit automatically. This can be used
@@ -61,48 +71,19 @@ release/version name would be acceptable.
Command line pull of multiple branches from one repository::
+
------------------------------------------------
$ cat .git/remotes/origin
URL: git://git.kernel.org/pub/scm/git/git.git
Pull: master:origin
$ git checkout master
$ git fetch origin master:origin +pu:pu maint:maint
$ git pull . origin
$ git fetch origin +pu:pu maint:tmp
$ git pull . tmp
------------------------------------------------
+
Here, a typical `.git/remotes/origin` file from a
`git-clone` operation is used in combination with
command line options to `git-fetch` to first update
multiple branches of the local repository and then
to merge the remote `origin` branch into the local
`master` branch. The local `pu` branch is updated
even if it does not result in a fast forward update.
Here, the pull can obtain its objects from the local
repository using `.`, as the previous `git-fetch` is
known to have already obtained and made available
all the necessary objects.
Pull of multiple branches from one repository using `.git/remotes` file::
This updates (or creates, as necessary) branches `pu` and `tmp`
in the local repository by fetching from the branches
(respectively) `pu` and `maint` from the remote repository.
+
------------------------------------------------
$ cat .git/remotes/origin
URL: git://git.kernel.org/pub/scm/git/git.git
Pull: master:origin
Pull: +pu:pu
Pull: maint:maint
$ git checkout master
$ git pull origin
------------------------------------------------
The `pu` branch will be updated even if it is does not
fast-forward; the others will not be.
+
Here, a typical `.git/remotes/origin` file from a
`git-clone` operation has been hand-modified to include
the branch-mapping of additional remote and local
heads directly. A single `git-pull` operation while
in the `master` branch will fetch multiple heads and
merge the remote `origin` head into the current,
local `master` branch.
The final command then merges the newly fetched `tmp` into master.
If you tried a pull which resulted in a complex conflicts and
@@ -112,7 +93,7 @@ gitlink:git-reset[1].
SEE ALSO
--------
gitlink:git-fetch[1], gitlink:git-merge[1]
gitlink:git-fetch[1], gitlink:git-merge[1], gitlink:git-repo-config[1]
Author

View File

@@ -39,10 +39,6 @@ checkout -b my-B remote-B`). Run `git fetch` to keep track of
the progress of the remote side, and when you see something new
on the remote branch, merge it into your development branch with
`git pull . remote-B`, while you are on `my-B` branch.
The common `Pull: master:origin` mapping of a remote `master`
branch to a local `origin` branch, which is then merged to a
local development branch, again typically named `master`, is made
when you run `git clone` for you to follow this pattern.
+
[NOTE]
There is a difference between listing multiple <refspec>

View File

@@ -27,86 +27,37 @@ Overall operation
Pack_objects pipeline
---------------------
This function gets one file descriptor (`out`) which is either a
This function gets one file descriptor (`fd`) which is either a
socket (over the network) or a pipe (local). What's written to
this fd goes to git-receive-pack to be unpacked.
send-pack ---> fd ---> receive-pack
It somehow forks once, but does not wait for it. I am not sure
why.
The forked child calls rev_list_generate() with that file
descriptor (while the parent closes `out` -- the child will be
the one that writes the packfile to the other end).
The function pack_objects creates a pipe and then forks. The
forked child execs pack-objects with --revs to receive revision
parameters from its standard input. This process will write the
packfile to the other end.
send-pack
|
rev-list-generate ---> fd ---> receive-pack
Then rev-list-generate forks after creates a pipe; the child
will become a pipeline "rev-list --stdin | pack-objects", which
is the rev_list() function, while the parent feeds that pipeline
the list of refs.
send-pack
|
rev-list-generate ---> fd ---> receive-pack
pack_objects() ---> fd ---> receive-pack
| ^ (pipe)
v |
rev-list
(child)
The child process, before calling rev-list, rearranges the file
descriptors:
. what it reads from rev-list-generate via pipe becomes the
stdin; this is to feed the upstream of the pipeline which will
be git-rev-list process.
. what it writes to its stdout goes to the fd connected to
receive-pack.
On the other hand, the parent process, before starting to feed
the child pipeline, closes the reading side of the pipe and fd
to receive-pack.
The child dup2's to arrange its standard output to go back to
the other end, and read its standard input to come from the
pipe. After that it exec's pack-objects. On the other hand,
the parent process, before starting to feed the child pipeline,
closes the reading side of the pipe and fd to receive-pack.
send-pack
|
rev-list-generate
pack_objects(parent)
|
v [0]
rev-list [1] ---> receive-pack
The parent then writes to the pipe and later closes it. There
is a commented out waitpid to wait for the rev-list side before
it exits, I again do not understand why.
The rev-list function further sets up a pipe and forks to run
git-rev-list piped to git-pack-objects. The child side, before
exec'ing git-pack-objects, rearranges the file descriptors:
. what it reads from the pipe becomes the stdin; this gets the
list of objects from the git-rev-list process.
. its stdout is already connected to receive-pack, so what it
generates goes there.
The parent process arranges its file descriptors before exec'ing
git-rev-list:
. its stdout is sent to the pipe to feed git-pack-objects.
. its stdin is already connected to rev-list-generate and will
read the set of refs from it.
send-pack
|
rev-list-generate
|
v [0]
git-rev-list [1] ---> [0] git-pack-objects [1] ---> receive-pack
pack-objects [0] ---> receive-pack
[jc: the pipeline was much more complex and needed documentation before
I understood an earlier bug, but now it is trivial and straightforward.]

View File

@@ -382,13 +382,22 @@ fetch_main () {
;; # we are already done.
*)
( : subshell because we muck with IFS
pack_lockfile=
IFS=" $LF"
(
git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref || echo failed "$remote"
git-fetch-pack --thin $exec $keep $shallow_depth "$remote" $rref ||
echo failed "$remote"
) |
while read sha1 remote_name
do
(
trap '
if test -n "$keepfile" && test -f "$keepfile"
then
rm -f "$keepfile"
fi
' 0
keepfile=
while read sha1 remote_name
do
case "$sha1" in
failed)
echo >&2 "Fetch failure: $remote"
@@ -397,7 +406,7 @@ fetch_main () {
pack)
continue ;;
keep)
pack_lockfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
keepfile="$GIT_OBJECT_DIRECTORY/pack/pack-$remote_name.keep"
continue ;;
esac
found=
@@ -429,8 +438,8 @@ fetch_main () {
append_fetch_head "$sha1" "$remote" \
"$remote_name" "$remote_nick" "$local_name" \
"$not_for_merge" || exit
done &&
if [ "$pack_lockfile" ]; then rm -f "$pack_lockfile"; fi
done
)
) || exit ;;
esac

View File

@@ -8,6 +8,9 @@ USAGE='[-n] [--no-commit] [--squash] [-s <strategy>] [-m=<merge-message>] <commi
. git-sh-setup
set_reflog_action "merge $*"
test -z "$(git ls-files -u)" ||
die "You are in a middle of conflicted merge."
LF='
'

View File

@@ -9,6 +9,9 @@ LONG_USAGE='Fetch one or more remote refs and merge it/them into the current HEA
. git-sh-setup
set_reflog_action "pull $*"
test -z "$(git ls-files -u)" ||
die "You are in a middle of conflicted merge."
strategy_args= no_summary= no_commit= squash=
while case "$#,$1" in 0) break ;; *,-*) ;; *) break ;; esac
do

View File

@@ -7,26 +7,10 @@ then
exit
fi
perl -e 'use SVN::Core; $SVN::Core::VERSION gt "1.1.0" or die' >/dev/null 2>&1
if test $? -ne 0
then
test_expect_success 'Perl SVN libraries not found, skipping test' :
test_done
exit
fi
GIT_DIR=$PWD/.git
GIT_SVN_DIR=$GIT_DIR/svn/git-svn
SVN_TREE=$GIT_SVN_DIR/svn-tree
svnadmin >/dev/null 2>&1
if test $? -ne 1
then
test_expect_success 'skipping git-svn tests, svnadmin not found' :
test_done
exit
fi
svn >/dev/null 2>&1
if test $? -ne 1
then
@@ -37,13 +21,24 @@ fi
svnrepo=$PWD/svnrepo
set -e
if svnadmin create --help | grep fs-type >/dev/null
perl -w -e "
use SVN::Core;
use SVN::Repos;
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
SVN::Repos::create('$svnrepo', undef, undef, undef,
{ 'fs-config' => 'fsfs'});
"
x=$?
if test $x -ne 0
then
svnadmin create --fs-type fsfs "$svnrepo"
else
svnadmin create "$svnrepo"
if test $x -eq 42; then
err='Perl SVN libraries must be >= 1.1.0'
else
err='Perl SVN libraries not found or unusable, skipping test'
fi
test_expect_success "$err" :
test_done
exit
fi
svnrepo="file://$svnrepo"

View File

@@ -24,10 +24,7 @@ test_expect_success \
mkdir import &&
cd import &&
echo foo > foo &&
if test -z '$NO_SYMLINK'
then
ln -s foo foo.link
fi
ln -s foo foo.link
mkdir -p dir/a/b/c/d/e &&
echo 'deep dir' > dir/a/b/c/d/e/file &&
mkdir bar &&
@@ -136,48 +133,43 @@ test_expect_success "$name" "
test -x '$SVN_TREE'/exec.sh"
if test -z "$NO_SYMLINK"
then
name='executable file becomes a symlink to bar/zzz (file)'
name='executable file becomes a symlink to bar/zzz (file)'
test_expect_success "$name" "
rm exec.sh &&
ln -s bar/zzz exec.sh &&
git update-index exec.sh &&
git commit -m '$name' &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
svn up '$SVN_TREE' &&
test -L '$SVN_TREE'/exec.sh"
test_expect_success "$name" "
rm exec.sh &&
ln -s bar/zzz exec.sh &&
git update-index exec.sh &&
git commit -m '$name' &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
svn up '$SVN_TREE' &&
test -L '$SVN_TREE'/exec.sh"
name='new symlink is added to a file that was also just made executable'
name='new symlink is added to a file that was also just made executable'
test_expect_success "$name" "
chmod +x bar/zzz &&
ln -s bar/zzz exec-2.sh &&
git update-index --add bar/zzz exec-2.sh &&
git commit -m '$name' &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
svn up '$SVN_TREE' &&
test -x '$SVN_TREE'/bar/zzz &&
test -L '$SVN_TREE'/exec-2.sh"
name='modify a symlink to become a file'
test_expect_success "$name" "
echo git help > help || true &&
rm exec-2.sh &&
cp help exec-2.sh &&
git update-index exec-2.sh &&
git commit -m '$name' &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
svn up '$SVN_TREE' &&
test -f '$SVN_TREE'/exec-2.sh &&
test ! -L '$SVN_TREE'/exec-2.sh &&
diff -u help $SVN_TREE/exec-2.sh"
fi
test_expect_success "$name" "
chmod +x bar/zzz &&
ln -s bar/zzz exec-2.sh &&
git update-index --add bar/zzz exec-2.sh &&
git commit -m '$name' &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
svn up '$SVN_TREE' &&
test -x '$SVN_TREE'/bar/zzz &&
test -L '$SVN_TREE'/exec-2.sh"
name='modify a symlink to become a file'
test_expect_success "$name" "
echo git help > help || true &&
rm exec-2.sh &&
cp help exec-2.sh &&
git update-index exec-2.sh &&
git commit -m '$name' &&
git-svn set-tree --find-copies-harder --rmdir \
remotes/git-svn..mybranch5 &&
svn up '$SVN_TREE' &&
test -f '$SVN_TREE'/exec-2.sh &&
test ! -L '$SVN_TREE'/exec-2.sh &&
diff -u help $SVN_TREE/exec-2.sh"
if test "$have_utf8" = t
then
@@ -203,12 +195,6 @@ test_expect_success "$name" \
git-rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
diff -u a b"
if test -n "$NO_SYMLINK"
then
test_done
exit 0
fi
name='check imported tree checksums expected tree checksums'
rm -f expected
if test "$have_utf8" = t

View File

@@ -57,13 +57,10 @@ test_expect_success 'setup some commits to svn' \
'cd test_wc &&
echo Greetings >> kw.c &&
svn commit -m "Not yet an Id" &&
svn up &&
echo Hello world >> kw.c &&
svn commit -m "Modified file, but still not yet an Id" &&
svn up &&
svn propset svn:keywords Id kw.c &&
svn commit -m "Propset Id" &&
svn up &&
svn commit -m "Propset Id"
cd ..'
test_expect_success 'initialize git-svn' "git-svn init $svnrepo"
@@ -86,8 +83,7 @@ test_expect_success "propset CR on crlf files" \
svn propset svn:eol-style CR empty &&
svn propset svn:eol-style CR crlf &&
svn propset svn:eol-style CR ne_crlf &&
svn commit -m "propset CR on crlf files" &&
svn up &&
svn commit -m "propset CR on crlf files"
cd ..'
test_expect_success 'fetch and pull latest from svn and checkout a new wc' \
@@ -111,8 +107,7 @@ cd test_wc
svn propset svn:eol-style CRLF ne_cr &&
svn propset svn:keywords Id cr &&
svn propset svn:keywords Id ne_cr &&
svn commit -m "propset CRLF on cr files" &&
svn up'
svn commit -m "propset CRLF on cr files"'
cd ..
test_expect_success 'fetch and pull latest from svn' \
'git-svn fetch && git pull . remotes/git-svn'

View File

@@ -16,25 +16,19 @@ test_expect_success 'initialize repo' "
cd wc &&
echo feedme >> branches/a/readme &&
svn commit -m hungry &&
svn up &&
cd trunk &&
svn merge -r3:4 $svnrepo/branches/a &&
svn commit -m 'merge with a' &&
cd ../.. &&
svn log -v $svnrepo &&
git-svn init -i trunk $svnrepo/trunk &&
git-svn init -i a $svnrepo/branches/a &&
git-svn init -i tags/a $svnrepo/tags/a &&
git-svn fetch -i tags/a &&
git-svn fetch -i a &&
git-svn fetch -i trunk
git-svn multi-init $svnrepo -T trunk -b branches -t tags &&
git-svn multi-fetch
"
r1=`git-rev-list remotes/trunk | tail -n1`
r2=`git-rev-list remotes/tags/a | tail -n1`
r3=`git-rev-list remotes/a | tail -n1`
r4=`git-rev-list remotes/a | head -n1`
r5=`git-rev-list remotes/trunk | head -n1`
r4=`git-rev-parse remotes/a`
r5=`git-rev-parse remotes/trunk`
test_expect_success 'test graft-branches regexes and copies' "
test -n "$r1" &&

View File

@@ -17,7 +17,6 @@ test_expect_success 'initialize repo' "
cd wc &&
echo world >> trunk/readme &&
svn commit -m 'another commit' &&
svn up &&
svn mv -m 'rename to thunk' trunk thunk &&
svn up &&
echo goodbye >> thunk/readme &&