{"thread":{"id":"60030","subject":"'git stash push -- {dir}' puts files in stash that are outside of {dir}","startedAt":"2023-07-26T17:07:18Z","lastAt":"2023-07-26T18:14:28Z","messageCount":4,"participants":["Yuri","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"479904","messageId":"5fce9c4f-0ea7-9393-4a30-ddd66946661d@tsoft.com","threadId":"60030","inReplyTo":null,"subject":"'git stash push -- {dir}' puts files in stash that are outside of {dir}","fromName":"Yuri","fromEmail":"yuri@tsoft.com","sentAt":"2023-07-26T17:05:04Z","receivedAt":"2023-07-26T17:07:18Z","isPatch":false,"sender":{"key":"yuri@tsoft.com","avatar":null},"body":"I am in the FreeBSD ports repository.\n\nI run this command:\n\n$ git stash push -m \"gh-print-tuple\" -- Mk\n\nBut then 'git show' shows that the top stash entry also has other files:\n\n$ git stash show -p stash@{0} | grep diff\ndiff --git a/Mk/Scripts/print-submodule-gh_tuple.awk \nb/Mk/Scripts/print-submodule-gh_tuple.awk\ndiff --git a/Mk/Scripts/print-submodule-gh_tuple.sh \nb/Mk/Scripts/print-submodule-gh_tuple.sh\ndiff --git a/Mk/bsd.sites.mk b/Mk/bsd.sites.mk\ndiff --git a/audio/triceratops-lv2/files/patch-synth.cpp \nb/audio/triceratops-lv2/files/patch-synth.cpp\ndiff --git a/cad/scotch/distinfo b/cad/scotch/distinfo\ndiff --git \na/cad/scotch/files/patch-Make.inc_Makefile.inc.i686__pc__freebsd \nb/cad/scotch/files/patch-Make.inc_Makefile.inc.i686__pc__freebsd\ndiff --git \na/cad/scotch/files/patch-Make.inc_Makefile.inc.x86-64__pc__freebsd \nb/cad/scotch/files/patch-Make.inc_Makefile.inc.x86-64__pc__freebsd\ndiff --git a/x11/darktile/Makefile b/x11/darktile/Makefile\ndiff --git a/x11/darktile/distinfo b/x11/darktile/distinfo\ndiff --git \na/x11/darktile/files/patch-vendor_github.com_kr_pty_ztypes__freebsd__arm64.go \nb/x11/darktile/files/patch-vendor_github.com_kr_pty_ztypes__freebsd__arm64.go\ndiff --git \na/x11/darktile/files/patch-vendor_github.com_riywo_loginshell_loginshell.go \nb/x11/darktile/files/patch-vendor_github.com_riywo_loginshell_loginshell.go\ndiff --git a/x11/darktile/pkg-descr b/x11/darktile/pkg-descr\n\n\nWhy do files that are not under Mk get into stash?\n\n\n\nThanks,\n\nYuri\n\n\n"},{"id":"479907","messageId":"xmqqsf9ad1ju.fsf@gitster.g","threadId":"60030","inReplyTo":"5fce9c4f-0ea7-9393-4a30-ddd66946661d@tsoft.com","subject":"Re: 'git stash push -- {dir}' puts files in stash that are outside of {dir}","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-07-26T17:29:09Z","receivedAt":"2023-07-26T17:29:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yuri <yuri@tsoft.com> writes:\n\n> I am in the FreeBSD ports repository.\n>\n> I run this command:\n>\n> $ git stash push -m \"gh-print-tuple\" -- Mk\n>\n> But then 'git show' shows that the top stash entry also has other files:\n>\n> $ git stash show -p stash@{0} | grep diff\n\nNot offering a solution, as a quick test or two in my environment do\nnot reproduce this problem [*].  But instead of the above command,\nwhich will show matches on any line that has \"diff\" in the \"-p\"\noutput, perhaps\n\n    $ git stash show --stat\n\nis easier to see?\n\nAre there configuration variables set to affect the behaviour of the\n\"git stash\" command in your environment that I do not have (I have\nnothing in \"git config -l | grep stash\" output), which may be\naffecting why it does not reproduce for me?\n\n> Why do files that are not under Mk get into stash?\n\n\n[Footnote]\n\n* Admittedly I didn't recall we had pathspec support to \"git stash\n  push\" so consider me no longer an expert in this area ;-).\n"},{"id":"479908","messageId":"792f71bb-2b9a-2e2b-80ea-9e3afd9fbfb4@tsoft.com","threadId":"60030","inReplyTo":"xmqqsf9ad1ju.fsf@gitster.g","subject":"Re: 'git stash push -- {dir}' puts files in stash that are outside of {dir}","fromName":"Yuri","fromEmail":"yuri@tsoft.com","sentAt":"2023-07-26T17:36:16Z","receivedAt":"2023-07-26T17:36:40Z","isPatch":false,"sender":{"key":"yuri@tsoft.com","avatar":null},"body":"On 7/26/23 10:29, Junio C Hamano wrote:\n> Are there configuration variables set to affect the behaviour of the\n> \"git stash\" command in your environment that I do not have (I have\n> nothing in \"git config -l | grep stash\" output), which may be\n> affecting why it does not reproduce for me?\n\n\n\"git config -l | grep stash\" doesn't print anything.\n\nInterestingly, the command 'git stash push -- Mk' puts intended and unintended files in stash, but the changes in unintended files (ones not under Mk) stay, while changes in the intended files are gone, as expected.\n\nClearing all changes and doing 'git stash pop && git stash push -- Mk' reproduces the problem.\n\n\nYuri\n\n"},{"id":"479912","messageId":"xmqqo7jyczgj.fsf@gitster.g","threadId":"60030","inReplyTo":"792f71bb-2b9a-2e2b-80ea-9e3afd9fbfb4@tsoft.com","subject":"Re: 'git stash push -- {dir}' puts files in stash that are outside of {dir}","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-07-26T18:14:20Z","receivedAt":"2023-07-26T18:14:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Yuri <yuri@tsoft.com> writes:\n\n> On 7/26/23 10:29, Junio C Hamano wrote:\n>> Are there configuration variables set to affect the behaviour of the\n>> \"git stash\" command in your environment that I do not have (I have\n>> nothing in \"git config -l | grep stash\" output), which may be\n>> affecting why it does not reproduce for me?\n>\n>\n> \"git config -l | grep stash\" doesn't print anything.\n\nAnother thing to try.  The command internally uses some internal\nform of \"git diff\" to find out what to save and reset to the HEAD\nversion in the working tree, so if you have an exotic configuration\nvariable that affects the way \"diff\" behaves, it _could_ trigger a\nsymptom like that (needless to say, the internal invocation of \"git\ndiff\" should have prepared for such an end-user configuration and\nexplicitly countermanded it, but people add configuration variables\nafter a command was implemented without thinking the ramification\nthrough and especially when they are rarely used ones that do not\nusually appear on Git developers' radar, such a bad interaction can\ngo unnoticed for a long time).\n"}]}