threads / patch / 1468

patch-x (no-exclude) option for cg-status

Subject: [PATCH] -x (no-exclude) option for cg-status

## tl;dr

One message between Aug 10, 2005 and Aug 10, 2005. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Pavel Roskin· Aug 10, 2005, 18:42 UTC · lore
Hello!

I'm trying to reimplement my cg-clean script so that it reuses more code from other utilities. This patch makes it possible to call cg-status from cg-clean.

This patch adds the "-x" option that instructs cg-status not to ignore any files. Also, the code has been changed to add standard includes in a loop.

Signed-off-by: Pavel Roskin <proski@gnu.org>
Show changes to cg-status +16 −7
diff --git a/cg-status b/cg-status
--- a/cg-status
+++ b/cg-status
@@ -34,6 +34,9 @@
 # -w::
 #	Show the working tree file list.
 #
+# -x::
+#	Don't exclude any files from listing.
+#
 # FILES
 # -----
 # $GIT_DIR/exclude::
@@ -53,11 +56,14 @@ USAGE="cg-status [-g] [-w]"
 
 gitstatus=
 workstatus=
+noexclude=
 while optparse; do
 	if optparse -g; then
 		gitstatus=1
 	elif optparse -w; then
 		workstatus=1
+	elif optparse -x; then
+		noexclude=1
 	else
 		optfail
 	fi
@@ -116,18 +122,21 @@ fi
 
 
 if [ "$workstatus" ]; then
-	EXCLUDEFILE=$_git/exclude
 	EXCLUDE=
-	if [ -f $EXCLUDEFILE ]; then
-		EXCLUDE="$EXCLUDE --exclude-from=$EXCLUDEFILE"
+	if [ -z "$noexclude" ]; then
+		EXCLUDEFILE=$_git/exclude
+		for excl in '*.[ao]' '.*' tags '*~' '#*' ',,merge*'; do
+			EXCLUDE="$EXCLUDE --exclude=$excl"
+		done
+		if [ -f $EXCLUDEFILE ]; then
+			EXCLUDE="$EXCLUDE --exclude-from=$EXCLUDEFILE"
+		fi
+		EXCLUDE="$EXCLUDE --exclude-per-directory=.gitignore"
 	fi
 
 	git-update-cache --refresh > /dev/null
 
-	git-ls-files --others --exclude='*.[ao]' --exclude='.*' --exclude=tags \
-		--exclude='*~' --exclude='#*' \
-		--exclude=',,merge*' $EXCLUDE \
-		--exclude-per-directory=.gitignore |
+	git-ls-files --others $EXCLUDE |
 		{ if [ "$_git_relpath" ]; then sed -n "s|^$_git_relpath||p"; else cat; fi } |
 		sed 's,^,? ,'
 
-- 
Regards,
Pavel Roskin

← back to recent threads