{"thread":{"id":"36769","subject":"[BUG] git diff --(src|dst)-prefix=// causes spurious \"(new|deleted) file mode\"","startedAt":"2014-05-28T01:55:29Z","lastAt":"2014-05-28T17:29:22Z","messageCount":2,"participants":["Noam Postavsky","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"242832","messageId":"CAM-tV-9vQPPj+TemYnzjRMTjaHqwo3qq=WWJ89VnRMAeYXHZZw@mail.gmail.com","threadId":"36769","inReplyTo":null,"subject":"[BUG] git diff --(src|dst)-prefix=// causes spurious \"(new|deleted) file mode\"","fromName":"Noam Postavsky","fromEmail":"npostavs@users.sourceforge.net","sentAt":"2014-05-28T01:55:29Z","receivedAt":"2014-05-28T01:55:29Z","isPatch":false,"sender":{"key":"npostavs@users.sourceforge.net","avatar":"https://avatars.githubusercontent.com/u/287742?v=4"},"body":"% git init\nInitialized empty Git repository in /home/npostavs/tmp/scratch/.git/\n% echo foo > x\n% git add x\n% git commit -m x\n[master (root-commit) 41be1f2] x\n 1 file changed, 1 insertion(+)\n create mode 100644 x\n% echo bar > x\n% git diff  | head -3\ndiff --git i/x w/x\nindex 257cc56..5716ca5 100644\n--- i/x\n% git diff --dst-prefix=// | head -3\ndiff --git i/x //x\ndeleted file mode 100644\nindex 257cc56..5716ca5 100644\n% git diff --src-prefix=// | head -3\ndiff --git //x w/x\nnew file mode 100644\nindex 257cc56..5716ca5 100644\n% git diff --src-prefix=// --dst-prefix=// | head -3\ndiff --git //x //x\nnew file mode 100644\nindex 257cc56..5716ca5 100644\n% git --version\ngit version 1.9.2\n\nBackground: trying to find a prefix that can't show up in file names\nin order to make parsing easier.\nhttps://github.com/magit/magit/pull/1379\nhttps://github.com/magit/magit/pull/1383\n"},{"id":"242875","messageId":"xmqq38fterrh.fsf@gitster.dls.corp.google.com","threadId":"36769","inReplyTo":"CAM-tV-9vQPPj+TemYnzjRMTjaHqwo3qq=WWJ89VnRMAeYXHZZw@mail.gmail.com","subject":"Re: [BUG] git diff --(src|dst)-prefix=// causes spurious \"(new|deleted) file mode\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-05-28T17:29:22Z","receivedAt":"2014-05-28T17:29:22Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Noam Postavsky <npostavs@users.sourceforge.net> writes:\n\n> % git init\n> Initialized empty Git repository in /home/npostavs/tmp/scratch/.git/\n> % echo foo > x\n> % git add x\n> % git commit -m x\n> [master (root-commit) 41be1f2] x\n>  1 file changed, 1 insertion(+)\n>  create mode 100644 x\n> % echo bar > x\n> % git diff  | head -3\n> diff --git i/x w/x\n> index 257cc56..5716ca5 100644\n> --- i/x\n> % git diff --dst-prefix=// | head -3\n> diff --git i/x //x\n\nThe feature these options implement was never designed to accept\nanything other than \"foo/bar/\" (i.e. a relative path-looking thing\nthat ends with \"/\" and no funnies such as duplicated slashes, in\norder to replace the standard \"a/\" and \"b/\").  I think the command\nline parsing code of src/dst-prefix trusts the user too much not to\nfeed nonsense like the above.  They may want to be tightened.\n\n> Background: trying to find a prefix that can't show up in file names\n> in order to make parsing easier.\n> https://github.com/magit/magit/pull/1379\n> https://github.com/magit/magit/pull/1383\n\nIt may be worth studying how \"git apply\" finds what the paths are\nand use the same rule for consistency.  IIRC, the rules are roughly:\n\n - In a renaming/copying patch, you will have \"rename/copy from/to\"\n   header separately.  There is no need to parse the \"diff --git\"\n   line at all;\n\n - Otherwise, you will have \"a/SOMETHING b/SOMETHING\" (SOMETHING are\n   repeated because there is no rename involved).\n"}]}