Skip to content

Commit b5062f7

Browse files
thaliaarchigitster
authored andcommitted
fast-import: allow unquoted empty path for root
Ever since filerename was added in f39a946 (Support wholesale directory renames in fast-import, 2007-07-09) and filecopy in b6f3481 (Teach fast-import to recursively copy files/directories, 2007-07-15), both have produced an error when the destination path is empty. Later, when support for targeting the root directory with an empty string was added in 2794ad5 (fast-import: Allow filemodify to set the root, 2010-10-10), this had the effect of allowing the quoted empty string (`""`), but forbidding its unquoted variant (``). This seems to have been intended as simple data validation for parsing two paths, rather than a syntax restriction, because it was not extended to the other operations. All other occurrences of paths (in filemodify, filedelete, the source of filecopy and filerename, and ls) allow both. For most of this feature's lifetime, the documentation has not prescribed the use of quoted empty strings. In e595910 (Documentation/fast-import: put explanation of M 040000 <dataref> "" in context, 2011-01-15), its documentation was changed from “`<path>` may also be an empty string (`""`) to specify the root of the tree” to “The root of the tree can be represented by an empty string as `<path>`”. Thus, we should assume that some front-ends have depended on this behavior. Remove this restriction for the destination paths of filecopy and filerename and change tests targeting the root to test `""` and ``. Signed-off-by: Thalia Archibald <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5733f89 commit b5062f7

File tree

2 files changed

+190
-176
lines changed

2 files changed

+190
-176
lines changed

builtin/fast-import.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,9 +2423,6 @@ static void file_change_cr(const char *p, struct branch *b, int rename)
24232423

24242424
strbuf_reset(&source);
24252425
parse_path_space(&source, p, &p, "source");
2426-
2427-
if (!*p)
2428-
die("Missing dest: %s", command_buf.buf);
24292426
strbuf_reset(&dest);
24302427
parse_path_eol(&dest, p, "dest");
24312428

0 commit comments

Comments
 (0)