git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* 'git commit .' in a subdirectory also commits staged files in other subdirectories
@ 2022-10-21 19:40 Yuri
  2022-10-21 21:48 ` Taylor Blau
  0 siblings, 1 reply; 4+ messages in thread
From: Yuri @ 2022-10-21 19:40 UTC (permalink / raw)
  To: Git Mailing List

I had several staged files in various subdirectories of the cloned 
repository tree.

'git commit .' in one of them attempted to commit all of them, not only 
the files in that subdirectory.

This is a very unreasonable behavior, because while being in any 
subdirectory 'git commit .' should only affect that subdirectory, and 
not files elsewhere.


git-2.38.0

FreeBSD 13.1


Yuri


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 'git commit .' in a subdirectory also commits staged files in other subdirectories
  2022-10-21 19:40 'git commit .' in a subdirectory also commits staged files in other subdirectories Yuri
@ 2022-10-21 21:48 ` Taylor Blau
  2022-10-21 22:02   ` Junio C Hamano
  2022-11-07 18:45   ` Yuri
  0 siblings, 2 replies; 4+ messages in thread
From: Taylor Blau @ 2022-10-21 21:48 UTC (permalink / raw)
  To: Yuri; +Cc: Git Mailing List

Hi Yuri,

On Fri, Oct 21, 2022 at 12:40:51PM -0700, Yuri wrote:
> I had several staged files in various subdirectories of the cloned
> repository tree.
>
> 'git commit .' in one of them attempted to commit all of them, not
> only the files in that subdirectory.
>
> This is a very unreasonable behavior, because while being in any
> subdirectory 'git commit .' should only affect that subdirectory, and
> not files elsewhere.

That isn't right, though I can't reproduce what you describe from your
report. Try this script out:

--- >8 ---
#!/bin/sh

rm -fr repo
git init repo
cd repo

mkdir -p dir
touch dir/c
touch a
touch b
git add a b dir/c
git commit -m "a"

date >>b
date >>dir/c

(
  cd dir

  git commit . -m "dir"
)
--- 8< ---

`repo` ends up wtih the contents of dir/c committed, but b is still
modified (and its latest changes not part of the most recent commit).

Can you share a reproduction script?

Thanks,
Taylor

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 'git commit .' in a subdirectory also commits staged files in other subdirectories
  2022-10-21 21:48 ` Taylor Blau
@ 2022-10-21 22:02   ` Junio C Hamano
  2022-11-07 18:45   ` Yuri
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2022-10-21 22:02 UTC (permalink / raw)
  To: Taylor Blau; +Cc: Yuri, Git Mailing List

Taylor Blau <me@ttaylorr.com> writes:

>> 'git commit .' in one of them attempted to commit all of them, not
>> only the files in that subdirectory.
>>
>> This is a very unreasonable behavior, because while being in any
>> subdirectory 'git commit .' should only affect that subdirectory, and
>> not files elsewhere.
>
> That isn't right, though I can't reproduce what you describe from your
> report. Try this script out:
> ...

"git commit --include ." would exhibit the behaviour, but that
should not be the default, so I am also puzzled.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 'git commit .' in a subdirectory also commits staged files in other subdirectories
  2022-10-21 21:48 ` Taylor Blau
  2022-10-21 22:02   ` Junio C Hamano
@ 2022-11-07 18:45   ` Yuri
  1 sibling, 0 replies; 4+ messages in thread
From: Yuri @ 2022-11-07 18:45 UTC (permalink / raw)
  To: Taylor Blau; +Cc: Git Mailing List

On 10/21/22 14:48, Taylor Blau wrote:
> That isn't right, though I can't reproduce what you describe from your
> report. Try this script out:


I don't know how to reproduce this on purpose. But I just got another 
instance of the problem.

I am in the FreeBSD ports Git repository, in the math/cimod subfolder. 
Another subfolder, audio/sonic-visualiser, also has changes.

Here is the command:

