From: Junio C Hamano <gitster@pobox.com>
To: "brian m. carlson" <sandals@crustytoothpaste.net>
Cc: wuzhouhui <wuzhouhui14@mails.ucas.ac.cn>, git@vger.kernel.org
Subject: Re: how to automatically open conflicted files when "git rebase" encounter conflict
Date: Fri, 18 Mar 2022 14:25:31 -0700 [thread overview]
Message-ID: <xmqqv8wb6jhw.fsf@gitster.g> (raw)
In-Reply-To: <YjToDb9Mz9Q9z4Bq@camp.crustytoothpaste.net> (brian m. carlson's message of "Fri, 18 Mar 2022 20:14:05 +0000")
"brian m. carlson" <sandals@crustytoothpaste.net> writes:
> Fortunately, there are lots of ways to do this. The way I happen to do
> it is with an alias:
>
> [alias]
> conflicted = "!f() { git status -s | grep -E '^(DD|AA|.U|U.)' | cut -b4-; };f"
>
> and then I run this:
>
> git conflicted | xargs nvim-gtk
>
> To preempt someone pointing this out, you would want to use "git status
> --porcelain" for scripting instead of "git status -s", but I happen to
> know what I'm doing in this particular case (and have reasons for it)
> and can fix things if it breaks. You should probably use --porcelain.
I wonder if adding "--name-only" support to "ls-files" helps here.
It would make the above
git ls-files [-z] --name-only -u | xargs [-0] editor
As your "grep -E" pattern indicates, "status" makes another
comparison with HEAD that we do not even use, when we only need to
list the unmerged paths in the index.
There is no "--[no-]name-only", and "-s" (for obvious reasons) asks
to show the mode, stage, and the object name information. When we
added "-u", we said "if you are asking for conflicted paths, you of
course want to know the stage information" without questioning the
wisdom of that decision, especially as Linus and I were both in the
mindset to produce a small building-block to be used in a script
back then, and for a tool that deals with an unmerged index, having
the path alone is not all that useful.
But with time, we learn more needs out of our existing tools.
prev parent reply other threads:[~2022-03-18 21:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 2:00 how to automatically open conflicted files when "git rebase" encounter conflict wuzhouhui
2022-03-18 4:11 ` Junio C Hamano
2022-03-18 16:01 ` Erik Cervin Edin
2022-03-19 2:01 ` wuzhouhui
2022-03-18 16:00 ` Erik Cervin Edin
2022-03-18 18:24 ` Junio C Hamano
2022-03-18 20:14 ` brian m. carlson
2022-03-18 21:25 ` Junio C Hamano [this message]
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=xmqqv8wb6jhw.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=sandals@crustytoothpaste.net \
--cc=wuzhouhui14@mails.ucas.ac.cn \
/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 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 NNTP newsgroup(s).