Skip to contentSkip to conversation

cg-add only checks if the first file exists

PATCH New Andy Lutomirski 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cg-add only checks if the first file exists

[apologies for possible dupe -- my mailer freaked out]

Doing:
cg-add foo bar
fails if foo doesn't exist but doesn't check for bar. It also gives misleading reports to stdout.

I've fixed it at rsync://www.luto.us/cogito.git

Patch attached below as well.

--
Changed cg-add to check each added file for existence.

---
commit 9eb8efee632b6270a436d8088315856712bb5b32
tree cba76f974b1840640ccfa14b0118e1dc4a704876
parent 49612c471eebd26efe926a71752e254c1cdc382d author Andy Lutomirski <[email protected]> 1114878247 -0700 committer Andy Lutomirski <[email protected]> 1114878247 -0700

cg-add (mode:100755 sha1:c84792450cec279f7b3eb1dec03b69ac07dbe9d9) renamed from cg-add (mode:100755 sha1:83f0b13f41599104d741ac91c7aa81497cd37d5f) +7 -5
Index: cg-add
===================================================================
@@ -10,10 +10,12 @@
 
 [ "$1" ] || die "usage: cg-add FILE..."
 
-if [ -f "$1" ]; then
-       echo "Adding file $1"
-else
-       die "$1 does not exist"
-fi
+for i in "$@"; do
+       if [ -f "$i" ]; then
+              echo "Adding file $i"
+       else
+              die "$i does not exist"
+       fi
+done
 
 update-cache --add -- "$@"