{"thread":{"id":"758","subject":"[COGITO PATCH] Allow file list for cg-add through stdin","startedAt":"2005-05-29T17:40:26Z","lastAt":"2005-05-29T20:22:57Z","messageCount":4,"participants":["Jochen Roemling","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"4175","messageId":"4299FE8A.1060207@roemling.net","threadId":"758","inReplyTo":null,"subject":"[COGITO PATCH] Allow file list for cg-add through stdin","fromName":"Jochen Roemling","fromEmail":"jochen@roemling.net","sentAt":"2005-05-29T17:40:26Z","receivedAt":"2005-05-29T17:40:26Z","isPatch":true,"sender":{"key":"jochen@roemling.net","avatar":"https://gravatar.com/avatar/fd825445a548573b8483227eea8a12d7d3e474693d15bc2b77d9ee7df8870948?d=mp&s=160"},"body":"|Hello,\n\nhow is the preferred way to add a whole new directory to a \ngit-repository using cogito?\nCurrently cg-add expects all new files on the command line.\nThe following patch allows to feed files through stdin, which allows to do\n\n    find mynewdir -type f | cg-add -\n\nWhat about a functionality to specify a directory on the command line \nand all files are\nrecursively added?\n\nSigned-off-by: Jochen Roemling <jochen@roemling.net>\n\n--- a/cg-add      2005-05-29 19:27:17.000000000 +0200\n+++ b/cg-add      2005-05-29 19:32:42.000000000 +0200\n@@ -10,12 +10,24 @@\n\n [ \"$1\" ] || die \"usage: cg-add FILE...\"\n\n-for file in \"$@\"; do\n-       if [ -f \"$file\" ] || [ -h \"$file\" ]; then\n-               echo \"Adding file $file\"\n-       else\n-               die \"$file does not exist\"\n-       fi\n-done\n+if [ \"$1\" == '-' ]; then\n+       set $@ \"\"\n+       while read file; do\n+               if [ -f \"$file\" ] || [ -h \"$file\" ]; then\n+                       echo \"Adding file $file\"\n+                       set $@ \"$file\"\n+               else\n+                       die \"$file does not exist\"\n+               fi\n+       done\n+else\n+       for file in \"$@\"; do\n+               if [ -f \"$file\" ] || [ -h \"$file\" ]; then\n+                       echo \"Adding file $file\"\n+               else\n+                       die \"$file does not exist\"\n+               fi\n+       done\n+fi\n\n git-update-cache --add -- \"$@\"\n\n|\n"},{"id":"4176","messageId":"20050529180442.GK1036@pasky.ji.cz","threadId":"758","inReplyTo":"4299FE8A.1060207@roemling.net","subject":"Re: [COGITO PATCH] Allow file list for cg-add through stdin","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-29T18:04:42Z","receivedAt":"2005-05-29T18:04:42Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sun, May 29, 2005 at 07:40:26PM CEST, I got a letter\nwhere Jochen Roemling <jochen@roemling.net> told me that...\n> |Hello,\n\nHello,\n\n> how is the preferred way to add a whole new directory to a \n> git-repository using cogito?\n> Currently cg-add expects all new files on the command line.\n> The following patch allows to feed files through stdin, which allows to do\n> \n>    find mynewdir -type f | cg-add -\n\nif you really want to do that, pass it through xargs...\n\n> What about a functionality to specify a directory on the command line \n> and all files are\n> recursively added?\n\n...but I think this is definitively the right way to go.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"4183","messageId":"20050529184642.GL1036@pasky.ji.cz","threadId":"758","inReplyTo":"429A0818.6080807@roemling.net","subject":"Re: [COGITO PATCH] Allow file list for cg-add through stdin","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-29T18:46:42Z","receivedAt":"2005-05-29T18:46:42Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sun, May 29, 2005 at 08:21:12PM CEST, I got a letter\nwhere Jochen Roemling <jochen@roemling.net> told me that...\n> Petr Baudis wrote:\n> \n> >>how is the preferred way to add a whole new directory to a \n> >>git-repository using cogito?\n> >>Currently cg-add expects all new files on the command line.\n> >>The following patch allows to feed files through stdin, which allows to do\n> >>\n> >>  find mynewdir -type f | cg-add -\n> >>   \n> >>\n> >\n> >if you really want to do that, pass it through xargs...\n> >\n> > \n> >\n> We have 32° in this room and my xargs must have been melted down.\n\nIt's awfully hot here too. :/\n\n> How could I forget about one of my favorite commands?\n> I promise I will not post to this list anymore today to avoid a bigger mess.\n\nBut a patch for cg-add processing directories recursively would be great\nanyway... ;-)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"4191","messageId":"429A24A1.1010402@roemling.net","threadId":"758","inReplyTo":"20050529184642.GL1036@pasky.ji.cz","subject":"Re: [COGITO PATCH] Allow file list for cg-add through stdin","fromName":"Jochen Roemling","fromEmail":"jochen@roemling.net","sentAt":"2005-05-29T20:22:57Z","receivedAt":"2005-05-29T20:22:57Z","isPatch":true,"sender":{"key":"jochen@roemling.net","avatar":"https://gravatar.com/avatar/fd825445a548573b8483227eea8a12d7d3e474693d15bc2b77d9ee7df8870948?d=mp&s=160"},"body":"Petr Baudis wrote:\n\n>But a patch for cg-add processing directories recursively would be great\n>anyway... ;-)\n>\n>  \n>\nOkay, okay, what about this one:\n\n\n[Cogito PATCH] Add directories recursively  with cg-add\n\nSigned-off-by: Jochen Roemling <jochen@roemling.net>\n\n--- a/cg-add\n\n+++ b/cg-add\n\n@@ -10,12 +10,11 @@\n\n [ \"$1\" ] || die \"usage: cg-add FILE...\"\n\n-for file in \"$@\"; do\n\n-\tif [ -f \"$file\" ] || [ -h \"$file\" ]; then\n\n-\t\techo \"Adding file $file\"\n\n-\telse\n\n-\t\tdie \"$file does not exist\"\n\n-\tfi\n\n-done\n\n+TMPFILE=\"${TMP:-/tmp}/$(basename $0).$$.tmp\"\n\n-git-update-cache --add -- \"$@\"\n\n+find $@ -type f > $TMPFILE || die \"not all files do exist, nothing added\"\n\n+\n\n+cat $TMPFILE | awk '{print \"Adding file \"  $0}' \n\n+cat $TMPFILE | xargs git-update-cache --add -- \n\n+\n\n+rm -f $TMPFILE\n\n"}]}