[COGITO PATCH] Allow file list for cg-add through stdin

From: Jochen Roemling <jochen@roemling.net>
Date: 2005-05-30 03:40:26
|Hello,

how is the preferred way to add a whole new directory to a 
git-repository using cogito?
Currently cg-add expects all new files on the command line.
The following patch allows to feed files through stdin, which allows to do

    find mynewdir -type f | cg-add -

What about a functionality to specify a directory on the command line 
and all files are
recursively added?

Signed-off-by: Jochen Roemling <jochen@roemling.net>

--- a/cg-add      2005-05-29 19:27:17.000000000 +0200
+++ b/cg-add      2005-05-29 19:32:42.000000000 +0200
@@ -10,12 +10,24 @@

 [ "$1" ] || die "usage: cg-add FILE..."

-for file in "$@"; do
-       if [ -f "$file" ] || [ -h "$file" ]; then
-               echo "Adding file $file"
-       else
-               die "$file does not exist"
-       fi
-done
+if [ "$1" == '-' ]; then
+       set $@ ""
+       while read file; do
+               if [ -f "$file" ] || [ -h "$file" ]; then
+                       echo "Adding file $file"
+                       set $@ "$file"
+               else
+                       die "$file does not exist"
+               fi
+       done
+else
+       for file in "$@"; do
+               if [ -f "$file" ] || [ -h "$file" ]; then
+                       echo "Adding file $file"
+               else
+                       die "$file does not exist"
+               fi
+       done
+fi

 git-update-cache --add -- "$@"

|
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Mon May 30 03:47:20 2005

This archive was generated by hypermail 2.1.8 : 2005-05-30 03:47:20 EST