From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, thomas.braun@virtuell-zuhause.de
Subject: Re: [PATCH 3/4] commit: don't count i-t-a entries when checking if the new commit is empty
Date: Mon, 06 Jun 2016 12:58:16 -0700 [thread overview]
Message-ID: <xmqqbn3ew0mf.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160606111643.7122-4-pclouds@gmail.com> ("Nguyễn Thái Ngọc Duy"'s message of "Mon, 6 Jun 2016 18:16:42 +0700")
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> i-t-a entries are excluded from tree building. Relying solely on active_nr
> (or diff without --shift-ita) may lead to empty commits sometimes, when
> i-t-a entries are the only ones "changed" in the index.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> builtin/commit.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/builtin/commit.c b/builtin/commit.c
> index fcfaa2b..e98ca8a 100644
> --- a/builtin/commit.c
> +++ b/builtin/commit.c
> @@ -894,9 +894,14 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
> if (amend)
> parent = "HEAD^1";
>
> - if (get_sha1(parent, sha1))
> - commitable = !!active_nr;
> - else {
> + if (get_sha1(parent, sha1)) {
> + int i, ita_nr = 0;
> +
> + for (i = 0; i < active_nr; i++)
> + if (ce_intent_to_add(active_cache[i]))
> + ita_nr++;
> + commitable = active_nr - ita_nr == 0;
> + } else {
> /*
> * Unless the user did explicitly request a submodule
> * ignore mode by passing a command line option we do
> @@ -910,6 +915,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
> if (ignore_submodule_arg &&
> !strcmp(ignore_submodule_arg, "all"))
> diff_flags |= DIFF_OPT_IGNORE_SUBMODULES;
> + diff_flags |= DIFF_OPT_SHIFT_INTENT_TO_ADD;
> commitable = index_differs_from(parent, diff_flags);
This feels like an ugly hack. Doesn't wt-status do a separate
"diff" that enumerates what's different between the index and the
HEAD?
I am wondering if this "we do not include status and do not ask
run_status() about commitable bit" codepath should share more with
the other side, which you do not touch at all with this series,
which in turn must be doing the right thing already, apparently
without having to know anything about the SHIFT_INTENT_TO_ADD
hackery.
Or does "git commit" that uses run_status() still allow an empty
commit after this patch?
next prev parent reply other threads:[~2016-06-06 19:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 11:16 [PATCH/RFC 0/4] i-t-a entries again Nguyễn Thái Ngọc Duy
2016-06-06 11:16 ` [PATCH 1/4] diff.h: extend "flags" field to 64 bits because we're out of bits Nguyễn Thái Ngọc Duy
2016-06-06 19:45 ` Junio C Hamano
2016-06-07 0:40 ` Duy Nguyen
2016-06-07 6:40 ` stefan.naewe
2016-06-06 11:16 ` [PATCH 2/4] Resurrect "diff-lib.c: adjust position of i-t-a entries in diff" Nguyễn Thái Ngọc Duy
2016-06-06 20:42 ` Junio C Hamano
2016-06-07 12:04 ` Duy Nguyen
2016-06-09 16:18 ` Johannes Schindelin
2016-09-27 10:58 ` Duy Nguyen
2016-09-27 12:27 ` Duy Nguyen
2016-06-06 11:16 ` [PATCH 3/4] commit: don't count i-t-a entries when checking if the new commit is empty Nguyễn Thái Ngọc Duy
2016-06-06 19:58 ` Junio C Hamano [this message]
2016-06-06 20:28 ` Junio C Hamano
2016-06-06 11:16 ` [PATCH/RFC 4/4] commit: reinstate commit behavior before 3f6d56d via a config option Nguyễn Thái Ngọc Duy
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=xmqqbn3ew0mf.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
--cc=thomas.braun@virtuell-zuhause.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.
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.