aboutsummaryrefslogtreecommitdiff
path: root/rsup
diff options
context:
space:
mode:
Diffstat (limited to 'rsup')
-rwxr-xr-xrsup59
1 files changed, 54 insertions, 5 deletions
diff --git a/rsup b/rsup
index d535e63..207d3d8 100755
--- a/rsup
+++ b/rsup
@@ -14,6 +14,46 @@ BASENAME="`basename $0`"
MESSAGE="$*"
GIT="hit"
+# Commit upwards
+function upward_commit {
+ local level=""
+ local up="../"
+ local found="0"
+ local base
+ local log
+ local message
+
+ # Check upwards if there's a .git folder
+ while true; do
+ # Stop on the root folder
+ if [ "`cd $level &> /dev/null && pwd`" == "/" ]; then
+ break
+ fi
+
+ if [ -d "$level/.git" ]; then
+ found="1"
+ break
+ fi
+
+ level="${level}${up}"
+ done
+
+ # Commit in the parent repository
+ if [ "$found" == "1" ]; then
+ base="$(basename `pwd`)"
+ log="`git log -1 --oneline`"
+ message="Updates $BASE: $LOG"
+
+ ( cd .. &> /dev/null && $GIT add -f $base )
+
+ cd $level && $DIRNAME/commit "$message"
+
+ return 0
+ fi
+
+ return 1
+}
+
# Check if it is a git repository
if [ ! -d ".git" ]; then
echo "$BASENAME: not a git repository"
@@ -27,10 +67,19 @@ if [ -z "$MESSAGE" ]; then
fi
# Commit
-commit $MESSAGE
+$DIRNAME/commit $MESSAGE
+
+# Commit upwards until there are repositories
+while true; do
+ # Stop on the root folder
+ if [ "`pwd`" == "/" ]; then
+ break
+ fi
-# Go up
-while test -d "../.git"; do
- sup
- cd ..
+ # Go up
+ if upward_commit; then
+ cd ..
+ else
+ break
+ fi
done