git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jochen Roemling <jochen@roemling.net>
Date
May 29, 2005, 17:40 UTC
Message-ID
<4299FE8A.1060207@roemling.net>
|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 -- "$@"

|
Next: Petr Baudis
Message 1 of 4 in “Allow file list for cg-add through stdin”
  1. Allow file list for cg-add through stdinJochen Roemling, May 29, 2005
  2. Petr BaudisMay 29, 2005
  3. Petr BaudisMay 29, 2005
  4. Jochen RoemlingMay 29, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.