* [COGITO PATCH] Allow file list for cg-add through stdin
@ 2005-05-29 17:40 Jochen Roemling
2005-05-29 18:04 ` Petr Baudis
0 siblings, 1 reply; 4+ messages in thread
From: Jochen Roemling @ 2005-05-29 17:40 UTC (permalink / raw)
To: Git Mailing List
|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 -- "$@"
|
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [COGITO PATCH] Allow file list for cg-add through stdin
2005-05-29 17:40 [COGITO PATCH] Allow file list for cg-add through stdin Jochen Roemling
@ 2005-05-29 18:04 ` Petr Baudis
[not found] ` <429A0818.6080807@roemling.net>
0 siblings, 1 reply; 4+ messages in thread
From: Petr Baudis @ 2005-05-29 18:04 UTC (permalink / raw)
To: Jochen Roemling; +Cc: Git Mailing List
Dear diary, on Sun, May 29, 2005 at 07:40:26PM CEST, I got a letter
where Jochen Roemling <jochen@roemling.net> told me that...
> |Hello,
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 -
if you really want to do that, pass it through xargs...
> 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.
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [COGITO PATCH] Allow file list for cg-add through stdin
[not found] ` <429A0818.6080807@roemling.net>
@ 2005-05-29 18:46 ` Petr Baudis
2005-05-29 20:22 ` Jochen Roemling
0 siblings, 1 reply; 4+ messages in thread
From: Petr Baudis @ 2005-05-29 18:46 UTC (permalink / raw)
To: Jochen Roemling; +Cc: Git Mailing List
Dear diary, on Sun, May 29, 2005 at 08:21:12PM CEST, I got a letter
where Jochen Roemling <jochen@roemling.net> told me that...
> Petr Baudis wrote:
>
> >>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 -
> >>
> >>
> >
> >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. :/
> 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... ;-)
--
Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [COGITO PATCH] Allow file list for cg-add through stdin
2005-05-29 18:46 ` Petr Baudis
@ 2005-05-29 20:22 ` Jochen Roemling
0 siblings, 0 replies; 4+ messages in thread
From: Jochen Roemling @ 2005-05-29 20:22 UTC (permalink / raw)
To: Petr Baudis; +Cc: Git Mailing List
Petr Baudis wrote:
>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
Signed-off-by: Jochen Roemling <jochen@roemling.net>
--- 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-05-29 20:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-29 17:40 [COGITO PATCH] Allow file list for cg-add through stdin Jochen Roemling
2005-05-29 18:04 ` Petr Baudis
[not found] ` <429A0818.6080807@roemling.net>
2005-05-29 18:46 ` Petr Baudis
2005-05-29 20:22 ` Jochen Roemling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).