Skip to contentSkip to conversation

git-add: Add support for --, documentation, and test.

PATCH New Carl Worth 1 participant 1 message Jun 15, 2016 Documentation

lore
Share & tools
lore

Carl Worth

author
#0 lore raw

PATCH 1/1 git-add: Add support for --, documentation, and test.

This adds support to git-add to allow the common -- to separate command-line options and file names. It adds documentation and a new git-add test case as well.

---

[In my tree on the git-add-dash-dash branch.]

 Documentation/git-add.txt |    7 ++++++-
 git-add.sh                |    4 ++++
 t/t3700-add.sh            |   22 ++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletions(-)
 create mode 100755 t/t3700-add.sh

af9363cd7aec2b39ad7ba4594e2c4d4757e8f644

Documentation/git-add.txt +6 -1
index 89e4614..7e29383 100644
@@ -7,7 +7,7 @@ git-add - Add files to the index file.
 
 SYNOPSIS
 --------
-'git-add' [-n] [-v] <file>...
+'git-add' [-n] [-v] [--] <file>...
 
 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
 ----------
git-add.sh +4 -0
index 13fad82..d6a4bc7 100755
@@ -14,6 +14,10 @@ while : ; do
     -v)
 	verbose=--verbose
 	;;
+    --)
+	shift
+	break
+	;;
     -*)
 	usage
 	;;
t/t3700-add.sh new file +22 -0
new file mode 100755
index 0000000..7c61034
@@ -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 --error-unmatch foo'
+
+test_expect_success \
+    'Test that "git-add -- -q" works' \
+    'touch -- -q && git-add -- -q'
+
+test_done
Signature · 1 line
1.2.2.g0a5f5-dirty