{"thread":{"id":"45983","subject":"Diff topic branch + working copy changes?","startedAt":"2017-05-16T19:31:40Z","lastAt":"2017-05-17T21:18:06Z","messageCount":5,"participants":["Robert Dailey","Junio C Hamano","Samuel Lijin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"319955","messageId":"CAHd499ADTbO09OJhH_wWBbAcXZeLRLFAqOw5eTe6=abN-JUrUA@mail.gmail.com","threadId":"45983","inReplyTo":null,"subject":"Diff topic branch + working copy changes?","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2017-05-16T19:31:33Z","receivedAt":"2017-05-16T19:31:40Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"So for a topic branch based on master, I can diff ONLY my changes on\nthe topic branch by doing this simple command:\n\n$ git diff origin/master...\n\nHowever, this does not include uncommitted working copy changes. To\nwork around this, I can do this instead:\n\n$ git diff origin/master\n\n(No three-dot notation above)\n\nHowever this implies a \"..\" notation which will include changes on\nmaster that have been made after I branched my topic (I use three-dot\nto exclude those).\n\nIs there a way I can do the first diff but also include working copy\nchanges? The reason I'm wanting to do this is because with difftool in\nparticular I like to make changes on the \"right\" side of each diff and\nhave those changes carry over to my working copy as edits I can\ncommit. This doesn't always work, especially if those same files are\nalready modified in my working copy but not committed.\n"},{"id":"319991","messageId":"xmqq37c4yzb3.fsf@gitster.mtv.corp.google.com","threadId":"45983","inReplyTo":"CAHd499ADTbO09OJhH_wWBbAcXZeLRLFAqOw5eTe6=abN-JUrUA@mail.gmail.com","subject":"Re: Diff topic branch + working copy changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-17T02:47:28Z","receivedAt":"2017-05-17T02:47:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Robert Dailey <rcdailey.lists@gmail.com> writes:\n\n> So for a topic branch based on master, I can diff ONLY my changes on\n> the topic branch by doing this simple command:\n>\n> $ git diff origin/master...\n>\n> However, this does not include uncommitted working copy changes. To\n> work around this, I can do this instead:\n>\n> $ git diff origin/master\n>\n> (No three-dot notation above)\n>\n> However this implies a \"..\" notation which will include changes on\n> master that have been made after I branched my topic (I use three-dot\n> to exclude those).\n>\n> Is there a way I can do the first diff but also include working copy\n> changes?\n\nI've wished this a few times, but the answer is no.  Not as a\nshort-hand like \"...\" anyway.\n\nYou can still do \n\n    $ git diff $(git merge-base origin/master HEAD)\n\nof course.\n"},{"id":"320072","messageId":"CAHd499DNa1zFm+ktWJb-4Rp09DjSc+p4HMqoHiXDj57muwxukw@mail.gmail.com","threadId":"45983","inReplyTo":"xmqq37c4yzb3.fsf@gitster.mtv.corp.google.com","subject":"Re: Diff topic branch + working copy changes?","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2017-05-17T13:39:26Z","receivedAt":"2017-05-17T13:39:32Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Tue, May 16, 2017 at 9:47 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Robert Dailey <rcdailey.lists@gmail.com> writes:\n>\n>> So for a topic branch based on master, I can diff ONLY my changes on\n>> the topic branch by doing this simple command:\n>>\n>> $ git diff origin/master...\n>>\n>> However, this does not include uncommitted working copy changes. To\n>> work around this, I can do this instead:\n>>\n>> $ git diff origin/master\n>>\n>> (No three-dot notation above)\n>>\n>> However this implies a \"..\" notation which will include changes on\n>> master that have been made after I branched my topic (I use three-dot\n>> to exclude those).\n>>\n>> Is there a way I can do the first diff but also include working copy\n>> changes?\n>\n> I've wished this a few times, but the answer is no.  Not as a\n> short-hand like \"...\" anyway.\n>\n> You can still do\n>\n>     $ git diff $(git merge-base origin/master HEAD)\n>\n> of course.\n\nThanks Junio, I forgot about merge-base. I'll create some aliases for now:\n\n    # Diff Branch\n    db = \"!f() { : git diff ; git diff $(git merge-base @{upstream}\nHEAD) ; }; f\"\n\n    # Diff Tool Branch\n    dtb = \"!f() { : git diff ; git difftool -d $(git merge-base\n@{upstream} HEAD) ; }; f\"\n\nSince I use push.default = current, I always keep my upstream set to\nthe parent branch (origin/master, origin/release/1.2.3, etc). So in my\ncase these aliases work, but probably not for other push.default\nsettings like 'upstream'.\n\nWould be nice in the future to have another revision specification\nlike @{wc} for \"HEAD + working copy\". I guess this technically isn't a\nrevision, but something along those lines. Or maybe just an\n--include-wc for diff or something.\n\nThanks again!!\n"},{"id":"320073","messageId":"CAHd499D5WiXfTXCx+Mzg5Mt+L0_pOKVgSuasFOew4QiZ5DGv-A@mail.gmail.com","threadId":"45983","inReplyTo":"CAHd499DNa1zFm+ktWJb-4Rp09DjSc+p4HMqoHiXDj57muwxukw@mail.gmail.com","subject":"Re: Diff topic branch + working copy changes?","fromName":"Robert Dailey","fromEmail":"rcdailey.lists@gmail.com","sentAt":"2017-05-17T13:40:27Z","receivedAt":"2017-05-17T13:40:32Z","isPatch":false,"sender":{"key":"rcdailey.lists@gmail.com","avatar":null},"body":"On Wed, May 17, 2017 at 8:39 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n> Thanks Junio, I forgot about merge-base. I'll create some aliases for now:\n>\n>     # Diff Branch\n>     db = \"!f() { : git diff ; git diff $(git merge-base @{upstream}\n> HEAD) ; }; f\"\n>\n>     # Diff Tool Branch\n>     dtb = \"!f() { : git diff ; git difftool -d $(git merge-base\n> @{upstream} HEAD) ; }; f\"\n>\n> Since I use push.default = current, I always keep my upstream set to\n> the parent branch (origin/master, origin/release/1.2.3, etc). So in my\n> case these aliases work, but probably not for other push.default\n> settings like 'upstream'.\n\nCorrection: settings like 'simple'\n\n> Would be nice in the future to have another revision specification\n> like @{wc} for \"HEAD + working copy\". I guess this technically isn't a\n> revision, but something along those lines. Or maybe just an\n> --include-wc for diff or something.\n>\n> Thanks again!!\n"},{"id":"320106","messageId":"CAJZjrdX6iDQeAV4v7S=_OV6McNFe8Tax3sNUatwhrg+nEOR0jA@mail.gmail.com","threadId":"45983","inReplyTo":"CAHd499DNa1zFm+ktWJb-4Rp09DjSc+p4HMqoHiXDj57muwxukw@mail.gmail.com","subject":"Re: Diff topic branch + working copy changes?","fromName":"Samuel Lijin","fromEmail":"sxlijin@gmail.com","sentAt":"2017-05-17T21:17:21Z","receivedAt":"2017-05-17T21:18:06Z","isPatch":false,"sender":{"key":"sxlijin@gmail.com","avatar":"https://gravatar.com/avatar/01777bf1eae64e2b4dca97dcac182a6abbcf6fd8cb4d5b8fa33edf9f8cc21746?d=mp&s=160"},"body":"On Wed, May 17, 2017 at 9:39 AM, Robert Dailey <rcdailey.lists@gmail.com> wrote:\n>\n> Would be nice in the future to have another revision specification\n> like @{wc} for \"HEAD + working copy\". I guess this technically isn't a\n> revision, but something along those lines. Or maybe just an\n> --include-wc for diff or something.\n\nI think the spec would *just* be the working tree, if it ever got\nimplemented - I don't think it makes much sense to say \"HEAD + working\ncopy\".\n\nMaybe something like this would do what you want?\n\n# Diff Merge Base\n\ndmb = \"!f() { : git diff ; ref=$(git rev-parse --abbrev-ref HEAD); git\nreset --soft $(git merge-base @{upstream} HEAD); git diff; git reset\n--soft \\\"$ref\\\"; }; f\"\n"}]}