unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master b5b0e05: Call `smerge-start-session' even when dealing with a stash conflict
Date: Mon, 20 Apr 2015 11:25:34 -0400	[thread overview]
Message-ID: <jwvlhhmeswg.fsf-monnier+emacsdiffs@gnu.org> (raw)
In-Reply-To: <5534FB9D.4070502@yandex.ru> (Dmitry Gutov's message of "Mon, 20 Apr 2015 16:14:05 +0300")

>> Better would be for vc-git-resolve-when-done to check the status of the
>> file and only `git add' it if it doesn't have anything staged yet.  So,
>> it would still work as before in the case where there was nothing staged
>> before the "stash pop".
> Hmm, it seem I can't really detect whether the file had something staged
> (whether the conflict is due to that, or some new commits, 'git
> diff --cached', for instance, only says '* Unmerged path test2').

"git status --porcelain <file>" gives me:

  "M  <file>"

for a file with staged changes

  " M <file>"

for a modified file with no staged changes, and

  "MM <file>"

for a modified file with both staged and unstaged changes.  So I think
that looking for "\\`M" in the output of "git status --porcelain"
should work.

Of course, what I'm proposing would still add the file to the staging
area, even if the user did not originally intend to do so, but at least
there's no serious loss of information (the only loss of information is
"which files(s)'s changes were already staged and which weren't").

> Guess I'm not enough of an aficionado, then.  After plenty of searching and
> reading the man pages, 'git add' followed by 'git reset' is the best I have.

Well, if you're not afraid of getting gross, you could do something
along the lines of:

   unstaged=$(git diff -- <file>)
   git add <file>
   echo "$unstaged" | patch -R -p1
   git add <file>
   echo "$unstaged" | patch -p1


-- Stefan



  parent reply	other threads:[~2015-04-20 15:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20150419192734.3632.17817@vcs.savannah.gnu.org>
     [not found] ` <E1YjusQ-0000xG-6u@vcs.savannah.gnu.org>
2015-04-20  2:48   ` [Emacs-diffs] master b5b0e05: Call `smerge-start-session' even when dealing with a stash conflict Stefan Monnier
2015-04-20 13:14     ` Dmitry Gutov
2015-04-20 13:35       ` Dmitry Gutov
2015-04-20 14:54       ` Eli Zaretskii
2015-04-20 15:25       ` Stefan Monnier [this message]
2015-04-20 15:54         ` Dmitry Gutov
2015-04-20 19:39           ` Stefan Monnier
2015-04-20 21:06             ` Dmitry Gutov
2015-04-20 14:46     ` Eli Zaretskii

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: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvlhhmeswg.fsf-monnier+emacsdiffs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /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://git.savannah.gnu.org/cgit/emacs.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).