diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-22 20:26:55 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-22 20:26:55 +0200 |
commit | 13e11087fed94279a5364dd87230586fb87baf8b (patch) | |
tree | b5b1c3f8888ad70d179fa7566ed70523e72eefa5 | |
parent | Merge branch 'rr/prompt-revert-head' into maint (diff) | |
parent | filter-branch: return to original dir after filtering (diff) | |
download | git-13e11087fed94279a5364dd87230586fb87baf8b.tar.xz git-13e11087fed94279a5364dd87230586fb87baf8b.zip |
Merge branch 'jk/filter-branch-come-back-to-original' into maint
* jk/filter-branch-come-back-to-original:
filter-branch: return to original dir after filtering
-rwxr-xr-x | git-filter-branch.sh | 5 | ||||
-rwxr-xr-x | t/t7003-filter-branch.sh | 14 |
2 files changed, 17 insertions, 2 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 53142492af..ac2a005fdb 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -199,6 +199,7 @@ t) test -d "$tempdir" && die "$tempdir already exists, please remove it" esac +orig_dir=$(pwd) mkdir -p "$tempdir/t" && tempdir="$(cd "$tempdir"; pwd)" && cd "$tempdir/t" && @@ -206,7 +207,7 @@ workdir="$(pwd)" || die "" # Remove tempdir on exit -trap 'cd ../..; rm -rf "$tempdir"' 0 +trap 'cd "$orig_dir"; rm -rf "$tempdir"' 0 ORIG_GIT_DIR="$GIT_DIR" ORIG_GIT_WORK_TREE="$GIT_WORK_TREE" @@ -469,7 +470,7 @@ if [ "$filter_tag_name" ]; then done fi -cd ../.. +cd "$orig_dir" rm -rf "$tempdir" trap - 0 diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh index 1e7a209efa..9496736a89 100755 --- a/t/t7003-filter-branch.sh +++ b/t/t7003-filter-branch.sh @@ -64,6 +64,20 @@ test_expect_success 'correct GIT_DIR while using -d' ' grep drepo "$TRASHDIR/backup-refs" ' +test_expect_success 'tree-filter works with -d' ' + git init drepo-tree && + ( + cd drepo-tree && + test_commit one && + git filter-branch -d "$TRASHDIR/dfoo" \ + --tree-filter "echo changed >one.t" && + echo changed >expect && + git cat-file blob HEAD:one.t >actual && + test_cmp expect actual && + test_cmp one.t actual + ) +' + test_expect_success 'Fail if commit filter fails' ' test_must_fail git filter-branch -f --commit-filter "exit 1" HEAD ' |