worktree move: accept destination as directory
Similar to "mv a b/", which is actually "mv a b/a", we extract basename of source worktree and create a directory of the same name at destination if dst path is a directory. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
9f792bb472
commit
c64a8d200f
8
strbuf.c
8
strbuf.c
@ -95,6 +95,7 @@ void strbuf_trim(struct strbuf *sb)
|
||||
strbuf_rtrim(sb);
|
||||
strbuf_ltrim(sb);
|
||||
}
|
||||
|
||||
void strbuf_rtrim(struct strbuf *sb)
|
||||
{
|
||||
while (sb->len > 0 && isspace((unsigned char)sb->buf[sb->len - 1]))
|
||||
@ -102,6 +103,13 @@ void strbuf_rtrim(struct strbuf *sb)
|
||||
sb->buf[sb->len] = '\0';
|
||||
}
|
||||
|
||||
void strbuf_trim_trailing_dir_sep(struct strbuf *sb)
|
||||
{
|
||||
while (sb->len > 0 && is_dir_sep((unsigned char)sb->buf[sb->len - 1]))
|
||||
sb->len--;
|
||||
sb->buf[sb->len] = '\0';
|
||||
}
|
||||
|
||||
void strbuf_ltrim(struct strbuf *sb)
|
||||
{
|
||||
char *b = sb->buf;
|
||||
|
Reference in New Issue
Block a user