{"thread":{"id":"58670","subject":"'git commit .' in a subdirectory also commits staged files in other subdirectories","startedAt":"2022-10-21T19:55:44Z","lastAt":"2022-11-07T18:45:34Z","messageCount":4,"participants":["Yuri","Taylor Blau","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"465506","messageId":"3a4dfad5-0f2e-14d8-61f2-779616de1ae0@tsoft.com","threadId":"58670","inReplyTo":null,"subject":"'git commit .' in a subdirectory also commits staged files in other subdirectories","fromName":"Yuri","fromEmail":"yuri@rawbw.com","sentAt":"2022-10-21T19:40:51Z","receivedAt":"2022-10-21T19:55:44Z","isPatch":false,"sender":{"key":"yuri@rawbw.com","avatar":null},"body":"I had several staged files in various subdirectories of the cloned \nrepository tree.\n\n'git commit .' in one of them attempted to commit all of them, not only \nthe files in that subdirectory.\n\nThis is a very unreasonable behavior, because while being in any \nsubdirectory 'git commit .' should only affect that subdirectory, and \nnot files elsewhere.\n\n\ngit-2.38.0\n\nFreeBSD 13.1\n\n\nYuri\n\n"},{"id":"465514","messageId":"Y1MTtNcUHyv76UEV@nand.local","threadId":"58670","inReplyTo":"3a4dfad5-0f2e-14d8-61f2-779616de1ae0@tsoft.com","subject":"Re: 'git commit .' in a subdirectory also commits staged files in other subdirectories","fromName":"Taylor Blau","fromEmail":"me@ttaylorr.com","sentAt":"2022-10-21T21:48:36Z","receivedAt":"2022-10-21T21:48:42Z","isPatch":false,"sender":{"key":"me@ttaylorr.com","avatar":"https://avatars.githubusercontent.com/u/301000140?v=4"},"body":"Hi Yuri,\n\nOn Fri, Oct 21, 2022 at 12:40:51PM -0700, Yuri wrote:\n> I had several staged files in various subdirectories of the cloned\n> repository tree.\n>\n> 'git commit .' in one of them attempted to commit all of them, not\n> only the files in that subdirectory.\n>\n> This is a very unreasonable behavior, because while being in any\n> subdirectory 'git commit .' should only affect that subdirectory, and\n> not files elsewhere.\n\nThat isn't right, though I can't reproduce what you describe from your\nreport. Try this script out:\n\n--- >8 ---\n#!/bin/sh\n\nrm -fr repo\ngit init repo\ncd repo\n\nmkdir -p dir\ntouch dir/c\ntouch a\ntouch b\ngit add a b dir/c\ngit commit -m \"a\"\n\ndate >>b\ndate >>dir/c\n\n(\n  cd dir\n\n  git commit . -m \"dir\"\n)\n--- 8< ---\n\n`repo` ends up wtih the contents of dir/c committed, but b is still\nmodified (and its latest changes not part of the most recent commit).\n\nCan you share a reproduction script?\n\nThanks,\nTaylor\n"},{"id":"465520","messageId":"xmqqy1t8j0nw.fsf@gitster.g","threadId":"58670","inReplyTo":"Y1MTtNcUHyv76UEV@nand.local","subject":"Re: 'git commit .' in a subdirectory also commits staged files in other subdirectories","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-10-21T22:02:11Z","receivedAt":"2022-10-21T22:02:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Taylor Blau <me@ttaylorr.com> writes:\n\n>> 'git commit .' in one of them attempted to commit all of them, not\n>> only the files in that subdirectory.\n>>\n>> This is a very unreasonable behavior, because while being in any\n>> subdirectory 'git commit .' should only affect that subdirectory, and\n>> not files elsewhere.\n>\n> That isn't right, though I can't reproduce what you describe from your\n> report. Try this script out:\n> ...\n\n\"git commit --include .\" would exhibit the behaviour, but that\nshould not be the default, so I am also puzzled.\n"},{"id":"466714","messageId":"7766c9c8-1323-70fb-c6d2-efca6b77595f@tsoft.com","threadId":"58670","inReplyTo":"Y1MTtNcUHyv76UEV@nand.local","subject":"Re: 'git commit .' in a subdirectory also commits staged files in other subdirectories","fromName":"Yuri","fromEmail":"yuri@rawbw.com","sentAt":"2022-11-07T18:45:20Z","receivedAt":"2022-11-07T18:45:34Z","isPatch":false,"sender":{"key":"yuri@rawbw.com","avatar":null},"body":"On 10/21/22 14:48, Taylor Blau wrote:\n> That isn't right, though I can't reproduce what you describe from your\n> report. Try this script out:\n\n\nI don't know how to reproduce this on purpose. But I just got another \ninstance of the problem.\n\nI am in the FreeBSD ports Git repository, in the math/cimod subfolder. \nAnother subfolder, audio/sonic-visualiser, also has changes.\n\nHere is the command:\n\n[yuri@yv /disk-samsung/freebsd-ports/math/cimod]$ git commit .\nhint: Waiting for your editor to close the file...\n# Uncomment and add a short description of why things changed.\nmath/cimod: Update 1.4.43 -> 1.4.45\n\n# Please enter the commit message for your changes. Lines starting\n# with '#' will be ignored, and an empty message aborts the commit.\n#\n# category/port: Subject goes here, max 50 cols -|\n# <then a blank line>\n#                                                         72 columns --|\n#\n# Do not add a Submitted by line.  If someone besides the committer sent \nin the\n# change, the commit author should be set using `git commit --author`.\n#\n# Uncomment and complete these metadata fields, as appropriate:\n#\n# PR:           <If and which Problem Report is related.>\nReported by:    portscout\n# Reviewed by:  <If someone else reviewed your modification.>\n# Tested by:    <If someone else tested the change.>\n# Approved by:  <If you needed approval for this commit.>\n# Obtained from:        <If the change is from a third party.>\n# Fixes:        <Short hash and title line of commit fixed by this change>\n# MFH:          <Ports tree branch name you plan to merge to.>\n# Relnotes:     <Set to 'yes' for mention in release notes.>\n# Security:     <Vulnerability reference (one per line) or description.>\n# Sponsored by: <If the change was sponsored by an organization.>\n# Pull Request: <https://github.com/freebsd/freebsd-ports/pull/###>\n# Differential Revision: <https://reviews.freebsd.org/D###>\n#\n# \"Pull Request\" and \"Differential Revision\" require the *full* GitHub or\n# Phabricator URL.\n#\n# On branch main\n# Your branch is up to date with 'origin/main'.\n#\n# Changes to be committed:\n#       modified:   Makefile\n#       modified:   distinfo\n#\n# Changes not staged for commit:\n#       modified:   ../../audio/sonic-visualiser/Makefile\n#       modified:   ../../audio/sonic-visualiser/distinfo\n#       deleted: ../../audio/sonic-visualiser/files/patch-acinclude.m4\n#       deleted: ../../audio/sonic-visualiser/files/patch-base.pro\n#       deleted: ../../audio/sonic-visualiser/files/patch-config.pri.in\n#       deleted: ../../audio/sonic-visualiser/files/patch-configure.ac\n#       deleted: ../../audio/sonic-visualiser/files/patch-convert.pro\n#       deleted: ../../audio/sonic-visualiser/files/patch-server.pro\n#       deleted: \n../../audio/sonic-visualiser/files/patch-sonic-visualiser.pro\n\n\nGit said that 2 files are to be committed, Makefile and distnfo. This is \ncorrect.\n\n\nHowever, the resulting commit also has audio/sonic-visualiser:\n\n  git diff 99f39b9798ff81b8fb529bea7c16d96e27aecfca~1 \n99f39b9798ff81b8fb529bea7c16d96e27aecfca | grep diff\ndiff --git a/audio/sonic-visualiser/files/patch-acinclude.m4 \nb/audio/sonic-visualiser/files/patch-acinclude.m4\ndiff --git a/audio/sonic-visualiser/files/patch-base.pro \nb/audio/sonic-visualiser/files/patch-base.pro\ndiff --git a/audio/sonic-visualiser/files/patch-config.pri.in \nb/audio/sonic-visualiser/files/patch-config.pri.in\ndiff --git a/audio/sonic-visualiser/files/patch-configure.ac \nb/audio/sonic-visualiser/files/patch-configure.ac\ndiff --git a/audio/sonic-visualiser/files/patch-convert.pro \nb/audio/sonic-visualiser/files/patch-convert.pro\ndiff --git a/audio/sonic-visualiser/files/patch-server.pro \nb/audio/sonic-visualiser/files/patch-server.pro\ndiff --git a/audio/sonic-visualiser/files/patch-sonic-visualiser.pro \nb/audio/sonic-visualiser/files/patch-sonic-visualiser.pro\n- # (because of the difficulty of getting them running nicely in the\ndiff --git a/audio/sonic-visualiser/files/patch-sv.pro \nb/audio/sonic-visualiser/files/patch-sv.pro\ndiff --git a/audio/sonic-visualiser/files/patch-svapp_acinclude.m4 \nb/audio/sonic-visualiser/files/patch-svapp_acinclude.m4\ndiff --git a/audio/sonic-visualiser/files/patch-svcore_acinclude.m4 \nb/audio/sonic-visualiser/files/patch-svcore_acinclude.m4\ndiff --git a/audio/sonic-visualiser/files/patch-svcore_config.pri.in \nb/audio/sonic-visualiser/files/patch-svcore_config.pri.in\ndiff --git a/audio/sonic-visualiser/files/patch-svgui_acinclude.m4 \nb/audio/sonic-visualiser/files/patch-svgui_acinclude.m4\ndiff --git \na/audio/sonic-visualiser/files/patch-svgui_layer_WaveformLayer.cpp \nb/audio/sonic-visualiser/files/patch-svgui_layer_WaveformLayer.cpp\ndiff --git a/audio/sonic-visualiser/files/patch-svgui_view_Overview.cpp \nb/audio/sonic-visualiser/files/patch-svgui_view_Overview.cpp\ndiff --git a/math/cimod/Makefile b/math/cimod/Makefile\ndiff --git a/math/cimod/distinfo b/math/cimod/distinfo\n\n\nThis is WRONG!\n\n\nThere *is* a bug in Git.\n\n\nEach commit needs to be individually checked to see if the right files \nwere committed. The Git's commit description can't be trusted.\n\nWhen it says \"Changes not staged for commit\" - these files should *not* \nbe committed,\n\nThis has already hurt me several times.\n\n\nThis should be the highest priority bug.\n\n\nYuri\n\n\n"}]}