Hi,

It is a bit of a wild guess, so please if anyone can correct me if needs
be, but when you have a conflict, your conflicting files are in your index
already and `git diff-index` then does not pick the changes.

However, if you use:

    git diff -G '^(<|=|>){7}' --diff-filter U --name-only

It seems to achieve what you want.
For example, I have below a fake repo with a file `foo` and a file `bar`.
`foo` has some modifications (staged and not staged), which both contain
"conflicts-like" strings (see diff). `bar` has an actual conflict (It is
unmerged).

Running the previous command outputs only `bar`, which is the only file
matching the regex and unmerged.

ghislain@ubuntu: /tmp/tmp (master *+$) ✔
> git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

modified:   foo

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

both modified:   bar

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

modified:   foo

ghislain@ubuntu: /tmp/tmp (master *+$) ✔
> git diff
diff --cc bar
index bb3367f,99c3cae..0000000
--- a/bar
+++ b/bar
@@@ -1,1 -1,1 +1,5 @@@
++<<<<<<< Updated upstream
 +new bar change
++=======
+ bar change
++>>>>>>> Stashed changes
diff --git a/foo b/foo
index 84e1f2b..f9ae9bc 100644
--- a/foo
+++ b/foo
@@ -1,2 +1,3 @@
 foo change
 <<<<<<<
+=======
ghislain@ubuntu: /tmp/tmp (master *+$) ✔
> git diff --cached
* Unmerged path bar
diff --git a/foo b/foo
index e69de29..84e1f2b 100644
--- a/foo
+++ b/foo
@@ -0,0 +1,2 @@
+foo change
+<<<<<<<

I hope it will help.

Ghislain


On 21 March 2018 at 13:41, Роман Чумак <isitema...@gmail.com> wrote:

> Hello.
> I need to filter unmerged files on my repo which have conflict markers ,
> such us <<<<<<< , ====== and >>>>>>>.
> It would be a nice to use  a single command and expected result - files
> path.
> I tried:
> git diff-index --name-only -G "^(<|=|>){7} " HEAD --diff-filter=U
>
>
> Does anybody have any idea what's wrong with that command ?
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Git for human beings" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to git-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to