Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ fuori [OPTIONS]
| `--allow-sensitive` | Export files even if they match sensitive-file protection rules |

Git selection flags (`--staged`, `--unstaged`, `--diff`) and `--from-stdin` are mutually exclusive; `--no-git` cannot be combined with them.
`--no-default-ignore` only applies to filesystem selection.

**Examples:**

Expand Down
14 changes: 14 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ static void print_selection_mode_conflict(void) {
fprintf(stderr, "Use -h or --help for usage information\n");
}

static void print_no_default_ignore_conflict(void) {
fprintf(stderr, "--no-default-ignore can only be used with filesystem selection\n");
fprintf(stderr, "Use -h or --help for usage information\n");
}

void init_cli_options(CliOptions* options) {
if (!options) {
return;
Expand Down Expand Up @@ -254,6 +259,15 @@ int parse_cli_options(int argc, char* argv[], CliOptions* options) {
return -1;
}

if (options->no_default_ignore &&
(options->requested_mode == FILE_SELECTION_STDIN ||
options->requested_mode == FILE_SELECTION_GIT_STAGED ||
options->requested_mode == FILE_SELECTION_GIT_UNSTAGED ||
options->requested_mode == FILE_SELECTION_GIT_DIFF)) {
print_no_default_ignore_conflict();
return -1;
}

if (force_no_git) {
options->requested_mode = FILE_SELECTION_RECURSIVE;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,11 @@ if printf 'alpha.c\n' | (cd "$STDIN_DIR" && "$BIN" --from-stdin --no-git >/dev/n
fi
assert_contains "$STDIN_DIR/stdin_conflict_no_git.txt" "--no-git cannot be combined with --from-stdin, --staged, --unstaged, or --diff"

if printf 'alpha.c\n' | (cd "$STDIN_DIR" && "$BIN" --from-stdin --no-default-ignore >/dev/null 2>stdin_conflict_no_default_ignore.txt); then
fail "expected --from-stdin --no-default-ignore to fail"
fi
assert_contains "$STDIN_DIR/stdin_conflict_no_default_ignore.txt" "--no-default-ignore can only be used with filesystem selection"

if (cd "$STDIN_DIR" && "$BIN" -0 >/dev/null 2>stdin_null_without_mode_stderr.txt); then
fail "expected -0 without --from-stdin to fail"
fi
Expand Down Expand Up @@ -458,6 +463,11 @@ if (cd "$REPO" && "$BIN" --no-git --staged >/dev/null 2>stderr_invalid.txt); the
fi
assert_contains "$REPO/stderr_invalid.txt" "--no-git cannot be combined with --from-stdin, --staged, --unstaged, or --diff"

if (cd "$REPO" && "$BIN" --staged --no-default-ignore >/dev/null 2>stderr_no_default_ignore_invalid.txt); then
fail "expected --staged --no-default-ignore to fail"
fi
assert_contains "$REPO/stderr_no_default_ignore_invalid.txt" "--no-default-ignore can only be used with filesystem selection"

STAGED_REPO="$TMPDIR/staged_repo"
mkdir -p "$STAGED_REPO"
(cd "$STAGED_REPO" && git init -q)
Expand Down