diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt index 89e461402e..7e293834d1 100644 --- a/Documentation/git-add.txt +++ b/Documentation/git-add.txt @@ -7,7 +7,7 @@ git-add - Add files to the index file. SYNOPSIS -------- -'git-add' [-n] [-v] ... +'git-add' [-n] [-v] [--] ... DESCRIPTION ----------- @@ -26,6 +26,11 @@ OPTIONS -v:: Be verbose. +--:: + This option can be used to separate command-line options from + the list of files, (useful when filenames might be mistaken + for command-line options). + DISCUSSION ---------- diff --git a/git-add.sh b/git-add.sh index f719b4b1a8..611f152dac 100755 --- a/git-add.sh +++ b/git-add.sh @@ -14,6 +14,10 @@ while : ; do -v) verbose=--verbose ;; + --) + shift + break + ;; -*) usage ;; diff --git a/t/t3700-add.sh b/t/t3700-add.sh new file mode 100755 index 0000000000..6cd05c3d90 --- /dev/null +++ b/t/t3700-add.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright (c) 2006 Carl D. Worth +# + +test_description='Test of git-add, including the -- option.' + +. ./test-lib.sh + +test_expect_success \ + 'Test of git-add' \ + 'touch foo && git-add foo' + +test_expect_success \ + 'Post-check that foo is in the index' \ + 'git-ls-files foo | grep foo' + +test_expect_success \ + 'Test that "git-add -- -q" works' \ + 'touch -- -q && git-add -- -q' + +test_done