{"thread":{"id":"20355","subject":"conflict status","startedAt":"2009-08-03T15:14:00Z","lastAt":"2009-08-04T07:56:35Z","messageCount":8,"participants":["Michael Wild","Sverre Rabbelier","Thomas Rast","Junio C Hamano","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"119411","messageId":"DDAD985F-C9CA-4159-B382-354D4B082C19@users.sourceforge.net","threadId":"20355","inReplyTo":null,"subject":"conflict status","fromName":"Michael Wild","fromEmail":"themiwi@users.sourceforge.net","sentAt":"2009-08-03T15:14:00Z","receivedAt":"2009-08-03T15:14:00Z","isPatch":false,"sender":{"key":"themiwi@users.sourceforge.net","avatar":"https://gravatar.com/avatar/9dbb9d449a09f3b523df6a16f8d0b46ba772d7a2793ddf1371555e82776edb70?d=mp&s=160"},"body":"Hi all\n\nI'm merging two branches with a large number of conflicts.  \nFortunately, there are many modified/deleted conflicts (locally  \nmodified, remotely deleted), and I know that for those I want to pick  \nthe deleted version. However, I can't seem to motivate GIT into  \ntelling me for which of the conflicting files this is the case. I know  \nthat git-mergetool somehow extracts this information, but looking at  \nthe code, it seems to me that there must be an easier, user-level  \nmethod of obtaining this information.\n\nGenerally speaking, I would like to know for each file with a conflict  \nwhat it's status is, similar to what SVN does:\n- locally modified/created/deleted/...\n- remotely modified/created/deleted/...\n\nPlease excuse me if this is either trivial or has been answered many  \ntimes before, but neither perusing the man-pages, nor asking google  \nturned up anything remotely useful.\n\nThanks for the help\n\nMichael\n"},{"id":"119416","messageId":"fabb9a1e0908031037t16a828f6h4de9fb11bcc957fe@mail.gmail.com","threadId":"20355","inReplyTo":"DDAD985F-C9CA-4159-B382-354D4B082C19@users.sourceforge.net","subject":"Re: conflict status","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2009-08-03T17:37:19Z","receivedAt":"2009-08-03T17:37:19Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Mon, Aug 3, 2009 at 08:14, Michael Wild<themiwi@users.sourceforge.net> wrote:\n> Generally speaking, I would like to know for each file with a conflict what\n> it's status is, similar to what SVN does:\n> - locally modified/created/deleted/...\n> - remotely modified/created/deleted/...\n\nTry 'git status' :),\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"119422","messageId":"200908032017.35101.trast@student.ethz.ch","threadId":"20355","inReplyTo":"fabb9a1e0908031037t16a828f6h4de9fb11bcc957fe@mail.gmail.com","subject":"Re: conflict status","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-08-03T18:17:33Z","receivedAt":"2009-08-03T18:17:33Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"You wrote:\n> Heya,\n> \n> On Mon, Aug 3, 2009 at 08:14, Michael Wild<themiwi@users.sourceforge.net> wrote:\n> > Generally speaking, I would like to know for each file with a conflict what\n> > it's status is, similar to what SVN does:\n> > - locally modified/created/deleted/...\n> > - remotely modified/created/deleted/...\n> \n> Try 'git status' :),\n\nThat only shows 'unmerged: foo' for me...\n\nThe closest to porcelain I can get while still having all the\ninformation is\n\n  $ git ls-files -s foo\n  100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 1       foo\n  100644 d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 2       foo\n\nIn other words, not porcelain at all.\n\nThe third column is the stage: 1 for base, 2 for ours, 3 for theirs.\nSo the above means that the file was changed between base and ours,\nand removed between base and theirs (as the entry is missing).\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"119424","messageId":"7vvdl4925k.fsf@alter.siamese.dyndns.org","threadId":"20355","inReplyTo":"200908032017.35101.trast@student.ethz.ch","subject":"Re: conflict status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-03T18:35:03Z","receivedAt":"2009-08-03T18:35:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thomas Rast <trast@student.ethz.ch> writes:\n\n> That only shows 'unmerged: foo' for me...\n>\n> The closest to porcelain I can get while still having all the\n> information is\n>\n>   $ git ls-files -s foo\n>   100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 1       foo\n>   100644 d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 2       foo\n>\n> In other words, not porcelain at all.\n\n\"git ls-files -u\" would be what you want.  It shows all the paths with\nconflicts in the index, and omits paths without conflicts in the index.\nAnd the object names allow you to inspect the individual stages.\n"},{"id":"119471","messageId":"4F52523A-2CEA-4CD3-A094-A2627E2A4403@users.sourceforge.net","threadId":"20355","inReplyTo":"7vvdl4925k.fsf@alter.siamese.dyndns.org","subject":"Re: conflict status","fromName":"Michael Wild","fromEmail":"themiwi@users.sourceforge.net","sentAt":"2009-08-04T07:10:00Z","receivedAt":"2009-08-04T07:10:00Z","isPatch":false,"sender":{"key":"themiwi@users.sourceforge.net","avatar":"https://gravatar.com/avatar/9dbb9d449a09f3b523df6a16f8d0b46ba772d7a2793ddf1371555e82776edb70?d=mp&s=160"},"body":"\nOn 3. Aug, 2009, at 20:35, Junio C Hamano wrote:\n\n> Thomas Rast <trast@student.ethz.ch> writes:\n>\n>> That only shows 'unmerged: foo' for me...\n>>\n>> The closest to porcelain I can get while still having all the\n>> information is\n>>\n>>  $ git ls-files -s foo\n>>  100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 1       foo\n>>  100644 d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 2       foo\n>>\n>> In other words, not porcelain at all.\n>\n> \"git ls-files -u\" would be what you want.  It shows all the paths with\n> conflicts in the index, and omits paths without conflicts in the  \n> index.\n> And the object names allow you to inspect the individual stages.\n>\n\n\nI found out about that one too (by having a look at git-mergetool),  \nand came up with the following quick hack (doesn't take any arguments/ \noptions, is very rough and slow for a large number of conflicts). For  \neach unmerged file it displays the file name, prefixed with the local  \nand remote state. Possible states are \"c\" for created, \"m\" for  \nmodified and \"d\" for deleted. Probably there are other cases I'm not  \naware of and require special handling.\n\n#!/bin/sh\n# displays the merge status of files\n\n# TODO all the niceties, bells and whistles...\nUSAGE=''\n# requires PWD to be top-level\nunset SUBDIRECTORY_OK\n  . \"$(git --exec-path)/git-sh-setup\"\n# obviously...\nrequire_work_tree\n\n# describe the state (deleted, modified or created)\ndescribe_state () {\n   mode=\"$1\"\n\n   if test -z \"$mode\"; then\n     printf \"d \"\n   else\n     if test -n \"$base_mode\"; then\n       printf \"m \"\n     else\n       printf \"c \"\n     fi\n   fi\n}\n\n# get all conflicts\nconflicts=\"$(git-status | awk '/unmerged:/{print $3;next}')\"\n\nfor f in $conflicts; do\n   # extract the file mode for base, local and remote\n   base_mode=$(git ls-files -u -- \"$f\" | awk '{if ($3==1) print $1;}')\n   local_mode=$(git ls-files -u -- \"$f\" | awk '{if ($3==2) print $1;}')\n   remote_mode=$(git ls-files -u -- \"$f\" | awk '{if ($3==3) print $1;}')\n   # create the status flags\n   describe_state \"$local_mode\"\n   describe_state \"$remote_mode\"\n   # append the file name\n   echo \" $f\"\ndone\n"},{"id":"119473","messageId":"m34osoqc5p.fsf@localhost.localdomain","threadId":"20355","inReplyTo":"4F52523A-2CEA-4CD3-A094-A2627E2A4403@users.sourceforge.net","subject":"Re: conflict status","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-08-04T07:19:21Z","receivedAt":"2009-08-04T07:19:21Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Michael Wild <themiwi@users.sourceforge.net> writes:\n> On 3. Aug, 2009, at 20:35, Junio C Hamano wrote:\n>> Thomas Rast <trast@student.ethz.ch> writes:\n>>\n>>> That only shows 'unmerged: foo' for me...\n>>>\n>>> The closest to porcelain I can get while still having all the\n>>> information is\n>>>\n>>>  $ git ls-files -s foo\n>>>  100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 1       foo\n>>>  100644 d00491fd7e5bb6fa28c517a0bb32b8b506539d4d 2       foo\n>>>\n>>> In other words, not porcelain at all.\n>>\n>> \"git ls-files -u\" would be what you want.  It shows all the paths with\n>> conflicts in the index, and omits paths without conflicts in the\n>> index.\n>>\n>> And the object names allow you to inspect the individual stages.\n>>\n> \n> \n> I found out about that one too (by having a look at git-mergetool),\n> and came up with the following quick hack (doesn't take any arguments/\n> options, is very rough and slow for a large number of conflicts). For\n> each unmerged file it displays the file name, prefixed with the local\n> and remote state. Possible states are \"c\" for created, \"m\" for\n> modified and \"d\" for deleted. Probably there are other cases I'm not\n> aware of and require special handling.\n\nIf you don't need SHA-1s, why not use -t or -v option of git-ls-files,\ne.g.:\n\n  $ git ls-files -v -u\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"119476","messageId":"398EA050-EEC9-4C16-8225-410BBECABB13@users.sourceforge.net","threadId":"20355","inReplyTo":"m34osoqc5p.fsf@localhost.localdomain","subject":"Re: conflict status","fromName":"Michael Wild","fromEmail":"themiwi@users.sourceforge.net","sentAt":"2009-08-04T07:31:13Z","receivedAt":"2009-08-04T07:31:13Z","isPatch":false,"sender":{"key":"themiwi@users.sourceforge.net","avatar":"https://gravatar.com/avatar/9dbb9d449a09f3b523df6a16f8d0b46ba772d7a2793ddf1371555e82776edb70?d=mp&s=160"},"body":"\nOn 4. Aug, 2009, at 9:19, Jakub Narebski wrote:\n>\n> If you don't need SHA-1s, why not use -t or -v option of git-ls-files,\n> e.g.:\n>\n>  $ git ls-files -v -u\n>\n\n\nHuh? Sorry, I don't get your point. -v and -t will just prefix a  \n\"M\" (or sometimes \"m\" in the case of-v) for unmerged files. But I  \nalready know they are unmerged, so why bother?\n"},{"id":"119478","messageId":"7vhbwoypu4.fsf@alter.siamese.dyndns.org","threadId":"20355","inReplyTo":"4F52523A-2CEA-4CD3-A094-A2627E2A4403@users.sourceforge.net","subject":"Re: conflict status","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-04T07:56:35Z","receivedAt":"2009-08-04T07:56:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Wild <themiwi@users.sourceforge.net> writes:\n\n> # get all conflicts\n> conflicts=\"$(git-status | awk '/unmerged:/{print $3;next}')\"\n>\n> for f in $conflicts; do\n>   # extract the file mode for base, local and remote\n>   base_mode=$(git ls-files -u -- \"$f\" | awk '{if ($3==1) print $1;}')\n>   local_mode=$(git ls-files -u -- \"$f\" | awk '{if ($3==2) print $1;}')\n>   remote_mode=$(git ls-files -u -- \"$f\" | awk '{if ($3==3) print $1;}')\n>   # create the status flags\n>   describe_state \"$local_mode\"\n>   describe_state \"$remote_mode\"\n>   # append the file name\n>   echo \" $f\"\n> done\n\nLooks an awfully inefficient way to say \"git ls-files -u\" to me.  If you\ndo not see stage 2, you do not have it.  If you do not see stage 3, they\ndo not have it.\n\nIf you really really want to condense the object name information out, you\ncould do something like this.\n\n-- >8 --\n#!/bin/sh\ngit ls-files -u -z |\nperl -e '\n\t$/ = \"\\0\";\n        my ($last_path, @stage);\n        sub describe_mode {\n        \tmy $ours = $_[0];\n\t\tmy $sign;\n                if (!defined $ours) {\n                \t$sign = \"d\";\n\t\t} elsif (defined $stage[1]) {\n                \t$sign = \"m\";\n\t\t} else {\n\t\t\t$sign = \"c\";\n                }\n\t\treturn $sign;\n        }\n\tsub flush_path {\n        \tprintf(\"%s %s %s\\n\",\n                \tdescribe_mode($stage[2]),\n                \tdescribe_mode($stage[3]),\n\t\t\t$last_path);\n\t\t$last_path = undef;\n        \t@stage = ();\n        }\n        while (<>) {\n\t\tchomp;\n        \tmy ($mode, $sha1, $stage, $path) =\n                \t/^([0-7]+) ([0-9a-f]{40}) ([1-3])\\t(.*)$/;\n\t\tif (defined $last_path) {\n\t\t\tflush_path() if ($path ne $last_path);\n                }\n                $stage[$stage] = 1;\n                $last_path = $path;\n\t}\n        if (defined $last_path) {\n                flush_path() if ($path ne $last_path);\n        }\n'\n-- 8< --\n\nI however do not think it is all that interesting, though.\n"}]}