diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 13f34d3ca2..5b4d184a73 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -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=:: + Deepen the history of a 'shallow' repository created by + `git clone` with `--depth=` option (see gitlink:git-clone[1]) + by the specified number of commits. diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt index 96523204dd..e7085fdf5f 100644 --- a/Documentation/git-clone.txt +++ b/Documentation/git-clone.txt @@ -11,7 +11,7 @@ SYNOPSIS [verse] 'git-clone' [--template=] [-l [-s]] [-q] [-n] [--bare] [-o ] [-u ] [--reference ] - [] + [--depth=] [] 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=:: + 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. + :: The (possibly remote) repository to clone from. It can be any URL git-fetch supports. diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt index 2a5aea73ba..13be992006 100644 --- a/Documentation/git-pull.txt +++ b/Documentation/git-pull.txt @@ -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..remote and + branch..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 diff --git a/Documentation/pull-fetch-param.txt b/Documentation/pull-fetch-param.txt index e852f41a32..8d4e950abc 100644 --- a/Documentation/pull-fetch-param.txt +++ b/Documentation/pull-fetch-param.txt @@ -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 diff --git a/Documentation/technical/send-pack-pipeline.txt b/Documentation/technical/send-pack-pipeline.txt index bd32aff00b..681efe4219 100644 --- a/Documentation/technical/send-pack-pipeline.txt +++ b/Documentation/technical/send-pack-pipeline.txt @@ -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.] diff --git a/git-fetch.sh b/git-fetch.sh index 8bd11f8b60..466fe59e35 100755 --- a/git-fetch.sh +++ b/git-fetch.sh @@ -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 diff --git a/git-merge.sh b/git-merge.sh index a8f673ef28..37d6288045 100755 --- a/git-merge.sh +++ b/git-merge.sh @@ -8,6 +8,9 @@ USAGE='[-n] [--no-commit] [--squash] [-s ] [-m=] /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" diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index c22fe47213..040da92756 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -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 diff --git a/t/t9101-git-svn-props.sh b/t/t9101-git-svn-props.sh index 5543b07f16..46fcec50a5 100755 --- a/t/t9101-git-svn-props.sh +++ b/t/t9101-git-svn-props.sh @@ -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' diff --git a/t/t9103-git-svn-graft-branches.sh b/t/t9103-git-svn-graft-branches.sh index 293b98f928..b5f7677021 100755 --- a/t/t9103-git-svn-graft-branches.sh +++ b/t/t9103-git-svn-graft-branches.sh @@ -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" && diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index 8d2e2fec39..400c21cd49 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -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 &&