commit 5a896ffda48c93e29d96e89c729c62464062d61640885316455cd448ea6e5a94 from: Stefan Sperling date: Sat Jul 11 08:19:34 2026 UTC do not raise errors when unversioned files are found during got rm -k ok Kyle Ackerman commit - e5b11b7968a46690c526716db076b7f004336c685780ae827be8307aaa199ff9 commit + 5a896ffda48c93e29d96e89c729c62464062d61640885316455cd448ea6e5a94 blob - 32f499975c59df0644d06db2e0ca4b467cee12fc69944f6a951f8bba9b13c5f1 blob + 0696309c9d24e61629af2d72a03e77fe73c60eb8bd51cfec29a4987302aa9067 --- got/got.1 +++ got/got.1 @@ -1921,6 +1921,9 @@ is a directory. Remove versioned files from a work tree and schedule them for deletion from the repository in the next commit. .Pp +By default, only files tracked under version control are removed, and +attempts to remove unversioned files result in errors. +.Pp The options for .Cm got remove are as follows: @@ -1932,6 +1935,7 @@ and do not raise an error if a specified does not exist on disk. .It Fl k Keep affected files on disk. +Silently ignore unversioned files encountered during file removal. .It Fl R Permit recursion into directories. If this option is not specified, blob - b29f4cb6093dac94899b224c287605091a27994d5b991b689f7027c610c6ccf6 blob + 198235d3bedddf3b7ae247dafb920b72ee87520f443972ac253e94c2171b5a61 --- lib/worktree.c +++ lib/worktree.c @@ -4577,6 +4577,12 @@ schedule_for_deletion(void *arg, unsigned char status, return got_error_set_errno(ENOENT, relpath); } + if (status == GOT_STATUS_UNVERSIONED) { + if (a->keep_on_disk) + return NULL; + return got_error_path(relpath, GOT_ERR_FILE_STATUS); + } + ie = got_fileindex_entry_get(a->fileindex, relpath, strlen(relpath)); if (ie == NULL) return got_error_path(relpath, GOT_ERR_FILE_STATUS);