* [PATCH v5 0/8] Improve git-pull test coverage
@ 2015-05-29 11:44 Paul Tan
2015-05-29 11:44 ` [PATCH v5 1/8] t5520: prevent field splitting in content comparisons Paul Tan
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan
This is a re-roll of [1].
This patch series improves test coverage of git-pull.sh, and is part of my
GSoC project to rewrite git-pull into a builtin. Improving test coverage
helps to prevent regressions that could occur due to the rewrite.
Thanks Junio, Johannes and Stefan for the reviews last round.
[1] http://thread.gmane.org/gmane.comp.version-control.git/269236
Paul Tan (8):
t5520: prevent field splitting in content comparisons
t5520: test no merge candidates cases
t5520: test for failure if index has unresolved entries
t5520: test work tree fast-forward when fetch updates head
t5520: test --rebase with multiple branches
t5520: test --rebase failure on unborn branch with index
t5521: test --dry-run does not make any changes
t5520: check reflog action in fast-forward merge
t/t5520-pull.sh | 198 +++++++++++++++++++++++++++++++++++++++---------
t/t5521-pull-options.sh | 13 ++++
2 files changed, 175 insertions(+), 36 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v5 1/8] t5520: prevent field splitting in content comparisons
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 11:44 ` [PATCH v5 2/8] t5520: test no merge candidates cases Paul Tan
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan
Many tests in t5520 used the following to test the contents of files:
test `cat file` = expected
or
test $(cat file) = expected
These 2 forms, however, will be affected by field splitting and,
depending on the value of $IFS, may be split into multiple arguments,
making the test fail in mysterious ways.
Replace the above 2 forms with:
test "$(cat file)" = expected
as quoting the command substitution will prevent field splitting.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
t/t5520-pull.sh | 70 ++++++++++++++++++++++++++++-----------------------------
1 file changed, 35 insertions(+), 35 deletions(-)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 7efd45b..5e4db67 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -93,9 +93,9 @@ test_expect_success 'test . as a remote' '
echo updated >file &&
git commit -a -m updated &&
git checkout copy &&
- test `cat file` = file &&
+ test "$(cat file)" = file &&
git pull &&
- test `cat file` = updated
+ test "$(cat file)" = updated
'
test_expect_success 'the default remote . should not break explicit pull' '
@@ -104,9 +104,9 @@ test_expect_success 'the default remote . should not break explicit pull' '
git commit -a -m modified &&
git checkout copy &&
git reset --hard HEAD^ &&
- test `cat file` = file &&
+ test "$(cat file)" = file &&
git pull . second &&
- test `cat file` = modified
+ test "$(cat file)" = modified
'
test_expect_success '--rebase' '
@@ -119,23 +119,23 @@ test_expect_success '--rebase' '
git commit -m "new file" &&
git tag before-rebase &&
git pull --rebase . copy &&
- test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
- test new = $(git show HEAD:file2)
+ test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+ test new = "$(git show HEAD:file2)"
'
test_expect_success 'pull.rebase' '
git reset --hard before-rebase &&
test_config pull.rebase true &&
git pull . copy &&
- test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
- test new = $(git show HEAD:file2)
+ test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+ test new = "$(git show HEAD:file2)"
'
test_expect_success 'branch.to-rebase.rebase' '
git reset --hard before-rebase &&
test_config branch.to-rebase.rebase true &&
git pull . copy &&
- test $(git rev-parse HEAD^) = $(git rev-parse copy) &&
- test new = $(git show HEAD:file2)
+ test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
+ test new = "$(git show HEAD:file2)"
'
test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
@@ -143,8 +143,8 @@ test_expect_success 'branch.to-rebase.rebase should override pull.rebase' '
test_config pull.rebase true &&
test_config branch.to-rebase.rebase false &&
git pull . copy &&
- test $(git rev-parse HEAD^) != $(git rev-parse copy) &&
- test new = $(git show HEAD:file2)
+ test "$(git rev-parse HEAD^)" != "$(git rev-parse copy)" &&
+ test new = "$(git show HEAD:file2)"
'
# add a feature branch, keep-merge, that is merged into master, so the
@@ -163,33 +163,33 @@ test_expect_success 'pull.rebase=false create a new merge commit' '
git reset --hard before-preserve-rebase &&
test_config pull.rebase false &&
git pull . copy &&
- test $(git rev-parse HEAD^1) = $(git rev-parse before-preserve-rebase) &&
- test $(git rev-parse HEAD^2) = $(git rev-parse copy) &&
- test file3 = $(git show HEAD:file3.t)
+ test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
+ test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
+ test file3 = "$(git show HEAD:file3.t)"
'
test_expect_success 'pull.rebase=true flattens keep-merge' '
git reset --hard before-preserve-rebase &&
test_config pull.rebase true &&
git pull . copy &&
- test $(git rev-parse HEAD^^) = $(git rev-parse copy) &&
- test file3 = $(git show HEAD:file3.t)
+ test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+ test file3 = "$(git show HEAD:file3.t)"
'
test_expect_success 'pull.rebase=1 is treated as true and flattens keep-merge' '
git reset --hard before-preserve-rebase &&
test_config pull.rebase 1 &&
git pull . copy &&
- test $(git rev-parse HEAD^^) = $(git rev-parse copy) &&
- test file3 = $(git show HEAD:file3.t)
+ test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+ test file3 = "$(git show HEAD:file3.t)"
'
test_expect_success 'pull.rebase=preserve rebases and merges keep-merge' '
git reset --hard before-preserve-rebase &&
test_config pull.rebase preserve &&
git pull . copy &&
- test $(git rev-parse HEAD^^) = $(git rev-parse copy) &&
- test $(git rev-parse HEAD^2) = $(git rev-parse keep-merge)
+ test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+ test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
'
test_expect_success 'pull.rebase=invalid fails' '
@@ -202,25 +202,25 @@ test_expect_success '--rebase=false create a new merge commit' '
git reset --hard before-preserve-rebase &&
test_config pull.rebase true &&
git pull --rebase=false . copy &&
- test $(git rev-parse HEAD^1) = $(git rev-parse before-preserve-rebase) &&
- test $(git rev-parse HEAD^2) = $(git rev-parse copy) &&
- test file3 = $(git show HEAD:file3.t)
+ test "$(git rev-parse HEAD^1)" = "$(git rev-parse before-preserve-rebase)" &&
+ test "$(git rev-parse HEAD^2)" = "$(git rev-parse copy)" &&
+ test file3 = "$(git show HEAD:file3.t)"
'
test_expect_success '--rebase=true rebases and flattens keep-merge' '
git reset --hard before-preserve-rebase &&
test_config pull.rebase preserve &&
git pull --rebase=true . copy &&
- test $(git rev-parse HEAD^^) = $(git rev-parse copy) &&
- test file3 = $(git show HEAD:file3.t)
+ test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+ test file3 = "$(git show HEAD:file3.t)"
'
test_expect_success '--rebase=preserve rebases and merges keep-merge' '
git reset --hard before-preserve-rebase &&
test_config pull.rebase true &&
git pull --rebase=preserve . copy &&
- test $(git rev-parse HEAD^^) = $(git rev-parse copy) &&
- test $(git rev-parse HEAD^2) = $(git rev-parse keep-merge)
+ test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+ test "$(git rev-parse HEAD^2)" = "$(git rev-parse keep-merge)"
'
test_expect_success '--rebase=invalid fails' '
@@ -232,8 +232,8 @@ test_expect_success '--rebase overrides pull.rebase=preserve and flattens keep-m
git reset --hard before-preserve-rebase &&
test_config pull.rebase preserve &&
git pull --rebase . copy &&
- test $(git rev-parse HEAD^^) = $(git rev-parse copy) &&
- test file3 = $(git show HEAD:file3.t)
+ test "$(git rev-parse HEAD^^)" = "$(git rev-parse copy)" &&
+ test file3 = "$(git show HEAD:file3.t)"
'
test_expect_success '--rebase with rebased upstream' '
@@ -250,7 +250,7 @@ test_expect_success '--rebase with rebased upstream' '
git tag to-rebase-orig &&
git pull --rebase me copy &&
test "conflicting modification" = "$(cat file)" &&
- test file = $(cat file2)
+ test file = "$(cat file2)"
'
@@ -261,7 +261,7 @@ test_expect_success '--rebase with rebased default upstream' '
git reset --hard to-rebase-orig &&
git pull --rebase &&
test "conflicting modification" = "$(cat file)" &&
- test file = $(cat file2)
+ test file = "$(cat file2)"
'
@@ -282,7 +282,7 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
git checkout to-rebase &&
git update-ref refs/remotes/me/copy copy^ &&
- COPY=$(git rev-parse --verify me/copy) &&
+ COPY="$(git rev-parse --verify me/copy)" &&
git rebase --onto $COPY copy &&
test_config branch.to-rebase.remote me &&
test_config branch.to-rebase.merge refs/heads/copy &&
@@ -290,10 +290,10 @@ test_expect_success 'pull --rebase dies early with dirty working directory' '
echo dirty >> file &&
git add file &&
test_must_fail git pull &&
- test $COPY = $(git rev-parse --verify me/copy) &&
+ test "$COPY" = "$(git rev-parse --verify me/copy)" &&
git checkout HEAD -- file &&
git pull &&
- test $COPY != $(git rev-parse --verify me/copy)
+ test "$COPY" != "$(git rev-parse --verify me/copy)"
'
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 2/8] t5520: test no merge candidates cases
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
2015-05-29 11:44 ` [PATCH v5 1/8] t5520: prevent field splitting in content comparisons Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 11:44 ` [PATCH v5 3/8] t5520: test for failure if index has unresolved entries Paul Tan
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan, Jeff King
a8c9bef (pull: improve advice for unconfigured error case, 2009-10-05)
fully established the current advices given by git-pull for the
different cases where git-fetch will not have anything marked for merge:
1. We fetched from a specific remote, and a refspec was given, but it
ended up not fetching anything. This is usually because the user
provided a wildcard refspec which had no matches on the remote end.
2. We fetched from a non-default remote, but didn't specify a branch to
merge. We can't use the configured one because it applies to the
default remote, and thus the user must specify the branches to merge.
3. We fetched from the branch's or repo's default remote, but:
a. We are not on a branch, so there will never be a configured branch
to merge with.
b. We are on a branch, but there is no configured branch to merge
with.
4. We fetched from the branch's or repo's default remote, but the
configured branch to merge didn't get fetched (either it doesn't
exist, or wasn't part of the configured fetch refspec)
Implement tests for the above 5 cases to ensure that the correct code
paths are triggered for each of these cases.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
t/t5520-pull.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 5e4db67..4a2c0a1 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -109,6 +109,61 @@ test_expect_success 'the default remote . should not break explicit pull' '
test "$(cat file)" = modified
'
+test_expect_success 'fail if wildcard spec does not match any refs' '
+ git checkout -b test copy^ &&
+ test_when_finished "git checkout -f copy && git branch -D test" &&
+ test "$(cat file)" = file &&
+ test_must_fail git pull . "refs/nonexisting1/*:refs/nonexisting2/*" 2>err &&
+ test_i18ngrep "no candidates for merging" err &&
+ test "$(cat file)" = file
+'
+
+test_expect_success 'fail if no branches specified with non-default remote' '
+ git remote add test_remote . &&
+ test_when_finished "git remote remove test_remote" &&
+ git checkout -b test copy^ &&
+ test_when_finished "git checkout -f copy && git branch -D test" &&
+ test "$(cat file)" = file &&
+ test_config branch.test.remote origin &&
+ test_must_fail git pull test_remote 2>err &&
+ test_i18ngrep "specify a branch on the command line" err &&
+ test "$(cat file)" = file
+'
+
+test_expect_success 'fail if not on a branch' '
+ git remote add origin . &&
+ test_when_finished "git remote remove origin" &&
+ git checkout HEAD^ &&
+ test_when_finished "git checkout -f copy" &&
+ test "$(cat file)" = file &&
+ test_must_fail git pull 2>err &&
+ test_i18ngrep "not currently on a branch" err &&
+ test "$(cat file)" = file
+'
+
+test_expect_success 'fail if no configuration for current branch' '
+ git remote add test_remote . &&
+ test_when_finished "git remote remove test_remote" &&
+ git checkout -b test copy^ &&
+ test_when_finished "git checkout -f copy && git branch -D test" &&
+ test_config branch.test.remote test_remote &&
+ test "$(cat file)" = file &&
+ test_must_fail git pull 2>err &&
+ test_i18ngrep "no tracking information" err &&
+ test "$(cat file)" = file
+'
+
+test_expect_success 'fail if upstream branch does not exist' '
+ git checkout -b test copy^ &&
+ test_when_finished "git checkout -f copy && git branch -D test" &&
+ test_config branch.test.remote . &&
+ test_config branch.test.merge refs/heads/nonexisting &&
+ test "$(cat file)" = file &&
+ test_must_fail git pull 2>err &&
+ test_i18ngrep "no such ref was fetched" err &&
+ test "$(cat file)" = file
+'
+
test_expect_success '--rebase' '
git branch to-rebase &&
echo modified again > file &&
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 3/8] t5520: test for failure if index has unresolved entries
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
2015-05-29 11:44 ` [PATCH v5 1/8] t5520: prevent field splitting in content comparisons Paul Tan
2015-05-29 11:44 ` [PATCH v5 2/8] t5520: test no merge candidates cases Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 11:44 ` [PATCH v5 4/8] t5520: test work tree fast-forward when fetch updates head Paul Tan
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan, Matthieu Moy
Commit d38a30d (Be more user-friendly when refusing to do something
because of conflict., 2010-01-12) introduced code paths to git-pull
which will error out with user-friendly advices if the user is in the
middle of a merge or has unmerged files.
Implement tests to ensure that git-pull will not run, and will print
these advices, if the user is in the middle of a merge or has unmerged
files in the index.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
Notes:
v5:
* use "test_commit"
t/t5520-pull.sh | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 4a2c0a1..265c693 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -164,6 +164,25 @@ test_expect_success 'fail if upstream branch does not exist' '
test "$(cat file)" = file
'
+test_expect_success 'fail if the index has unresolved entries' '
+ git checkout -b third second^ &&
+ test_when_finished "git checkout -f copy && git branch -D third" &&
+ test "$(cat file)" = file &&
+ test_commit modified2 file &&
+ test -z "$(git ls-files -u)" &&
+ test_must_fail git pull . second &&
+ test -n "$(git ls-files -u)" &&
+ cp file expected &&
+ test_must_fail git pull . second 2>err &&
+ test_i18ngrep "Pull is not possible because you have unmerged files" err &&
+ test_cmp expected file &&
+ git add file &&
+ test -z "$(git ls-files -u)" &&
+ test_must_fail git pull . second 2>err &&
+ test_i18ngrep "You have not concluded your merge" err &&
+ test_cmp expected file
+'
+
test_expect_success '--rebase' '
git branch to-rebase &&
echo modified again > file &&
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 4/8] t5520: test work tree fast-forward when fetch updates head
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
` (2 preceding siblings ...)
2015-05-29 11:44 ` [PATCH v5 3/8] t5520: test for failure if index has unresolved entries Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 11:44 ` [PATCH v5 5/8] t5520: test --rebase with multiple branches Paul Tan
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan, Junio C Hamano
Since b10ac50 (Fix pulling into the same branch., 2005-08-25), git-pull,
upon detecting that git-fetch updated the current head, will
fast-forward the working tree to the updated head commit.
Implement tests to ensure that the fast-forward occurs in such a case,
as well as to ensure that the user-friendly advice is printed upon
failure.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
t/t5520-pull.sh | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 265c693..872d765 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -183,6 +183,27 @@ test_expect_success 'fail if the index has unresolved entries' '
test_cmp expected file
'
+test_expect_success 'fast-forwards working tree if branch head is updated' '
+ git checkout -b third second^ &&
+ test_when_finished "git checkout -f copy && git branch -D third" &&
+ test "$(cat file)" = file &&
+ git pull . second:third 2>err &&
+ test_i18ngrep "fetch updated the current branch head" err &&
+ test "$(cat file)" = modified &&
+ test "$(git rev-parse third)" = "$(git rev-parse second)"
+'
+
+test_expect_success 'fast-forward fails with conflicting work tree' '
+ git checkout -b third second^ &&
+ test_when_finished "git checkout -f copy && git branch -D third" &&
+ test "$(cat file)" = file &&
+ echo conflict >file &&
+ test_must_fail git pull . second:third 2>err &&
+ test_i18ngrep "Cannot fast-forward your working tree" err &&
+ test "$(cat file)" = conflict &&
+ test "$(git rev-parse third)" = "$(git rev-parse second)"
+'
+
test_expect_success '--rebase' '
git branch to-rebase &&
echo modified again > file &&
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 5/8] t5520: test --rebase with multiple branches
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
` (3 preceding siblings ...)
2015-05-29 11:44 ` [PATCH v5 4/8] t5520: test work tree fast-forward when fetch updates head Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 11:44 ` [PATCH v5 6/8] t5520: test --rebase failure on unborn branch with index Paul Tan
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan, Jay Soffian
Since rebasing on top of multiple upstream branches does not make sense,
since 51b2ead (disallow providing multiple upstream branches to rebase,
pull --rebase, 2009-02-18), git-pull explicitly disallowed specifying
multiple branches in the rebase case.
Implement tests to ensure that git-pull fails and prints out the
user-friendly error message in such a case.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
t/t5520-pull.sh | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 872d765..90728e0 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -217,6 +217,15 @@ test_expect_success '--rebase' '
test "$(git rev-parse HEAD^)" = "$(git rev-parse copy)" &&
test new = "$(git show HEAD:file2)"
'
+
+test_expect_success '--rebase fails with multiple branches' '
+ git reset --hard before-rebase &&
+ test_must_fail git pull --rebase . copy master 2>err &&
+ test "$(git rev-parse HEAD)" = "$(git rev-parse before-rebase)" &&
+ test_i18ngrep "Cannot rebase onto multiple branches" err &&
+ test modified = "$(git show HEAD:file)"
+'
+
test_expect_success 'pull.rebase' '
git reset --hard before-rebase &&
test_config pull.rebase true &&
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 6/8] t5520: test --rebase failure on unborn branch with index
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
` (4 preceding siblings ...)
2015-05-29 11:44 ` [PATCH v5 5/8] t5520: test --rebase with multiple branches Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 11:44 ` [PATCH v5 7/8] t5521: test --dry-run does not make any changes Paul Tan
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan, Jeff King
Commit 19a7fcb (allow pull --rebase on branch yet to be born,
2009-08-11) special cases git-pull on an unborn branch in a different
code path such that git-pull --rebase is still valid even though there
is no HEAD yet.
This code path still ensures that there is no index in order not to lose
any staged changes. Implement a test to ensure that this check is
triggered.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
Notes:
v5:
* Move test_i18ngrep into subshell
t/t5520-pull.sh | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 90728e0..a04f55c 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -412,6 +412,21 @@ test_expect_success 'pull --rebase works on branch yet to be born' '
test_cmp expect actual
'
+test_expect_success 'pull --rebase fails on unborn branch with staged changes' '
+ test_when_finished "rm -rf empty_repo2" &&
+ git init empty_repo2 &&
+ (
+ cd empty_repo2 &&
+ echo staged-file >staged-file &&
+ git add staged-file &&
+ test "$(git ls-files)" = staged-file &&
+ test_must_fail git pull --rebase .. master 2>err &&
+ test "$(git ls-files)" = staged-file &&
+ test "$(git show :staged-file)" = staged-file &&
+ test_i18ngrep "unborn branch with changes added to the index" err
+ )
+'
+
test_expect_success 'setup for detecting upstreamed changes' '
mkdir src &&
(cd src &&
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 7/8] t5521: test --dry-run does not make any changes
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
` (5 preceding siblings ...)
2015-05-29 11:44 ` [PATCH v5 6/8] t5520: test --rebase failure on unborn branch with index Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 11:44 ` [PATCH v5 8/8] t5520: check reflog action in fast-forward merge Paul Tan
2015-05-29 18:08 ` [PATCH v5 0/8] Improve git-pull test coverage Junio C Hamano
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan, Jeff King
Test that when --dry-run is provided to git-pull, it does not make any
changes, namely:
* --dry-run gets passed to git-fetch, so no FETCH_HEAD will be created
and no refs will be fetched.
* The index and work tree will not be modified.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
t/t5521-pull-options.sh | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index 453aba5..56e7377 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -117,4 +117,17 @@ test_expect_success 'git pull --all' '
)
'
+test_expect_success 'git pull --dry-run' '
+ test_when_finished "rm -rf clonedry" &&
+ git init clonedry &&
+ (
+ cd clonedry &&
+ git pull --dry-run ../parent &&
+ test_path_is_missing .git/FETCH_HEAD &&
+ test_path_is_missing .git/refs/heads/master &&
+ test_path_is_missing .git/index &&
+ test_path_is_missing file
+ )
+'
+
test_done
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v5 8/8] t5520: check reflog action in fast-forward merge
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
` (6 preceding siblings ...)
2015-05-29 11:44 ` [PATCH v5 7/8] t5521: test --dry-run does not make any changes Paul Tan
@ 2015-05-29 11:44 ` Paul Tan
2015-05-29 18:08 ` [PATCH v5 0/8] Improve git-pull test coverage Junio C Hamano
8 siblings, 0 replies; 10+ messages in thread
From: Paul Tan @ 2015-05-29 11:44 UTC (permalink / raw)
To: git; +Cc: Johannes Schindelin, Stefan Beller, Paul Tan
When testing a fast-forward merge with git-pull, check to see if the
reflog action is "pull" with the arguments passed to git-pull.
While we are in the vicinity, remove the empty line as well.
Signed-off-by: Paul Tan <pyokagan@gmail.com>
---
Notes:
v5:
* Loosen up the pattern used for search-and-replace of the object ID in
the reflog: it may not always be the case that the abbreviated object
ID is at least 5 characters.
* Only match the beginning of the reflog entry for the object ID.
t/t5520-pull.sh | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index a04f55c..af31f04 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -86,7 +86,6 @@ test_expect_success 'pulling into void must not create an octopus' '
'
test_expect_success 'test . as a remote' '
-
git branch copy master &&
git config branch.copy.remote . &&
git config branch.copy.merge refs/heads/master &&
@@ -95,7 +94,11 @@ test_expect_success 'test . as a remote' '
git checkout copy &&
test "$(cat file)" = file &&
git pull &&
- test "$(cat file)" = updated
+ test "$(cat file)" = updated &&
+ git reflog -1 >reflog.actual &&
+ sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
+ echo "OBJID HEAD@{0}: pull: Fast-forward" >reflog.expected &&
+ test_cmp reflog.expected reflog.fuzzy
'
test_expect_success 'the default remote . should not break explicit pull' '
@@ -106,7 +109,11 @@ test_expect_success 'the default remote . should not break explicit pull' '
git reset --hard HEAD^ &&
test "$(cat file)" = file &&
git pull . second &&
- test "$(cat file)" = modified
+ test "$(cat file)" = modified &&
+ git reflog -1 >reflog.actual &&
+ sed "s/^[0-9a-f][0-9a-f]*/OBJID/" reflog.actual >reflog.fuzzy &&
+ echo "OBJID HEAD@{0}: pull . second: Fast-forward" >reflog.expected &&
+ test_cmp reflog.expected reflog.fuzzy
'
test_expect_success 'fail if wildcard spec does not match any refs' '
--
2.1.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v5 0/8] Improve git-pull test coverage
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
` (7 preceding siblings ...)
2015-05-29 11:44 ` [PATCH v5 8/8] t5520: check reflog action in fast-forward merge Paul Tan
@ 2015-05-29 18:08 ` Junio C Hamano
8 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2015-05-29 18:08 UTC (permalink / raw)
To: Paul Tan; +Cc: git, Johannes Schindelin, Stefan Beller
Paul Tan <pyokagan@gmail.com> writes:
> This is a re-roll of [1].
>
> This patch series improves test coverage of git-pull.sh, and is part of my
> GSoC project to rewrite git-pull into a builtin. Improving test coverage
> helps to prevent regressions that could occur due to the rewrite.
>
> Thanks Junio, Johannes and Stefan for the reviews last round.
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/269236
>
> Paul Tan (8):
> t5520: prevent field splitting in content comparisons
> t5520: test no merge candidates cases
> t5520: test for failure if index has unresolved entries
> t5520: test work tree fast-forward when fetch updates head
> t5520: test --rebase with multiple branches
> t5520: test --rebase failure on unborn branch with index
> t5521: test --dry-run does not make any changes
> t5520: check reflog action in fast-forward merge
>
> t/t5520-pull.sh | 198 +++++++++++++++++++++++++++++++++++++++---------
> t/t5521-pull-options.sh | 13 ++++
> 2 files changed, 175 insertions(+), 36 deletions(-)
I saw very little changes relative to the previous round, and all of
them looked sensible ones.
Thanks.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-05-29 18:08 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-29 11:44 [PATCH v5 0/8] Improve git-pull test coverage Paul Tan
2015-05-29 11:44 ` [PATCH v5 1/8] t5520: prevent field splitting in content comparisons Paul Tan
2015-05-29 11:44 ` [PATCH v5 2/8] t5520: test no merge candidates cases Paul Tan
2015-05-29 11:44 ` [PATCH v5 3/8] t5520: test for failure if index has unresolved entries Paul Tan
2015-05-29 11:44 ` [PATCH v5 4/8] t5520: test work tree fast-forward when fetch updates head Paul Tan
2015-05-29 11:44 ` [PATCH v5 5/8] t5520: test --rebase with multiple branches Paul Tan
2015-05-29 11:44 ` [PATCH v5 6/8] t5520: test --rebase failure on unborn branch with index Paul Tan
2015-05-29 11:44 ` [PATCH v5 7/8] t5521: test --dry-run does not make any changes Paul Tan
2015-05-29 11:44 ` [PATCH v5 8/8] t5520: check reflog action in fast-forward merge Paul Tan
2015-05-29 18:08 ` [PATCH v5 0/8] Improve git-pull test coverage Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).