From: Junio C Hamano <gitster@pobox.com>
To: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: [PATCH 1/1] stash apply: report status correctly even in a worktree's subdirectory
Date: Fri, 04 Oct 2019 07:22:57 +0900 [thread overview]
Message-ID: <xmqqk19lbha6.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <a687c16b824ec9ab45d1e2c39a5470ed89153fc0.1569415522.git.gitgitgadget@gmail.com> (Johannes Schindelin via GitGitGadget's message of "Wed, 25 Sep 2019 05:45:24 -0700 (PDT)")
"Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> diff --git a/builtin/stash.c b/builtin/stash.c
> index b5a301f24d..a1e2e7ae7e 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -497,6 +497,8 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
> */
> cp.git_cmd = 1;
> cp.dir = prefix;
> + argv_array_pushf(&cp.env_array, GIT_WORK_TREE_ENVIRONMENT"=%s",
> + absolute_path(get_git_work_tree()));
> argv_array_push(&cp.args, "status");
> run_command(&cp);
> }
Nicely spotted. Exporting GIT_WORK_TREE alone without GIT_DIR feels
a bit disturbing, at least to me, though.
I wondered if this misbehaves when the end user has GIT_WORK_TREE
environment exported, but in such a case, get_git_work_tree() would
return that directory, and by re-exporting it to the child process,
we would honor the end user's intention, so all is good, I think.
Thanks.
> diff --git a/t/t3908-stash-in-worktree.sh b/t/t3908-stash-in-worktree.sh
> new file mode 100755
> index 0000000000..2b2b366ef9
> --- /dev/null
> +++ b/t/t3908-stash-in-worktree.sh
> @@ -0,0 +1,27 @@
> +#!/bin/sh
> +#
> +# Copyright (c) 2019 Johannes E Schindelin
> +#
> +
> +test_description='Test git stash in a worktree'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'setup' '
> + test_commit initial &&
> + git worktree add wt &&
> + test_commit -C wt in-worktree
> +'
> +
> +test_expect_success 'apply in subdirectory' '
> + mkdir wt/subdir &&
> + (
> + cd wt/subdir &&
> + echo modified >../initial.t &&
> + git stash &&
> + git stash apply >out
> + ) &&
> + grep "\.\.\/initial\.t" wt/subdir/out
> +'
> +
> +test_done
next prev parent reply other threads:[~2019-10-03 22:23 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 [this message]
2019-10-04 9:19 ` Johannes Schindelin
2019-10-04 12:30 ` [PATCH v2 0/1] stash apply: be prepared to run " Johannes Schindelin via GitGitGadget
2019-10-04 12:30 ` [PATCH v2 1/1] stash apply: report status correctly even " 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=xmqqk19lbha6.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.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).