summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2011-10-13 11:59:24 -0400
committerJunio C Hamano <gitster@pobox.com>2011-10-13 12:16:36 -0700
commit035b5bf6431dbf8f3cde2f44b0d7ef893b95b605 (patch)
treec4cffa6060f66c01f48857a05a12bf8727c3cfa7
parente2eb527345d48881dac0d88e6bdfc0a267a2eb62 (diff)
downloadgit-035b5bf6431dbf8f3cde2f44b0d7ef893b95b605.tar.gz
pull,rebase: handle GIT_WORK_TREE better
You can't currently run git-pull or git-rebase from outside of the work tree, even with GIT_WORK_TREE set, due to an overeager require_work_tree function. Commit e2eb527 documents this problem and provides the infrastructure for a fix, but left it to later commits to audit and update individual scripts. Changing these scripts to use require_work_tree_exists is easy to verify. We immediately call cd_to_toplevel, anyway. Therefore no matter which function we use, the state afterwards is one of: 1. We have a work tree, and we are at the top level. 2. We don't have a work tree, and we have died. The only catch is that we must also make sure no code that ran before the cd_to_toplevel assumed that we were already in the working tree. In this case, we will only have included shell libraries and called set_reflog_action, neither of which care about the current working directory at all. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgit-pull.sh2
-rwxr-xr-xgit-rebase.sh2
2 files changed, 2 insertions, 2 deletions
diff --git a/git-pull.sh b/git-pull.sh
index eb87f49062..7500b58ff9 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -10,7 +10,7 @@ SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
. git-sh-setup
set_reflog_action "pull $*"
-require_work_tree
+require_work_tree_exists
cd_to_toplevel
diff --git a/git-rebase.sh b/git-rebase.sh
index cbb0ea90ed..60a405d1fb 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -31,7 +31,7 @@ SUBDIRECTORY_OK=Yes
OPTIONS_SPEC=
. git-sh-setup
set_reflog_action rebase
-require_work_tree
+require_work_tree_exists
cd_to_toplevel
LF='