All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Krefting <peter@softwolves.pp.se>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Osipov, Michael (IN IT IN)" <michael.osipov@innomotics.com>,
	 git@vger.kernel.org
Subject: [RFC PATCH] bisect: Honor log.date
Date: Thu, 28 Mar 2024 21:53:40 +0100 (CET)	[thread overview]
Message-ID: <4727b78c-e45b-da7c-fa6e-85876b50dcde@softwolves.pp.se> (raw)
In-Reply-To: <xmqq1q7ygex1.fsf@gitster.g>

When bisect finds the target commit to display, it calls git diff-tree
to do so. This is a plumbing command that is not affected by the user's
log.date setting. Switch to instead use "git show", which does honor
it.

Reported-by: Michael Osipov <michael.osipov@innomotics.com>
Signed-off-By: Peter Krefting <peter@softwolves.pp.se>
---
  bisect.c | 26 +++++++++++---------------
  1 file changed, 11 insertions(+), 15 deletions(-)

Junio C Hamano:

> Instead of focusing too narrowly on the log.date option, that would 
> only tweak the date format, it may be a more fruitful way to invest 
> brainwaves in to consider the feasibility of switching to use "git 
> show" there.

Indeed.

Here is a patch that does exactly that.

This is my first patch to the actual codebase in Git, so it might be 
bit rough; improvements are welcome. I might need to change something 
in the test suite as well?

With this patch applied, running with log.date=iso and 
log.decorate=short, I get this output:

  $ ./git-bisect start
  [...]
  $ ./git-bisect good v2.43.2
  [...]
  $ ./git-bisect bad v2.43.3
  [...]
  $ ./git-bisect good
  0d464a4e6a5a19bd8fbea1deae22d48d14dccb01 is the first bad commit
  commit 0d464a4e6a5a19bd8fbea1deae22d48d14dccb01 (tag: v2.43.3)
  Author: Junio C Hamano <gitster@pobox.com>
  Date:   2024-02-22 16:13:38 -0800

      Git 2.43.3

  Signed-off-by: Junio C Hamano <gitster@pobox.com>

which is the format I expect.

diff --git a/bisect.c b/bisect.c
index 8487f8cd1b..0f7126c32b 100644
--- a/bisect.c
+++ b/bisect.c
@@ -959,23 +959,19 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r,
  }

  /*
- * This does "git diff-tree --pretty COMMIT" without one fork+exec.
+ * Runs "git show" to display a commit
   */
-static void show_diff_tree(struct repository *r,
-			   const char *prefix,
-			   struct commit *commit)
+static void show_commit(struct commit *commit)
  {
-	const char *argv[] = {
-		"diff-tree", "--pretty", "--stat", "--summary", "--cc", NULL
-	};
-	struct rev_info opt;
+	struct child_process show = CHILD_PROCESS_INIT;

-	git_config(git_diff_ui_config, NULL);
-	repo_init_revisions(r, &opt, prefix);
-
-	setup_revisions(ARRAY_SIZE(argv) - 1, argv, &opt, NULL);
-	log_tree_commit(&opt, commit);
-	release_revisions(&opt);
+	/* Invoke "git show --pretty=medium --shortstat --no-abbrev-commit --no-patch $object" */
+	strvec_pushl(&show.args, "show", "--pretty=medium", "--shortstat", "--no-abbrev-commit", "--no-patch",
+		     oid_to_hex(&commit->object.oid), NULL);
+	show.git_cmd = 1;
+	if (run_command(&show))
+		die(_("unable to start 'show' for object '%s'"),
+		    oid_to_hex(&commit->object.oid));
  }

  /*
@@ -1092,7 +1088,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
  		printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
  			term_bad);

-		show_diff_tree(r, prefix, revs.commits->item);
+		show_commit(revs.commits->item);
  		/*
  		 * This means the bisection process succeeded.
  		 * Using BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND (-10)
-- 
2.39.2


  reply	other threads:[~2024-03-28 20:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 11:07 bisect does not respect 'log.date' Osipov, Michael (IN IT IN)
2024-03-13 18:24 ` Junio C Hamano
2024-03-13 19:26   ` Osipov, Michael (IN IT IN)
2024-03-25 20:27     ` Peter Krefting
2024-03-25 21:49       ` Junio C Hamano
2024-03-28 20:53         ` Peter Krefting [this message]
2024-03-28 21:38           ` [RFC PATCH] bisect: Honor log.date Eric Sunshine
2024-03-28 23:18             ` Peter Krefting

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=4727b78c-e45b-da7c-fa6e-85876b50dcde@softwolves.pp.se \
    --to=peter@softwolves.pp.se \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=michael.osipov@innomotics.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.