Perform these two tasks:

    git gc --auto
    rm -fr "$dotest"

only when not called with --rebasing (from git-rebase--am.sh).
Otherwise, return control to the caller so that it can do the needful.
The advantage of doing this is that the caller can implement a generic
cleanup routine (that possibly does other things) independent of
specific rebases.

Patch the ultimate caller, git-rebase.sh, to perform these two steps
for the moment.  Later patches will add functionality.

Signed-off-by: Ramkumar Ramachandra <artag...@gmail.com>
---
 git-am.sh         | 9 +++++++--
 git-rebase--am.sh | 8 ++++----
 git-rebase.sh     | 7 +++++++
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index f4ef8fc..47c1021 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -904,5 +904,10 @@ if test -s "$dotest"/rewritten; then
     fi
 fi
 
-rm -fr "$dotest"
-git gc --auto
+# If am was called with --rebasing (from git-rebase--am), it's up to
+# the caller to take care of housekeeping.
+if ! test -f "$dotest/rebasing"
+then
+       rm -fr "$dotest"
+       git gc --auto
+fi
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
index f84854f..8230094 100644
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -7,12 +7,12 @@ case "$action" in
 continue)
        git am --resolved --resolvemsg="$resolvemsg" &&
        move_to_original_branch
-       exit
+       return $?
        ;;
 skip)
        git am --skip --resolvemsg="$resolvemsg" &&
        move_to_original_branch
-       exit
+       return $?
        ;;
 esac
 
@@ -56,7 +56,7 @@ else
 
                As a result, git cannot rebase them.
                EOF
-               exit $?
+               return $?
        fi
 
        git am $git_am_opt --rebasing --resolvemsg="$resolvemsg" 
<"$GIT_DIR/rebased-patches"
@@ -68,7 +68,7 @@ fi
 if test 0 != $ret
 then
        test -d "$state_dir" && write_basic_state
-       exit $ret
+       return $ret
 fi
 
 move_to_original_branch
diff --git a/git-rebase.sh b/git-rebase.sh
index b2f1c76..8412d81 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -150,6 +150,13 @@ run_specific_rebase () {
                autosquash=
        fi
        . git-rebase--$type
+       ret=$?
+       if test $ret = 0
+       then
+               git gc --auto &&
+               rm -rf "$state_dir"
+       fi
+       exit $ret
 }
 
 run_pre_rebase_hook () {
-- 
1.8.2.1.578.ga933817

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to