Skip to content

Commit 035b5bf

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e2eb527 commit 035b5bf

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

git-pull.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SUBDIRECTORY_OK=Yes
1010
OPTIONS_SPEC=
1111
. git-sh-setup
1212
set_reflog_action "pull $*"
13-
require_work_tree
13+
require_work_tree_exists
1414
cd_to_toplevel
1515

1616

git-rebase.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SUBDIRECTORY_OK=Yes
3131
OPTIONS_SPEC=
3232
. git-sh-setup
3333
set_reflog_action rebase
34-
require_work_tree
34+
require_work_tree_exists
3535
cd_to_toplevel
3636

3737
LF='

0 commit comments

Comments
 (0)