Skip to content

Commit de81390

Browse files
committed
Merge branch 'maint'
* maint: urls.txt: document optional port specification in git URLS 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.
2 parents d3f552b + f26b5dc commit de81390

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Documentation/urls.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ to name the remote repository:
66

77
===============================================================
88
- rsync://host.xz/path/to/repo.git/
9-
- http://host.xz/path/to/repo.git/
10-
- https://host.xz/path/to/repo.git/
11-
- git://host.xz/path/to/repo.git/
12-
- git://host.xz/~user/path/to/repo.git/
9+
- http://host.xz{startsb}:port{endsb}/path/to/repo.git/
10+
- https://host.xz{startsb}:port{endsb}/path/to/repo.git/
11+
- git://host.xz{startsb}:port{endsb}/path/to/repo.git/
12+
- git://host.xz{startsb}:port{endsb}/~user/path/to/repo.git/
1313
- ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/path/to/repo.git/
1414
- ssh://{startsb}user@{endsb}host.xz/path/to/repo.git/
1515
- ssh://{startsb}user@{endsb}host.xz/~user/path/to/repo.git/

builtin-mv.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
162162
}
163163
argc += last - first;
164164
}
165-
} else if (lstat(dst, &st) == 0) {
165+
} else if (cache_name_pos(src, length) < 0)
166+
bad = "not under version control";
167+
else if (lstat(dst, &st) == 0) {
166168
bad = "destination exists";
167169
if (force) {
168170
/*
@@ -177,9 +179,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
177179
} else
178180
bad = "Cannot overwrite";
179181
}
180-
} else if (cache_name_pos(src, length) < 0)
181-
bad = "not under version control";
182-
else if (string_list_has_string(&src_for_dst, dst))
182+
} else if (string_list_has_string(&src_for_dst, dst))
183183
bad = "multiple sources for the same target";
184184
else
185185
string_list_insert(dst, &src_for_dst);

t/t7001-mv.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,17 @@ test_expect_success \
5555
git mv -k untracked1 untracked2 path0 &&
5656
test -f untracked1 &&
5757
test -f untracked2 &&
58-
test ! -f path0/untracked1
58+
test ! -f path0/untracked1 &&
5959
test ! -f path0/untracked2'
6060

61+
test_expect_success \
62+
'checking -f on untracked file with existing target' \
63+
'touch path0/untracked1 &&
64+
git mv -f untracked1 path0
65+
test ! -f .git/index.lock &&
66+
test -f untracked1 &&
67+
test -f path0/untracked1'
68+
6169
# clean up the mess in case bad things happen
6270
rm -f idontexist untracked1 untracked2 \
6371
path0/idontexist path0/untracked1 path0/untracked2 \

0 commit comments

Comments
 (0)