git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: <git@vger.kernel.org>, Derrick Stolee <dstolee@gmail.com>,
	Thomas Gummerer <t.gummerer@gmail.com>
Subject: Re: [PATCH 2/6] builtin/stash: fill in all commit data
Date: Wed, 16 Mar 2022 09:50:42 -0700	[thread overview]
Message-ID: <xmqqv8wdn8nx.fsf@gitster.g> (raw)
In-Reply-To: <20220310173236.4165310-3-sandals@crustytoothpaste.net> (brian m. carlson's message of "Thu, 10 Mar 2022 17:32:32 +0000")

"brian m. carlson" <sandals@crustytoothpaste.net> writes:

> get_stash_info doesn't ensure that all entries are filled in in all
> cases.  However, we'll want to use this information to write new
> commits, and when we do so, we'll need all the information to be
> present.  Fill in all the commit information whenever we call this
> function.
>
> Note that the behavior of info->has_u doesn't change here.  If we
> previously read a tree a refs/stash^3:, then refs/stash^3 must be a
> treeish.  We already here assume that the other parents specifically
> commits, so it should be safe to do so here as well.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>  builtin/stash.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/stash.c b/builtin/stash.c
> index 2aa06cc91d..128f0a01ef 100644
> --- a/builtin/stash.c
> +++ b/builtin/stash.c
> @@ -124,6 +124,7 @@ static void free_stash_info(struct stash_info *info)

Before this function ...

>  static void assert_stash_like(struct stash_info *info, const char *revision)
>  {
>  	if (get_oidf(&info->b_commit, "%s^1", revision) ||
> +	    get_oidf(&info->i_commit, "%s^2", revision) ||
>  	    get_oidf(&info->w_tree, "%s:", revision) ||
>  	    get_oidf(&info->b_tree, "%s^1:", revision) ||
>  	    get_oidf(&info->i_tree, "%s^2:", revision))

... there is this comment.

/*
 * w_commit is set to the commit containing the working tree
 * b_commit is set to the base commit
 * i_commit is set to the commit containing the index tree
 * u_commit is set to the commit containing the untracked files tree
 * w_tree is set to the working tree
 * b_tree is set to the base tree
 * i_tree is set to the index tree
 * u_tree is set to the untracked files tree
 */

We probably would want to comment that u_commit (hence u_tree) is
optional.  That is why assert_stash_like() does not say anything
about u_commit or u_tree, right?

It is curious why the function does not learn to check w_commit,
even though the proposed commit log message claims that this is
about filling all commit data.

> @@ -166,7 +167,8 @@ static int get_stash_info_1(struct stash_info *info, const char *commit, int qui
>  
>  	assert_stash_like(info, revision);
>  
> -	info->has_u = !get_oidf(&info->u_tree, "%s^3:", revision);
> +	info->has_u = !get_oidf(&info->u_commit, "%s^3", revision) &&
> +		      !get_oidf(&info->u_tree, "%s^3:", revision);
>  
>  	end_of_rev = strchrnul(revision, '@');
>  	strbuf_add(&symbolic, revision, end_of_rev - revision);

  reply	other threads:[~2022-03-16 16:50 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 17:32 [PATCH 0/6] Importing and exporting stashes to refs brian m. carlson
2022-03-10 17:32 ` [PATCH 1/6] builtin/stash: factor out generic function to look up stash info brian m. carlson
2022-03-10 17:32 ` [PATCH 2/6] builtin/stash: fill in all commit data brian m. carlson
2022-03-16 16:50   ` Junio C Hamano [this message]
2022-03-10 17:32 ` [PATCH 3/6] object-name: make get_oid quietly return an error brian m. carlson
2022-03-16 16:56   ` Junio C Hamano
2022-03-16 17:01     ` Drew Stolee
2022-03-16 21:40     ` brian m. carlson
2022-03-10 17:32 ` [PATCH 4/6] builtin/stash: provide a way to export stashes to a ref brian m. carlson
2022-03-11  2:08   ` Ævar Arnfjörð Bjarmason
2022-03-14 21:19     ` Phillip Wood
2022-03-15 10:50       ` Phillip Wood
2022-03-16 21:48       ` brian m. carlson
2022-03-18 13:34         ` C99 %zu support (on MSVC) (was: [PATCH 4/6] builtin/stash: provide a way to export stashes to a ref) Ævar Arnfjörð Bjarmason
2022-03-18 16:26           ` Phillip Wood
2022-03-24 14:02         ` [PATCH 4/6] builtin/stash: provide a way to export stashes to a ref Johannes Schindelin
2022-03-18 13:41       ` ssize_t portability (was: [PATCH 4/6] builtin/stash: provide a way to export stashes to a ref) Ævar Arnfjörð Bjarmason
2022-03-16 17:05   ` [PATCH 4/6] builtin/stash: provide a way to export stashes to a ref Junio C Hamano
2022-03-10 17:32 ` [PATCH 5/6] builtin/stash: provide a way to import stashes from " brian m. carlson
2022-03-16 17:26   ` Junio C Hamano
2022-03-16 21:50     ` brian m. carlson
2022-03-10 17:32 ` [PATCH 6/6] doc: add stash export and import to docs brian m. carlson
2022-03-16 17:34   ` Junio C Hamano
2022-03-16 21:44     ` Junio C Hamano
2022-03-10 19:14 ` [PATCH 0/6] Importing and exporting stashes to refs Junio C Hamano
2022-03-10 21:04   ` brian m. carlson
2022-03-10 21:38     ` Junio C Hamano
2022-03-10 22:42       ` brian m. carlson
2022-03-29 21:49 ` [PATCH v2 0/4] " brian m. carlson
2022-03-29 21:49   ` [PATCH v2 1/4] object-name: make get_oid quietly return an error brian m. carlson
2022-03-29 21:49   ` [PATCH v2 2/4] builtin/stash: factor out revision parsing into a function brian m. carlson
2022-03-29 21:49   ` [PATCH v2 3/4] builtin/stash: provide a way to export stashes to a ref brian m. carlson
2022-03-30 23:05     ` Junio C Hamano
2022-03-30 23:44       ` brian m. carlson
2022-03-31  1:56     ` Ævar Arnfjörð Bjarmason
2022-03-31 17:43       ` Junio C Hamano
2022-04-05 10:55       ` brian m. carlson
2022-04-06  9:05         ` Ævar Arnfjörð Bjarmason
2022-04-06 16:38         ` Junio C Hamano
2022-03-31  2:09     ` Ævar Arnfjörð Bjarmason
2022-04-05 10:22       ` brian m. carlson
2022-03-29 21:49   ` [PATCH v2 4/4] builtin/stash: provide a way to import stashes from " brian m. carlson
2022-03-31  1:48   ` [PATCH v2 0/4] Importing and exporting stashes to refs Junio C Hamano
2022-03-31  2:18     ` Ævar Arnfjörð Bjarmason
2022-04-03 18:22 ` [PATCH v3 " brian m. carlson
2022-04-03 18:22   ` [PATCH v3 1/4] object-name: make get_oid quietly return an error brian m. carlson
2022-04-03 18:22   ` [PATCH v3 2/4] builtin/stash: factor out revision parsing into a function brian m. carlson
2022-04-04 15:44     ` Phillip Wood
2022-04-03 18:22   ` [PATCH v3 3/4] builtin/stash: provide a way to export stashes to a ref brian m. carlson
2022-04-04  6:46     ` Ævar Arnfjörð Bjarmason
2022-04-03 18:22   ` [PATCH v3 4/4] builtin/stash: provide a way to import stashes from " brian m. carlson
2022-04-04 10:38     ` Ævar Arnfjörð Bjarmason
2022-04-05 10:03       ` brian m. carlson
2022-04-06  9:00         ` Ævar Arnfjörð Bjarmason
2022-04-04  0:05   ` [PATCH v3 0/4] Importing and exporting stashes to refs Junio C Hamano
2022-04-04  0:29     ` Junio C Hamano
2022-04-04  6:20       ` Ævar Arnfjörð Bjarmason
2022-04-05  9:15         ` brian m. carlson
2022-04-07 21:53 ` [PATCH v4 " brian m. carlson
2022-04-07 21:53   ` [PATCH v4 1/4] object-name: make get_oid quietly return an error brian m. carlson
2022-04-07 21:53   ` [PATCH v4 2/4] builtin/stash: factor out revision parsing into a function brian m. carlson
2022-04-07 21:53   ` [PATCH v4 3/4] builtin/stash: provide a way to export stashes to a ref brian m. carlson
2022-04-13 15:29     ` Ævar Arnfjörð Bjarmason
2022-04-13 15:36     ` Ævar Arnfjörð Bjarmason
2022-04-13 15:55     ` Ævar Arnfjörð Bjarmason
2022-04-07 21:53   ` [PATCH v4 4/4] builtin/stash: provide a way to import stashes from " brian m. carlson
2022-04-12 20:14     ` Jonathan Tan
2022-04-13  1:12       ` brian m. carlson
2022-04-13 17:34         ` Jonathan Tan
2022-04-13 18:25         ` Ævar Arnfjörð Bjarmason
2022-04-13 19:14           ` Jonathan Tan
2022-04-13 20:10         ` Junio C Hamano
2022-04-13 21:33           ` brian m. carlson
2022-04-13 21:43             ` Junio C Hamano
2022-04-13 18:33     ` Ævar Arnfjörð Bjarmason
2022-04-13 15:25   ` [PATCH v4 0/4] Importing and exporting stashes to refs Ævar Arnfjörð Bjarmason

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=xmqqv8wdn8nx.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=dstolee@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sandals@crustytoothpaste.net \
    --cc=t.gummerer@gmail.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.
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).