diff --git a/Documentation/git-ls-files.txt b/Documentation/git-ls-files.txt index 591f4ed462dea070c3f5d264b1b96d7edd70d063..87cc362ad88a4e65e7216d7db78b3219ddf65df8 100644 --- a/Documentation/git-ls-files.txt +++ b/Documentation/git-ls-files.txt @@ -13,7 +13,7 @@ SYNOPSIS (-[c|d|o|i|s|u|k|m])\* [-x |--exclude=] [-X |--exclude-from=] - [--exclude-per-directory=] + [--exclude-per-directory=] [--] []\* DESCRIPTION ----------- @@ -77,6 +77,13 @@ OPTIONS K to be killed ? other +--:: + Do not interpret any more arguments as options. + +:: + Files to show. If no files are given all files which match the other + specified criteria are shown. + Output ------ show files just outputs the filename unless '--stage' is specified in diff --git a/ls-files.c b/ls-files.c index 956be09350f6c17a479e96ab8e42575e1ce60762..f47114a168f3a7479cbe147f953e5f56af3d2dfc 100644 --- a/ls-files.c +++ b/ls-files.c @@ -530,7 +530,7 @@ static void verify_pathspec(void) static const char ls_files_usage[] = "git-ls-files [-z] [-t] (--[cached|deleted|others|stage|unmerged|killed|modified])* " "[ --ignored ] [--exclude=] [--exclude-from=] " - "[ --exclude-per-directory= ]"; + "[ --exclude-per-directory= ] [--] []*"; int main(int argc, const char **argv) { @@ -544,6 +544,10 @@ int main(int argc, const char **argv) for (i = 1; i < argc; i++) { const char *arg = argv[i]; + if (!strcmp(arg, "--")) { + i++; + break; + } if (!strcmp(arg, "-z")) { line_terminator = 0; continue; diff --git a/t/t3002-ls-files-dashpath.sh b/t/t3002-ls-files-dashpath.sh new file mode 100755 index 0000000000000000000000000000000000000000..b42f1382bc9c585d12febcd99594f6ba7d7d743c --- /dev/null +++ b/t/t3002-ls-files-dashpath.sh @@ -0,0 +1,69 @@ +#!/bin/sh +# +# Copyright (c) 2005 Junio C Hamano +# + +test_description='git-ls-files test (-- to terminate the path list). + +This test runs git-ls-files --others with the following on the +filesystem. + + path0 - a file + -foo - a file with a funny name. + -- - another file with a funny name. +' +. ./test-lib.sh + +test_expect_success \ + setup \ + 'echo frotz >path0 && + echo frotz >./-foo && + echo frotz >./--' + +test_expect_success \ + 'git-ls-files without path restriction.' \ + 'git-ls-files --others >output && + diff -u output - <output && + diff -u output - <output && + diff -u output - <output && + diff -u output - <output && + diff -u output - <