summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Shawn O. Pearce <spearce@spearce.org>2007-02-06 16:08:06 -0500
committerLibravatar Shawn O. Pearce <spearce@spearce.org>2007-02-06 16:08:06 -0500
commit7073e69e382bc8247c28859d8b0eda2612cd6b94 (patch)
treeb4e0cd34461796e03686090a594c9f1ee07d9290 /t
parentSupport RFC 2822 date parsing in fast-import. (diff)
downloadtgif-7073e69e382bc8247c28859d8b0eda2612cd6b94.tar.xz
Don't do non-fastforward updates in fast-import.
If fast-import is being used to update an existing branch of a repository, the user may not want to lose commits if another process updates the same ref at the same time. For example, the user might be using fast-import to make just one or two commits against a live branch. We now perform a fast-forward check during the ref updating process. If updating a branch would cause commits in that branch to be lost, we skip over it and display the new SHA1 to standard error. This new default behavior can be overridden with `--force`, like git-push and git-fetch. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 't')
-rwxr-xr-xt/t9300-fast-import.sh80
1 files changed, 80 insertions, 0 deletions
diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
index 84b3c12a50..23a2ba78f6 100755
--- a/t/t9300-fast-import.sh
+++ b/t/t9300-fast-import.sh
@@ -276,4 +276,84 @@ test_expect_success \
'git-cat-file commit branch | sed 1,2d >actual &&
diff -u expect actual'
+###
+### series F
+###
+
+old_branch=`git-rev-parse --verify branch^0`
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/branch
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+losing things already?
+COMMIT
+
+from refs/heads/branch~1
+
+reset refs/heads/other
+from refs/heads/branch
+
+INPUT_END
+test_expect_success \
+ 'F: non-fast-forward update skips' \
+ 'if git-fast-import <input
+ then
+ echo BAD gfi did not fail
+ return 1
+ else
+ if test $old_branch = `git-rev-parse --verify branch^0`
+ then
+ : branch unaffected and failure returned
+ return 0
+ else
+ echo BAD gfi changed branch $old_branch
+ return 1
+ fi
+ fi
+ '
+test_expect_success \
+ 'F: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+
+cat >expect <<EOF
+tree `git-rev-parse branch~1^{tree}`
+parent `git-rev-parse branch~1`
+author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+
+losing things already?
+EOF
+test_expect_success \
+ 'F: verify other commit' \
+ 'git-cat-file commit other >actual &&
+ diff -u expect actual'
+
+###
+### series G
+###
+
+old_branch=`git-rev-parse --verify branch^0`
+test_tick
+cat >input <<INPUT_END
+commit refs/heads/branch
+committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+data <<COMMIT
+losing things already?
+COMMIT
+
+from refs/heads/branch~1
+
+INPUT_END
+test_expect_success \
+ 'G: non-fast-forward update forced' \
+ 'git-fast-import --force <input'
+test_expect_success \
+ 'G: verify pack' \
+ 'for p in .git/objects/pack/*.pack;do git-verify-pack $p||exit;done'
+test_expect_success \
+ 'G: branch changed, but logged' \
+ 'test $old_branch != `git-rev-parse --verify branch^0` &&
+ test $old_branch = `git-rev-parse --verify branch@{1}`'
+
test_done