Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Thu, 6 Sep 2007 06:37:02 +0000 (23:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Sep 2007 06:37:02 +0000 (23:37 -0700)
* maint:
Include a git-push example for creating a remote branch
Cleanup unnecessary file modifications in t1400-update-ref
Makefile: Add cache-tree.h to the headers list
Don't allow contrib/workdir/git-new-workdir to trash existing dirs
git-apply: do not read past the end of buffer

Documentation/git-push.txt
Makefile
builtin-apply.c
contrib/workdir/git-new-workdir
t/t1400-update-ref.sh
t/t4123-apply-shrink.sh [new file with mode: 0755]
index 0dd9caf86799e1648fde8895af918f6f4806d202..7b8e075c422ba8065e746a8bb771267c4aca1d24 100644 (file)
@@ -117,6 +117,12 @@ git push origin master:satellite/master::
        the ref that matches `satellite/master` (most likely, it would
        be `refs/remotes/satellite/master`) in `origin` repository with it.
 
+git push origin master:refs/heads/experimental::
+       Create the branch `experimental` in the `origin` repository
+       by copying the current `master` branch.  This form is usually
+       needed to create a new branch in the remote repository as
+       there is no `experimental` branch to match.
+
 Author
 ------
 Written by Junio C Hamano <junkio@cox.net>, later rewritten in C
index 51af531c9a0c23dcd577bc73ccd14940ed20ae57..dace2112f903f6e5be8220deb3b1502496876bb1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -281,7 +281,7 @@ LIB_FILE=libgit.a
 XDIFF_LIB=xdiff/lib.a
 
 LIB_H = \
-       archive.h blob.h cache.h commit.h csum-file.h delta.h grep.h \
+       archive.h blob.h cache.h cache-tree.h commit.h csum-file.h delta.h grep.h \
        diff.h object.h pack.h pkt-line.h quote.h refs.h list-objects.h sideband.h \
        run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h \
        tree-walk.h log-tree.h dir.h path-list.h unpack-trees.h builtin.h \
index 25b1447901d4085bdc5b554451c5e79b72cbae12..976ec770417cba4113c4c55f5ca7a5f7b8520f1e 100644 (file)
@@ -1514,7 +1514,8 @@ static int find_offset(const char *buf, unsigned long size, const char *fragment
        }
 
        /* Exact line number? */
-       if (!memcmp(buf + start, fragment, fragsize))
+       if ((start + fragsize <= size) &&
+           !memcmp(buf + start, fragment, fragsize))
                return start;
 
        /*
index c6e154a84fb5bdd4ed456ac3fdf94c54466fc5f0..2838546d16073f29b3a87ce9126d92b0f640be5e 100755 (executable)
@@ -48,6 +48,12 @@ then
                "a complete repository."
 fi
 
+# don't recreate a workdir over an existing repository
+if test -e "$new_workdir"
+then
+       die "destination directory '$new_workdir' already exists."
+fi
+
 # make sure the the links use full paths
 git_dir=$(cd "$git_dir"; pwd)
 
index c4c0dfaab1adf7866ca82d998b6d7a040a011935..ce045b2a57c13de3ef8a01f806e3472d18bdef37 100755 (executable)
@@ -198,11 +198,9 @@ test_expect_success \
         GIT_AUTHOR_DATE="2005-05-26 23:41" \
         GIT_COMMITTER_DATE="2005-05-26 23:41" git-commit -F M -a &&
         h_OTHER=$(git rev-parse --verify HEAD) &&
-        echo FIXED >F &&
         GIT_AUTHOR_DATE="2005-05-26 23:44" \
         GIT_COMMITTER_DATE="2005-05-26 23:44" git-commit --amend &&
         h_FIXED=$(git rev-parse --verify HEAD) &&
-        echo TEST+FIXED >F &&
         echo Merged initial commit and a later commit. >M &&
         echo $h_TEST >.git/MERGE_HEAD &&
         GIT_AUTHOR_DATE="2005-05-26 23:45" \
diff --git a/t/t4123-apply-shrink.sh b/t/t4123-apply-shrink.sh
new file mode 100755 (executable)
index 0000000..984157f
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+test_description='apply a patch that is larger than the preimage'
+
+. ./test-lib.sh
+
+cat >F  <<\EOF
+1
+2
+3
+4
+5
+6
+7
+8
+999999
+A
+B
+C
+D
+E
+F
+G
+H
+I
+J
+
+EOF
+
+test_expect_success setup '
+
+       git add F &&
+       mv F G &&
+       sed -e "s/1/11/" -e "s/999999/9/" -e "s/H/HH/" <G >F &&
+       git diff >patch &&
+       sed -e "/^\$/d" <G >F &&
+       git add F
+
+'
+
+test_expect_success 'apply should fail gracefully' '
+
+       if git apply --index patch
+       then
+               echo Oops, should not have succeeded
+               false
+       else
+               status=$?
+               echo "Status was $status"
+               if test -f .git/index.lock
+               then
+                       echo Oops, should not have crashed
+                       false
+               fi
+       fi
+'
+
+test_done