From: Erik Faye-Lund <kusmabite@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, matthieu.moy@grenoble-inp.fr, hellmuth@ira.uka.de
Subject: [PATCH] add -p: skip conflicted paths
Date: Wed, 28 Mar 2012 22:20:17 +0200 [thread overview]
Message-ID: <1332966017-6100-1-git-send-email-kusmabite@gmail.com> (raw)
In-Reply-To: <7viphov839.fsf@alter.siamese.dyndns.org>
When performing "git add -p" on a file in a conflicted state, we
currently spew the diff and terminate the process.
This is not very helpful to the user. Change the behaviour to
skipping the file, while outputting a warning.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
---
On Wed, Mar 28, 2012 at 9:28 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Perhaps teach list_modified(), which currently takes 'file-only' and
> 'index-only', to also take an option to omit (and warn if it is
> appropriate) unmerged paths?
Good idea. This way, the path doesn't even get listed when using
git add -i, and no warning is spewed on "git add -p" without specifying
the path. It seems like the right thing to do.
Again, I'm no Perl-guru, so apologies if the code isn't idiomatic.
git-add--interactive.perl | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 8f0839d..4913203 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -270,7 +270,7 @@ sub get_empty_tree {
# FILE_ADDDEL: is it add/delete between index and file?
sub list_modified {
- my ($only) = @_;
+ my ($only, $omit_unmerged) = @_;
my (%data, @return);
my ($add, $del, $adddel, $file);
my @tracked = ();
@@ -359,6 +359,10 @@ sub list_modified {
next if ($it->{FILE} eq 'nothing');
}
}
+ if ($omit_unmerged && run_cmd_pipe(qw(git ls-files -u --), $_)) {
+ print colored $error_color, "Warning: $_ is in conflicted state, skipping.\n" if @ARGV;
+ next;
+ }
push @return, +{
VALUE => $_,
%$it,
@@ -1189,7 +1193,7 @@ sub apply_patch_for_checkout_commit {
}
sub patch_update_cmd {
- my @all_mods = list_modified($patch_mode_flavour{FILTER});
+ my @all_mods = list_modified($patch_mode_flavour{FILTER}, 1);
my @mods = grep { !($_->{BINARY}) } @all_mods;
my @them;
--
1.7.9
next prev parent reply other threads:[~2012-03-28 20:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-28 19:18 [PATCH] add -p: skip conflicted paths Erik Faye-Lund
2012-03-28 19:28 ` Junio C Hamano
2012-03-28 20:20 ` Erik Faye-Lund [this message]
2012-03-28 21:39 ` Junio C Hamano
2012-03-28 21:58 ` Junio C Hamano
2012-03-28 22:14 ` Junio C Hamano
2012-03-29 5:45 ` Jeff King
2012-04-02 17:20 ` Erik Faye-Lund
2012-04-02 18:25 ` Junio C Hamano
2012-04-04 9:46 ` Jeff King
2012-04-04 12:50 ` Tay Ray Chuan
2012-04-04 15:36 ` Junio C Hamano
2012-04-04 18:29 ` Junio C Hamano
2012-04-04 20:25 ` Jeff King
2012-04-04 21:31 ` Junio C Hamano
2012-04-05 12:30 ` Jeff King
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=1332966017-6100-1-git-send-email-kusmabite@gmail.com \
--to=kusmabite@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hellmuth@ira.uka.de \
--cc=matthieu.moy@grenoble-inp.fr \
/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).