Skip to content

Commit

Permalink
Merge branch 'maint-1.6.0' into maint
Browse files Browse the repository at this point in the history
* maint-1.6.0:
  builtin-mv.c: check for unversionned files before looking at the destination.
  Add a testcase for "git mv -f" on untracked files.
  Missing && in t/t7001.sh.
  • Loading branch information
Junio C Hamano committed Feb 4, 2009
2 parents f081731 + 5aed3c6 commit 745bc77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions builtin-mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
/*
Expand All @@ -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);
Expand Down
10 changes: 9 additions & 1 deletion t/t7001-mv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,17 @@ 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'

test_expect_success \
'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 \
Expand Down

0 comments on commit 745bc77

Please sign in to comment.