All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Denton Liu <liu.denton@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v3 1/2] stash show: teach --include-untracked and --only-untracked
Date: Tue, 16 Feb 2021 12:22:52 -0800	[thread overview]
Message-ID: <xmqqczwzpxsz.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <85b81f2f06bd1b40ee2de220cc84dd74b425daf3.1613459475.git.liu.denton@gmail.com> (Denton Liu's message of "Mon, 15 Feb 2021 23:11:56 -0800")

Denton Liu <liu.denton@gmail.com> writes:

> +static void diff_include_untracked(const struct stash_info *info, struct diff_options *diff_opt)
> +{
> +	const struct object_id *oid[] = { &info->w_commit, &info->u_tree };
> +	struct tree *tree[ARRAY_SIZE(oid)];
> +	struct tree_desc tree_desc[ARRAY_SIZE(oid)];
> +	struct unpack_trees_options unpack_tree_opt = { 0 };
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(oid); i++) {
> +		tree[i] = parse_tree_indirect(oid[i]);
> +		if (parse_tree(tree[i]) < 0)
> +			die(_("failed to parse tree"));
> +		init_tree_desc(&tree_desc[i], tree[i]->buffer, tree[i]->size);
> +	}
> +
> +	unpack_tree_opt.head_idx = -1;
> +	unpack_tree_opt.src_index = &the_index;
> +	unpack_tree_opt.dst_index = &the_index;
> +	unpack_tree_opt.fn = twoway_merge;

OK, it looks like this was borrowed from read_tree implementation
for reading two trees into the index, sort-of, but is a bit funny.

The setting of .fn to twoway_merge is misleading.  The .fn callback
is to be used when .merge is set (otherwise nothing should call it
inside unpack-trees.c), but nobody seems to set opt.merge to true.

> +	if (unpack_trees(ARRAY_SIZE(tree_desc), tree_desc, &unpack_tree_opt))
> +		die(_("failed to unpack trees"));
> +
> +	do_diff_cache(&info->b_commit, diff_opt);
> +}

Nice to see that it was just a simple matter of programming ;-)



 builtin/stash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git c/builtin/stash.c w/builtin/stash.c
index c788a3e236..7e0204bd8a 100644
--- c/builtin/stash.c
+++ w/builtin/stash.c
@@ -807,10 +807,11 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op
 		init_tree_desc(&tree_desc[i], tree[i]->buffer, tree[i]->size);
 	}
 
+	/* mimic "git read-tree W U" without "-m" */
 	unpack_tree_opt.head_idx = -1;
 	unpack_tree_opt.src_index = &the_index;
 	unpack_tree_opt.dst_index = &the_index;
-	unpack_tree_opt.fn = twoway_merge;
+	unpack_tree_opt.fn = NULL;
 
 	if (unpack_trees(ARRAY_SIZE(tree_desc), tree_desc, &unpack_tree_opt))
 		die(_("failed to unpack trees"));

  reply	other threads:[~2021-02-16 20:23 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02  9:31 [PATCH 0/9] stash show: learn --include-untracked and --only-untracked Denton Liu
2021-02-02  9:33 ` Denton Liu
2021-02-02  9:33 ` [PATCH 1/9] git-stash.txt: be explicit about subcommand options Denton Liu
2021-02-02 17:37   ` Eric Sunshine
2021-02-02  9:33 ` [PATCH 2/9] t3905: remove spaces after redirect operators Denton Liu
2021-02-02  9:33 ` [PATCH 3/9] t3905: move all commands into test cases Denton Liu
2021-02-02 21:41   ` Junio C Hamano
2021-02-02  9:33 ` [PATCH 4/9] t3905: remove nested git in command substitution Denton Liu
2021-02-02  9:33 ` [PATCH 5/9] t3905: replace test -s with test_file_not_empty Denton Liu
2021-02-02  9:33 ` [PATCH 6/9] t3905: use test_cmp() to check file contents Denton Liu
2021-02-02  9:33 ` [PATCH 7/9] stash: declare ref_stash as an array Denton Liu
2021-02-02 21:46   ` Junio C Hamano
2021-02-02  9:33 ` [PATCH 8/9] stash show: teach --include-tracked and --only-untracked Denton Liu
2021-02-02 21:56   ` Junio C Hamano
2021-02-02  9:33 ` [PATCH 9/9] stash show: learn stash.showIncludeUntracked Denton Liu
2021-02-09  7:28 ` [PATCH v2 0/9] stash show: learn --include-untracked and --only-untracked Denton Liu
2021-02-09  7:28   ` [PATCH v2 1/9] git-stash.txt: be explicit about subcommand options Denton Liu
2021-02-10  7:17     ` Junio C Hamano
2021-02-11 19:07       ` [PATCH] fixup! " Denton Liu
2021-02-09  7:28   ` [PATCH v2 2/9] t3905: remove spaces after redirect operators Denton Liu
2021-02-10  7:18     ` Junio C Hamano
2021-02-09  7:28   ` [PATCH v2 3/9] t3905: move all commands into test cases Denton Liu
2021-02-09  7:28   ` [PATCH v2 4/9] t3905: remove nested git in command substitution Denton Liu
2021-02-10  7:24     ` Junio C Hamano
2021-02-09  7:28   ` [PATCH v2 5/9] t3905: replace test -s with test_file_not_empty Denton Liu
2021-02-09  7:28   ` [PATCH v2 6/9] t3905: use test_cmp() to check file contents Denton Liu
2021-02-09  7:28   ` [PATCH v2 7/9] stash: declare ref_stash as an array Denton Liu
2021-02-10  7:28     ` Junio C Hamano
2021-02-09  7:28   ` [PATCH v2 8/9] stash show: teach --include-untracked and --only-untracked Denton Liu
2021-02-10  7:53     ` Junio C Hamano
2021-02-16  3:15       ` Denton Liu
2021-02-16  6:42         ` Junio C Hamano
2021-02-09  7:28   ` [PATCH v2 9/9] stash show: learn stash.showIncludeUntracked Denton Liu
2021-02-16  7:11   ` [PATCH v3 0/2] stash show: learn --include-untracked and --only-untracked Denton Liu
2021-02-16  7:11     ` [PATCH v3 1/2] stash show: teach " Denton Liu
2021-02-16 20:22       ` Junio C Hamano [this message]
2021-02-17 11:18         ` Denton Liu
2021-02-17 17:50           ` Junio C Hamano
2021-02-17  2:31       ` Junio C Hamano
2021-02-16  7:11     ` [PATCH v3 2/2] stash show: learn stash.showIncludeUntracked Denton Liu
2021-03-03 11:16     ` [PATCH v4 0/2] stash show: learn --include-untracked and --only-untracked Denton Liu
2021-03-03 11:16       ` [PATCH v4 1/2] stash show: teach " Denton Liu
2021-03-03 11:16       ` [PATCH v4 2/2] stash show: learn stash.showIncludeUntracked Denton Liu
2021-03-04  0:38       ` [PATCH v4 0/2] stash show: learn --include-untracked and --only-untracked Junio C Hamano
2021-03-04  1:33         ` Denton Liu
2021-03-04  1:42           ` Denton Liu

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqczwzpxsz.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=liu.denton@gmail.com \
    --cc=sunshine@sunshineco.com \
    /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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.