Permalink
Browse files

Fixed removal of submodule git dirs and improved checking for non-tra…

…cking branches.

This version still has some problems with git versions 1.7.8.4 and 1.7.9.4. Versions earlier to 1.7.8 as well as 1.7.10 should work fine. A list of tested versions is given in README.md.
  • Loading branch information...
Manuel Koller
Manuel Koller committed May 20, 2012
1 parent 82289ea commit e900c24b9ec26750207fb6eb9a12f6ac4e777973
Showing with 325 additions and 288 deletions.
  1. +2 −2 README.md
  2. +6 −1 git-check-non-tracking
  3. +4 −3 git-rm-orphaned-submodule-dirs
  4. +4 −3 git-rm-submodule
  5. +309 −279 test_output_linux
View
@@ -158,8 +158,8 @@ Known Problems
does not allow for an -r argument (use `no xargs`-branch).
* When invoking `git rcommit` without giving the message, the shell somehow
breaks afterwards and has to be restarted.
-* The scripts were tested for git version 1.7.3.4 but not for any other
- version.
+* The scripts work fine for git versions 1.7.6.1, 1.7.7.3 and 1.7.10.1, but
+ there are some known problems with 1.7.8.4 and 1.7.9.4.
Copyright/License
-----------------
View
@@ -40,8 +40,13 @@ if [[ "$tmp" ]]; then
branch=`expr "$line" : '\** *\([^ ]*\)'`
##echo "$branch"
remote=`expr "$line" : '.*\[\(.*\)\]'` && continue
- nontracking="$nontracking $branch is not a remote tracking branch and is not fully merged to HEAD.
+ ## this might be a a non-tracking branch that is not fully merged to some other tracking branch
+ if git branch -vv --no-color --contains testbranch | grep \\[.*/.*\\] -q; then
+ continue
+ else
+ nontracking="$nontracking $branch is not a remote tracking branch and is not fully merged any tracking branch.
"
+ fi
done <<< "$tmp"
fi
@@ -39,11 +39,12 @@ while read key url; do
git check-unpushed || exit 1
git check-non-tracking || exit 1
## find the real git-dir (might be git-file, for v.1.7.8 compatibility)
- gitdir=$(git rev-parse --git-dir)
+ ## git dir should be relative to current dir... but is it?
+ gitdir=$(cd `git rev-parse --git-dir`; pwd)
cd "$tdir"
- ## remove git dir first (might git-file, for v.1.7.8 compatibility)
- rm -rf "$dir$gitdir"
rm -rf "$dir"
+ ## remove git dir as well (might git-file, for v.1.7.8 compatibility)
+ rm -rf "$gitdir"
fi
done
View
@@ -50,7 +50,8 @@ git check-unpushed || exit 1
## check for local non-tracking-branches
git check-non-tracking || exit 1
## find the real git-dir (might be git-file, for v.1.7.8 compatibility)
-gitdir=$(git rev-parse --git-dir)
+## git dir should be relative to current dir... but is it?
+gitdir=$(cd `git rev-parse --git-dir`; pwd)
cd "$cdup"
## seems we're safe, so start removing
@@ -59,10 +60,10 @@ url=`git config --get submodule."$dir".url || echo "unknown"`
## remove config entries
git config -f .gitmodules --remove-section submodule."$dir" 2>/dev/null || echo -n ""
git config --remove-section submodule."$dir" 2>/dev/null || echo -n ""
-## remove git dir first (might git-file, for v.1.7.8 compatibility)
-rm -rf "$dir$gitdir"
git rm --cached "$dir"
rm -rf "$dir"
+## remove git dir as well (might git-file, for v.1.7.8 compatibility)
+rm -rf "$gitdir"
## commit changes
if [[ ! "$nocommit" ]]; then
git add .gitmodules
Oops, something went wrong.

0 comments on commit e900c24

Please sign in to comment.