Allow file list for cg-add through stdin
PATCH 1/1 Allow file list for cg-add through stdin
|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?
cg-add 2005-05-29 19:32:42.000000000 +0200 renamed from cg-add 2005-05-29 19:27:17.000000000 +0200 +0 -0
@@ -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 -- "$@"
|
Dear diary, on Sun, May 29, 2005 at 07:40:26PM CEST, I got a letter where Jochen Roemling <[email protected]> told me that...
Quoted 1 line
|Hello,
Hello,
Quoted 6 lines
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 dofind mynewdir -type f | cg-add -
if you really want to do that, pass it through xargs...
Quoted 3 lines
What about a functionality to specify a directory on the command line and all files are
recursively added?
...but I think this is definitively the right way to go.
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
A message that is not in the archive (sent off-list or not yet received): [email protected]
Dear diary, on Sun, May 29, 2005 at 08:21:12PM CEST, I got a letter where Jochen Roemling <[email protected]> told me that...
Quoted 11 lines
Quoted 9 lines · Petr Baudis
Quoted 8 lines
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 dofind mynewdir -type f | cg-add -
Quoted 5 lines
Quoted 4 lines
if you really want to do that, pass it through xargs...
We have 32° in this room and my xargs must have been melted down.
It's awfully hot here too. :/
Quoted 2 lines
How could I forget about one of my favorite commands?
I promise I will not post to this list anymore today to avoid a bigger mess.
But a patch for cg-add processing directories recursively would be great anyway... ;-)
Signature · 3 lines
Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Quoted 5 lines · Petr Baudis
But a patch for cg-add processing directories recursively would be great anyway... ;-)
Okay, okay, what about this one:
[Cogito PATCH] Add directories recursively with cg-add
--- a/cg-add
+++ b/cg-add
@@ -10,12 +10,11 @@
[ "$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
+TMPFILE="${TMP:-/tmp}/$(basename $0).$$.tmp"
-git-update-cache --add -- "$@"
+find $@ -type f > $TMPFILE || die "not all files do exist, nothing added"
+
+cat $TMPFILE | awk '{print "Adding file " $0}'
+cat $TMPFILE | xargs git-update-cache --add --
+
+rm -f $TMPFILE