Re: gitignore design

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Sixt <j.sixt@xxxxxxxxxxxxx> writes:
> Am 7/29/2011 14:19, schrieb Jakub Narebski:
> > For that you can use 'assume-unachanged' mechanism (note: it is local
> > to repository).  The gitignore(7) manpage says:
> > 
> >   NOTES
> >      The purpose of gitignore files is to ensure that certain files not tracked
> >      by git remain untracked.
> > 
> >      To ignore uncommitted changes in a file that is already tracked, use
> >      `git update-index --assume-unchanged <file>`.
> 
> This statement in our documentation is *wrong*!! Please do not suggest it
> for cases like the OP's!
> 
> See the discussion of assume-unchanged in git-update-index: This bit
> actually means that git may assume that the file was not changed, and it
> can take the worktree's data when it otherwise would have to unpack the
> index's data. IOW, using it for the purposes that the OP would need is
> *dangerous*.

Are you sure?  It seems to work as I thought it would.

  $ git init
  Initialized empty Git repository in /tmp/jnareb/test/.git/
  [master!test]$ echo foo >foo
  [master!test]$ echo bar >bar
  [master!test]$ echo bar >.gitignore
  [master!test]$ git add .
  [master!test]$ git commit -m Initial
  [master (root-commit) 522267b] Initial
   2 files changed, 2 insertions(+), 0 deletions(-)
   create mode 100644 .gitignore
   create mode 100644 foo
  [master!test]$ git add -f bar
  [master!test]$ git commit -m 'Add bar (ignored)'
  [master a708f70] Add bar (ignored)
   1 files changed, 1 insertions(+), 0 deletions(-)
   create mode 100644 bar
  [master!test]$ echo foo >>foo
  [master!test]$ echo bar >>bar
  [master!test]$ git status -s
   M bar
   M foo
  [master!test]$ git update-index --assume-unchanged bar
  [master!test]$ git status -s
   M foo
  [master!test]$ git commit -a -m "assume-unchanged bar, both changed"
  [master ec74f8e] assume-unchanged bar, both changed
   1 files changed, 1 insertions(+), 0 deletions(-)
  [master!test]$ git status -s
  [master!test]$ git show
  commit ec74f8e3f3f819bba22453324d7659fe8dd253e8
  Author: Jakub Narebski <jnareb@xxxxxxxxx>
  Date:   Fri Jul 29 44 2011 +0200
  
      assume-unchanged bar, both changed
  
  diff --git a/foo b/foo
  index 257cc56..0d55bed 100644
  --- a/foo
  +++ b/foo
  @@ -1 +1,2 @@
   foo
  +foo

Notice that change to 'bar' didn't get comitted.

-- 
Jakub Narębski

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]