diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2007-02-07 00:08:06 +0300 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2007-02-07 00:08:06 +0300 |
commit | 7073e69e382bc8247c28859d8b0eda2612cd6b94 (patch) | |
tree | b4e0cd34461796e03686090a594c9f1ee07d9290 /t/t9300-fast-import.sh | |
parent | 63e0c8b364e334fc7cc975edf1f16fb4c89594b3 (diff) |
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/t9300-fast-import.sh')
-rwxr-xr-x | t/t9300-fast-import.sh | 80 |
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 |