git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Bug Report: Creating a hardlink to any of the file in git repo cause the source file  to show up in git commit message editor under "Changes not staged for commit" section.
@ 2011-07-18  3:24 Michael
  2011-07-18 20:12 ` Andreas Schwab
  0 siblings, 1 reply; 4+ messages in thread
From: Michael @ 2011-07-18  3:24 UTC (permalink / raw)
  To: git

 Creating a hardlink to any of the file in git repo cause the source 
 file
 to show up in git commit message editor under "Changes not staged for 
 commit"
 section.

 Reproduced on:
 Ubuntu 10.04, Gentoo, FreeBSD
 Git version: 1.7.6

 Bug has been observed by atleast 3 people.

 Follow these steps to reproduce:

 # create test repo
 cd /tmp
 mkdir -p test-repo/repo
 cd test-repo/repo
 git init
 git config user.name "Foo"
 git config user.email "foo@example.com"

 # put some files in the repo
 touch FILE1 FILE2 FILE3 FILE4 FILE5
 git add -A
 git commit -m "initial commit"

 # create git hook that hardlink FILE2 and FILE3 and remove the 
 hardlinks
 # right then and there
 echo "ln -vf FILE2 ../HARDLINK_TO_FILE2" >| .git/hooks/pre-commit
 echo "rm -vf ../HARDLINK_TO_FILE2" >> .git/hooks/pre-commit
 echo "ln -vf FILE3 ../HARDLINK_TO_FILE3" >> .git/hooks/pre-commit
 echo "rm -vf ../HARDLINK_TO_FILE3" >> .git/hooks/pre-commit

 # make pre-commit executable
 chmod u+x .git/hooks/pre-commit

 # modify FILE1
 echo "hello world" >> FILE1

 # run git status
 git status
 -------------------------------------------------------------------------------
 # On branch master
 # Changes not staged for commit:
 #   (use "git add <file>..." to update what will be committed)
 #   (use "git checkout -- <file>..." to discard changes in working 
 directory)
 #
 #       modified:   FILE1
 #
 no changes added to commit (use "git add" and/or "git commit -a")
 -------------------------------------------------------------------------------

 # try commit using nano as commit editor and without usin -a flag
 VISUAL=nano git commit FILE1

 # Despite the fact that they are modified FILE2 and FILE3 will show in 
 the
 # commit message, under "Changes not staged for commit" section
 # like so:

 --------------------------------------------------------------------------------
 # Please enter the commit message for your changes. Lines starting
 # with '#' will be ignored, and an empty message aborts the commit.
 # Explicit paths specified without -i nor -o; assuming --only paths...
 # On branch master
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #       modified:   FILE1
 #
 # Changes not staged for commit:
 #   (use "git add <file>..." to update what will be committed)
 #   (use "git checkout -- <file>..." to discard changes in working 
 directory)
 #
 #       modified:   FILE2
 #       modified:   FILE3
 #
 --------------------------------------------------------------------------------


 In case anyone interested, tor me this happens when I do a python EGG 
 build
 which hardlinks files in order to build.


 -- Michael

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

* Bug Report: Creating a hardlink to any of the file in git repo cause the source file  to show up in git commit message editor under "Changes not staged for commit" section.
@ 2011-07-18  3:42 Michael
  2011-07-18 18:37 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Michael @ 2011-07-18  3:42 UTC (permalink / raw)
  To: git

 Creating a hardlink to any of the file in git repo cause the source 
 file
 to show up in git commit message editor under "Changes not staged for 
 commit"
 section.

 Reproduced on:
 Ubuntu 10.04, Gentoo, FreeBSD
 Git version: 1.7.6

 Bug has been observed by atleast 3 people.

 Follow these steps to reproduce:

 # create test repo
 cd /tmp
 mkdir -p test-repo/repo
 cd test-repo/repo
 git init
 git config user.name "Foo"
 git config user.email "foo@example.com"

 # put some files in the repo
 touch FILE1 FILE2 FILE3 FILE4 FILE5
 git add -A
 git commit -m "initial commit"

 # create git hook that hardlink FILE2 and FILE3 and remove the 
 hardlinks
 # right then and there
 echo "ln -vf FILE2 ../HARDLINK_TO_FILE2" >| .git/hooks/pre-commit
 echo "rm -vf ../HARDLINK_TO_FILE2" >> .git/hooks/pre-commit
 echo "ln -vf FILE3 ../HARDLINK_TO_FILE3" >> .git/hooks/pre-commit
 echo "rm -vf ../HARDLINK_TO_FILE3" >> .git/hooks/pre-commit

 # make pre-commit executable
 chmod u+x .git/hooks/pre-commit

 # modify FILE1
 echo "hello world" >> FILE1

 # run git status
 git status
 -------------------------------------------------------------------------------
 # On branch master
 # Changes not staged for commit:
 #   (use "git add <file>..." to update what will be committed)
 #   (use "git checkout -- <file>..." to discard changes in working 
 directory)
 #
 #       modified:   FILE1
 #
 no changes added to commit (use "git add" and/or "git commit -a")
 -------------------------------------------------------------------------------

 # try commit using nano as commit editor and without usin -a flag
 VISUAL=nano git commit FILE1

 # Despite the fact that they are modified FILE2 and FILE3 will show in 
 the
 # commit message, under "Changes not staged for commit" section
 # like so:

 --------------------------------------------------------------------------------
 # Please enter the commit message for your changes. Lines starting
 # with '#' will be ignored, and an empty message aborts the commit.
 # Explicit paths specified without -i nor -o; assuming --only paths...
 # On branch master
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #       modified:   FILE1
 #
 # Changes not staged for commit:
 #   (use "git add <file>..." to update what will be committed)
 #   (use "git checkout -- <file>..." to discard changes in working 
 directory)
 #
 #       modified:   FILE2
 #       modified:   FILE3
 #
 --------------------------------------------------------------------------------


 In case anyone interested, tor me this happens when I do a python EGG 
 build
 which hardlinks files in order to build.


 -- Michael

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

* Re: Bug Report: Creating a hardlink to any of the file in git repo cause the source file  to show up in git commit message editor under "Changes not staged for commit" section.
  2011-07-18  3:42 Bug Report: Creating a hardlink to any of the file in git repo cause the source file to show up in git commit message editor under "Changes not staged for commit" section Michael
@ 2011-07-18 18:37 ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2011-07-18 18:37 UTC (permalink / raw)
  To: Michael who??; +Cc: git

Michael <git-scm@webhippo.net> writes:

> echo "ln -vf FILE2 ../HARDLINK_TO_FILE2" >| .git/hooks/pre-commit
> echo "rm -vf ../HARDLINK_TO_FILE2" >> .git/hooks/pre-commit
> echo "ln -vf FILE3 ../HARDLINK_TO_FILE3" >> .git/hooks/pre-commit
> echo "rm -vf ../HARDLINK_TO_FILE3" >> .git/hooks/pre-commit

This does not have to do anything with hardlink. A simple "touch" should
do as long as FILE2/FILE3 are sufficiently old.

You are smudging cached stat information in your pre-commit hook (st_ctime
would be different), and that is shown as a difference between the working
tree and the index (note that nowhere in githooks documentation we say
pre-commit hook is allowed to muck with the working tree files). I think
we do refresh the cached stat information before running the pre-commit
hook so that the hook can check the list of working tree files that are
different from the index using diff-files, but the purpose of the said
hook is to validate, and not affect, the state of the working tree, and I
wouldn't be surprised if we do not update the cached stat information
after the hook returns control to us.

If you really want to munge the working tree inside pre-commit, I think
adding "git update-index --refresh" at the end of pre-commit hook would
make the phantom change go away.

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

* Re: Bug Report: Creating a hardlink to any of the file in git repo cause the source file  to show up in git commit message editor under "Changes not staged for commit" section.
  2011-07-18  3:24 Michael
@ 2011-07-18 20:12 ` Andreas Schwab
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2011-07-18 20:12 UTC (permalink / raw)
  To: git-scm; +Cc: git

Michael <git-scm@webhippo.net> writes:

> In case anyone interested, tor me this happens when I do a python EGG
> build
> which hardlinks files in order to build.

Try "git config core.trustctime false".  Adding a link changes ctime.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

end of thread, other threads:[~2011-07-18 20:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-18  3:42 Bug Report: Creating a hardlink to any of the file in git repo cause the source file to show up in git commit message editor under "Changes not staged for commit" section Michael
2011-07-18 18:37 ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2011-07-18  3:24 Michael
2011-07-18 20:12 ` Andreas Schwab

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 NNTP newsgroup(s).