@@ -43,9 +43,11 @@ static void setup_enlistment_directory(int argc, const char **argv,
usage_with_options(usagestr, options);
/* find the worktree, determine its corresponding root */
- if (argc == 1)
+ if (argc == 1) {
strbuf_add_absolute_path(&path, argv[0]);
- else if (strbuf_getcwd(&path) < 0)
+ if (!is_directory(path.buf))
+ die(_("'%s' does not exist"), path.buf);
+ } else if (strbuf_getcwd(&path) < 0)
die(_("need a working directory"));
strbuf_trim_trailing_dir_sep(&path);
@@ -93,4 +93,9 @@ test_expect_success 'scalar supports -c/-C' '
test true = "$(git -C sub config core.preloadIndex)"
'
+test_expect_success '`scalar [...] <dir>` errors out when dir is missing' '
+ ! scalar run config cloned 2>err &&
+ grep "cloned. does not exist" err
+'
+
test_done