]> scripts.mit.edu Git - wizard.git/commitdiff
Have gct properly change ownership instead of 777, add null argument testing.
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 14 Nov 2010 16:29:05 +0000 (16:29 +0000)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 14 Nov 2010 16:29:05 +0000 (16:29 +0000)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
bin/gct

diff --git a/TODO b/TODO
index 5f4fd90d4b3fbfe0d4f7cff14bb2f842cac2430f..7fc3e933f9df5df3c873ef3e118eab9c51eef3d9 100644 (file)
--- a/TODO
+++ b/TODO
@@ -22,8 +22,6 @@
   explicitly configure a URL at install, we should be able to
   detect this URL as baked in from the configuration
 
-- gct has accidentally set the +x bit on a lot of files >.>.
-- Make gct do the right thing with no arguments
 - Rerere support doesn't actually work
 - Utility scripts gct should support multiple filenames
 - "Version 3.0.0 doesn't exist; did you mean 3.0?"
diff --git a/bin/gct b/bin/gct
index bdc2ca81ad1bf78ec0ad13f76dea6f662d16e128..e3da5a8645529781967bb4f3792555bf02c1c086 100755 (executable)
--- a/bin/gct
+++ b/bin/gct
@@ -1,4 +1,12 @@
-#!/bin/sh
+#!/bin/bash
+set -e
+if [ -z "$1" ]
+then
+    echo "Usage: gct FILE"
+    exit 1
+fi
+OWNER=$(stat -c "%u:%g" "$1")
+set -x
 git checkout --theirs "$1"
-chmod 0777 "$1"
+chown "$OWNER" "$1"
 git add "$1"