From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 0/1] stash apply: be prepared to run in a worktree's subdirectory
Date: Fri, 04 Oct 2019 05:30:58 -0700 (PDT) [thread overview]
Message-ID: <pull.354.v2.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.354.git.gitgitgadget@gmail.com>
I saw this issue a couple times in my setup, and always wondered why nobody
else seemed to be hit by this. When I finally found/made some time to
investigate, I found out that it really requires a specific setup: I have
many worktrees connected to my main git.git clone, often run inside t/ and I
do stash quite often (now that git stash's performance is a joy on Windows).
Changes since v1:
* We now make sure to also set GIT_DIR.
Johannes Schindelin (1):
stash apply: report status correctly even in a worktree's subdirectory
builtin/stash.c | 4 ++++
t/t3908-stash-in-worktree.sh | 27 +++++++++++++++++++++++++++
2 files changed, 31 insertions(+)
create mode 100755 t/t3908-stash-in-worktree.sh
base-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-354%2Fdscho%2Fapply-stash-in-subdirectory-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-354/dscho/apply-stash-in-subdirectory-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/354
Range-diff vs v1:
1: a687c16b82 ! 1: 4e19436fbf stash apply: report status correctly even in a worktree's subdirectory
@@ -3,15 +3,20 @@
stash apply: report status correctly even in a worktree's subdirectory
When Git wants to spawn a child Git process inside a worktree's
- subdirectory, we need to take care of specifying the work tree's
- top-level directory explicitly because it cannot be discovered: the
- current directory is _not_ the top-level directory of the work tree, and
- neither is it inside the parent directory of `GIT_DIR`.
+ subdirectory while `GIT_DIR` is set, we need to take care of specifying
+ the work tree's top-level directory explicitly because it cannot be
+ discovered: the current directory is _not_ the top-level directory of
+ the work tree, and neither is it inside the parent directory of
+ `GIT_DIR`.
This fixes the problem where `git stash apply` would report pretty much
everything deleted or untracked when run inside a worktree's
subdirectory.
+ To make sure that we do not introduce the "reverse problem", i.e. when
+ `GIT_WORK_TREE` is defined but `GIT_DIR` is not, we simply make sure
+ that both are set.
+
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
diff --git a/builtin/stash.c b/builtin/stash.c
@@ -23,6 +28,8 @@
cp.dir = prefix;
+ argv_array_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
+ absolute_path(get_git_work_tree()));
++ argv_array_pushf(&cp.env_array, GIT_DIR_ENVIRONMENT"=%s",
++ absolute_path(get_git_dir()));
argv_array_push(&cp.args, "status");
run_command(&cp);
}
--
gitgitgadget
next prev parent reply other threads:[~2019-10-04 12:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-25 12:45 [PATCH 0/1] stash apply: be prepared to run in a worktree's subdirectory Johannes Schindelin via GitGitGadget
2019-09-25 12:45 ` [PATCH 1/1] stash apply: report status correctly even " Johannes Schindelin via GitGitGadget
2019-10-03 22:22 ` Junio C Hamano
2019-10-04 9:19 ` Johannes Schindelin
2019-10-04 12:30 ` Johannes Schindelin via GitGitGadget [this message]
2019-10-04 12:30 ` [PATCH v2 " Johannes Schindelin via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.354.v2.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).