threads / patch / 17550

patch, 3 partsMissing && in t/t7001.sh.

Subject: [PATCH 1/3] Missing && in t/t7001.sh.

## tl;dr

4 messages between Feb 4, 2009 and Feb 4, 2009. Diffs are folded; open one to read it.

replies: 3people: 2as markdown or json

Matthieu Moy· Feb 4, 2009, 09:32 UTC · lore
Without this, the exit status is only the one of the last line.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t7001-mv.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to t/t7001-mv.sh +1 −1
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index ef2e78f..e4dfe95 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -55,7 +55,7 @@ test_expect_success \
      git mv -k untracked1 untracked2 path0 &&
      test -f untracked1 &&
      test -f untracked2 &&
-     test ! -f path0/untracked1
+     test ! -f path0/untracked1 &&
      test ! -f path0/untracked2'
 
 # clean up the mess in case bad things happen
-- 
1.6.1.2.321.g68da9
Matthieu Moy· Feb 4, 2009, 09:32 UTC · re: Matthieu Moy · lore

[PATCH 2/3] [BUG] Add a testcase for "git mv -f" on untracked files.

This currently fails with: git: builtin-mv.c:217: cmd_mv: Assertion `pos >= 0' failed.

Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 t/t7001-mv.sh |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
Show changes to t/t7001-mv.sh +8 −0
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index e4dfe95..52a47b5 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -58,6 +58,14 @@ test_expect_success \
      test ! -f path0/untracked1 &&
      test ! -f path0/untracked2'
 
+test_expect_failure \
+    'checking -f on untracked file with existing target' \
+    'touch path0/untracked1 &&
+     git mv -f untracked1 path0
+     test ! -f .git/index.lock &&
+     test -f untracked1 &&
+     test -f path0/untracked1'
+
 # clean up the mess in case bad things happen
 rm -f idontexist untracked1 untracked2 \
      path0/idontexist path0/untracked1 path0/untracked2 \
-- 
1.6.1.2.321.g68da9
Matthieu Moy· Feb 4, 2009, 09:32 UTC · re: Matthieu Moy · lore

[PATCH 3/3] builtin-mv.c: check for unversionned files before looking at the destination.

The previous code was failing in the case where one moves an unversionned file to an existing destination, with mv -f: the "existing destination" was checked first, and the error was cancelled by the force flag.

We now check the unrecoverable error first, which fixes the bug.
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
 builtin-mv.c  |    8 ++++----
 t/t7001-mv.sh |    2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
Show changes to 2 files +5 −5

builtin-mv.c, t/t7001-mv.sh

diff --git a/builtin-mv.c b/builtin-mv.c
index bce9959..01270fe 100644
--- a/builtin-mv.c
+++ b/builtin-mv.c
@@ -162,7 +162,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				}
 				argc += last - first;
 			}
-		} else if (lstat(dst, &st) == 0) {
+		} else if (cache_name_pos(src, length) < 0)
+			bad = "not under version control";
+		else if (lstat(dst, &st) == 0) {
 			bad = "destination exists";
 			if (force) {
 				/*
@@ -177,9 +179,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 				} else
 					bad = "Cannot overwrite";
 			}
-		} else if (cache_name_pos(src, length) < 0)
-			bad = "not under version control";
-		else if (string_list_has_string(&src_for_dst, dst))
+		} else if (string_list_has_string(&src_for_dst, dst))
 			bad = "multiple sources for the same target";
 		else
 			string_list_insert(dst, &src_for_dst);
diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh
index 52a47b5..8fb3a56 100755
--- a/t/t7001-mv.sh
+++ b/t/t7001-mv.sh
@@ -58,7 +58,7 @@ test_expect_success \
      test ! -f path0/untracked1 &&
      test ! -f path0/untracked2'
 
-test_expect_failure \
+test_expect_success \
     'checking -f on untracked file with existing target' \
     'touch path0/untracked1 &&
      git mv -f untracked1 path0
-- 
1.6.1.2.321.g68da9

← back to recent threads