git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: "Justin Donnelly" <justinrdonnelly@gmail.com>,
	"Justin Donnelly via GitGitGadget" <gitgitgadget@gmail.com>,
	git@vger.kernel.org, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	newren@gmail.com, phillip.wood@dunelm.org.uk,
	Johannes.Schindelin@gmx.de
Subject: Re: [PATCH v2] git-prompt: show presence of unresolved conflicts at command prompt
Date: Mon, 15 Aug 2022 09:00:29 -0700	[thread overview]
Message-ID: <xmqqilmt4huq.fsf@gitster.g> (raw)
In-Reply-To: <08a8e78d-7861-3da3-f6f6-bba466655071@gmail.com> (Phillip Wood's message of "Mon, 15 Aug 2022 14:04:50 +0100")

Phillip Wood <phillip.wood123@gmail.com> writes:

> I had not commented as I don't use the prompt. I have just had a quick
> read and I wonder if it would be more efficient to use
>     git diff --cached --quiet --diff-filter=U
> rather than
>     git ls-files --unmerged 2>/dev/null
> to check if there are unmerged entries,

The former reads the on-disk index into in-core index, and reads
tree objects (recursively for subdirectories) referenced by the
HEAD, walks both in parallel to find differences and filters out the
result to unmerged (I am not sure how well diff-filter works with
unmerged paths, though).

The latter rads the on-disk index into in-core index, scans the
entries and finds unmerged entries.

So if we compare the overhead to run either command standalone, I am
reasonably sure that the latter would be a lot more efficient.

But if the shell prompt code already needs to run the diff-index for
other reasons (e.g. to show if there is any modification added to
the index), that may change the equation.  Instead of adding a
separate and extra call to "ls-files -u", it might be more efficient
if you can somehow piggy-back on an existing diff-index call.  For
example, you may be running "git diff --cached --quiet" for exit code
to show if any change has been added, but you can instead run "git
diff --no-ext-diff --no-renames --cached --name-status" and (1) if
there is any output, then the index is dirty, and (2) if there is a
line that begins with "U", you have an unmerged path right there.

  reply	other threads:[~2022-08-15 16:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-26  1:23 [PATCH] git-prompt: show 'CONFLICT' indicator at command prompt Justin Donnelly via GitGitGadget
2022-07-27 20:13 ` Junio C Hamano
2022-07-28  2:17   ` Justin Donnelly
2022-07-28 17:44     ` Junio C Hamano
2022-07-28 23:33       ` Justin Donnelly
2022-07-29 22:08 ` [PATCH v2] git-prompt: show presence of unresolved conflicts " Justin Donnelly via GitGitGadget
2022-08-14 21:06   ` Justin Donnelly
2022-08-15  4:22     ` Junio C Hamano
2022-08-15 12:50       ` Johannes Schindelin
2022-08-16  3:36         ` Justin Donnelly
2022-08-15 13:04       ` Phillip Wood
2022-08-15 16:00         ` Junio C Hamano [this message]
2022-08-16  4:20           ` Justin Donnelly
2022-08-16 23:32             ` Justin Donnelly
2022-08-17  0:18   ` [PATCH v3] " Justin Donnelly via GitGitGadget
2022-08-19 11:29     ` Johannes Schindelin
2022-08-19 17:57       ` Junio C Hamano

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=xmqqilmt4huq.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=justinrdonnelly@gmail.com \
    --cc=newren@gmail.com \
    --cc=phillip.wood123@gmail.com \
    --cc=phillip.wood@dunelm.org.uk \
    /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).