[yuri@yv /disk-samsung/freebsd-ports/math/cimod]$ git commit .
hint: Waiting for your editor to close the file...
# Uncomment and add a short description of why things changed.
math/cimod: Update 1.4.43 -> 1.4.45

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# category/port: Subject goes here, max 50 cols -|
# <then a blank line>
#                                                         72 columns --|
#
# Do not add a Submitted by line.  If someone besides the committer sent 
in the
# change, the commit author should be set using `git commit --author`.
#
# Uncomment and complete these metadata fields, as appropriate:
#
# PR:           <If and which Problem Report is related.>
Reported by:    portscout
# Reviewed by:  <If someone else reviewed your modification.>
# Tested by:    <If someone else tested the change.>
# Approved by:  <If you needed approval for this commit.>
# Obtained from:        <If the change is from a third party.>
# Fixes:        <Short hash and title line of commit fixed by this change>
# MFH:          <Ports tree branch name you plan to merge to.>
# Relnotes:     <Set to 'yes' for mention in release notes.>
# Security:     <Vulnerability reference (one per line) or description.>
# Sponsored by: <If the change was sponsored by an organization.>
# Pull Request: <https://github.com/freebsd/freebsd-ports/pull/###>
# Differential Revision: <https://reviews.freebsd.org/D###>
#
# "Pull Request" and "Differential Revision" require the *full* GitHub or
# Phabricator URL.
#
# On branch main
# Your branch is up to date with 'origin/main'.
#
# Changes to be committed:
#       modified:   Makefile
#       modified:   distinfo
#
# Changes not staged for commit:
#       modified:   ../../audio/sonic-visualiser/Makefile
#       modified:   ../../audio/sonic-visualiser/distinfo
#       deleted: ../../audio/sonic-visualiser/files/patch-acinclude.m4
#       deleted: ../../audio/sonic-visualiser/files/patch-base.pro
#       deleted: ../../audio/sonic-visualiser/files/patch-config.pri.in
#       deleted: ../../audio/sonic-visualiser/files/patch-configure.ac
#       deleted: ../../audio/sonic-visualiser/files/patch-convert.pro
#       deleted: ../../audio/sonic-visualiser/files/patch-server.pro
#       deleted: 
../../audio/sonic-visualiser/files/patch-sonic-visualiser.pro


Git said that 2 files are to be committed, Makefile and distnfo. This is 
correct.


However, the resulting commit also has audio/sonic-visualiser:

  git diff 99f39b9798ff81b8fb529bea7c16d96e27aecfca~1 
99f39b9798ff81b8fb529bea7c16d96e27aecfca | grep diff
diff --git a/audio/sonic-visualiser/files/patch-acinclude.m4 
b/audio/sonic-visualiser/files/patch-acinclude.m4
diff --git a/audio/sonic-visualiser/files/patch-base.pro 
b/audio/sonic-visualiser/files/patch-base.pro
diff --git a/audio/sonic-visualiser/files/patch-config.pri.in 
b/audio/sonic-visualiser/files/patch-config.pri.in
diff --git a/audio/sonic-visualiser/files/patch-configure.ac 
b/audio/sonic-visualiser/files/patch-configure.ac
diff --git a/audio/sonic-visualiser/files/patch-convert.pro 
b/audio/sonic-visualiser/files/patch-convert.pro
diff --git a/audio/sonic-visualiser/files/patch-server.pro 
b/audio/sonic-visualiser/files/patch-server.pro
diff --git a/audio/sonic-visualiser/files/patch-sonic-visualiser.pro 
b/audio/sonic-visualiser/files/patch-sonic-visualiser.pro
- # (because of the difficulty of getting them running nicely in the
diff --git a/audio/sonic-visualiser/files/patch-sv.pro 
b/audio/sonic-visualiser/files/patch-sv.pro
diff --git a/audio/sonic-visualiser/files/patch-svapp_acinclude.m4 
b/audio/sonic-visualiser/files/patch-svapp_acinclude.m4
diff --git a/audio/sonic-visualiser/files/patch-svcore_acinclude.m4 
b/audio/sonic-visualiser/files/patch-svcore_acinclude.m4
diff --git a/audio/sonic-visualiser/files/patch-svcore_config.pri.in 
b/audio/sonic-visualiser/files/patch-svcore_config.pri.in
diff --git a/audio/sonic-visualiser/files/patch-svgui_acinclude.m4 
b/audio/sonic-visualiser/files/patch-svgui_acinclude.m4
diff --git 
a/audio/sonic-visualiser/files/patch-svgui_layer_WaveformLayer.cpp 
b/audio/sonic-visualiser/files/patch-svgui_layer_WaveformLayer.cpp
diff --git a/audio/sonic-visualiser/files/patch-svgui_view_Overview.cpp 
b/audio/sonic-visualiser/files/patch-svgui_view_Overview.cpp
diff --git a/math/cimod/Makefile b/math/cimod/Makefile
diff --git a/math/cimod/distinfo b/math/cimod/distinfo


This is WRONG!


There *is* a bug in Git.


Each commit needs to be individually checked to see if the right files 
were committed. The Git's commit description can't be trusted.

When it says "Changes not staged for commit" - these files should *not* 
be committed,

This has already hurt me several times.


This should be the highest priority bug.


Yuri



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-07 18:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-21 19:40 'git commit .' in a subdirectory also commits staged files in other subdirectories Yuri
2022-10-21 21:48 ` Taylor Blau
2022-10-21 22:02   ` Junio C Hamano
2022-11-07 18:45   ` Yuri

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).