git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Ignore on commit
@ 2012-10-04 16:45 Marco Craveiro
  2012-10-04 20:06 ` Pascal Obry
  0 siblings, 1 reply; 12+ messages in thread
From: Marco Craveiro @ 2012-10-04 16:45 UTC (permalink / raw)
  To: git

Hello gitters,

One of the very (very) few features I miss in svn is "ignore on
commit" (or, more generally, changelists). I'm not sure if this has
been discussed in the past - google failed me a bit due to spurious
matches - but I personally find it quite useful. The feature is
described here [1] (and graphically, here [2]).

The gist of it is, one can mark certain files as "ignore on commit"
and they get placed on a "special list" which shows up on status.
These lists are effectively a sub-division of modified (but not
staged). Up till now I have found the staging area to be quite
sufficient, but recently I hit a use case where I was modifying a
large number of files; some modifications were hacks required to get
the build to work but were not meant to ever get checked in, most
other files had real work. In cases like this its really useful to
mark the hacked files as "ignore on commit", so that a) we don't lose
track of them (as one would with git ignore, or with [4]) but b) we
won't check them in by mistake.

I found some tips on how to survive without change lists ([3], [4])
but they are a bit more cumbersome. Has this feature been discussed?

Thanks a lot for an amazing piece of software, and thanks for your time.

Cheers

Marco
-- 
So young, and already so unknown -- Pauli

blog: http://mcraveiro.blogspot.com

[1] http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.changelist.html
[2] http://blog.baljeetsingh.net/2009/02/tips-tricks-svn-ignore-on-commit.html
[3] http://stackoverflow.com/questions/10606809/git-equivalence-of-svn-changelist
[4] http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

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

* Re: Ignore on commit
  2012-10-04 16:45 Ignore on commit Marco Craveiro
@ 2012-10-04 20:06 ` Pascal Obry
  2012-10-04 21:20   ` Marco Craveiro
  0 siblings, 1 reply; 12+ messages in thread
From: Pascal Obry @ 2012-10-04 20:06 UTC (permalink / raw)
  To: Marco Craveiro; +Cc: git


I'm not sure to follow everything... But looks like:

   $ git add -p

or

   $ git add -i

should do what you want, no?

You select the hunks to commit, let over the "hacks" and then

   $ git commit

-- 

  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://v2p.fr.eu.org
  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

* Re: Ignore on commit
  2012-10-04 20:06 ` Pascal Obry
@ 2012-10-04 21:20   ` Marco Craveiro
  2012-10-04 23:02     ` Andrew Wong
                       ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Marco Craveiro @ 2012-10-04 21:20 UTC (permalink / raw)
  To: pascal; +Cc: git

<ignore on commit>
> I'm not sure to follow everything... But looks like:
>
>    $ git add -p
>
> or
>
>    $ git add -i
>
> should do what you want, no?
>
> You select the hunks to commit, let over the "hacks" and then
>
>    $ git commit

Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files. The
changelist concept allows you to "move" the files out of the way from
the main modified section until you are ready to commit them. Perhaps
an imaginary git status would help:

# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   some_staged_file.h
#
# 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:   some_modified_file.h
#
# Changes ignored on commit:
#
#	modified:   some_other_modified_file.h

Such that if you now did a git add -A, some_modified_file.h would then
be staged but some_other_modified_file.h would stay put. Of course the
name "ignored on commit" makes little sense in git terms, but I'm
using it here as its the svn term. Its a "modified but temporarily
ignored" or something.

Cheers

Marco
-- 
So young, and already so unknown -- Pauli

blog: http://mcraveiro.blogspot.com

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

* Re: Ignore on commit
  2012-10-04 21:20   ` Marco Craveiro
@ 2012-10-04 23:02     ` Andrew Wong
  2012-10-05  1:00     ` Andrew Ardill
  2012-10-05 13:30     ` Pascal Obry
  2 siblings, 0 replies; 12+ messages in thread
From: Andrew Wong @ 2012-10-04 23:02 UTC (permalink / raw)
  To: Marco Craveiro; +Cc: pascal, git

On 10/04/2012 05:20 PM, Marco Craveiro wrote:
> Similar but not quite; the idea is that you know that there is some
> code (I'm just talking about files here, so lets ignore hunks for the
> moment) which is normally checked in but for a period of time you want
> it ignored. So you don't want it git ignored but at the same time you
> don't want to see these files in the list of modified files.
The way I usually handle this scenario is by actually making a temporary 
commit with those temporary changes. And whenever I make a permanent 
commit, I'll use "rebase -i" to rearrange the commits so that all my 
permanent commits go before my temporary commits. So when I need to 
push, I'll just push up till before my temporary commits.

This way I also get to make permanent changes in files that I have 
temporary changes.

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

* Re: Ignore on commit
  2012-10-04 21:20   ` Marco Craveiro
  2012-10-04 23:02     ` Andrew Wong
@ 2012-10-05  1:00     ` Andrew Ardill
  2012-10-05  1:35       ` demerphq
  2012-10-05  7:00       ` Philip Oakley
  2012-10-05 13:30     ` Pascal Obry
  2 siblings, 2 replies; 12+ messages in thread
From: Andrew Ardill @ 2012-10-05  1:00 UTC (permalink / raw)
  To: Marco Craveiro; +Cc: pascal, git

On 5 October 2012 07:20, Marco Craveiro <marco.craveiro@gmail.com> wrote:
> ...
> Similar but not quite; the idea is that you know that there is some
> code (I'm just talking about files here, so lets ignore hunks for the
> moment) which is normally checked in but for a period of time you want
> it ignored. So you don't want it git ignored but at the same time you
> don't want to see these files in the list of modified files.

What is the reason git ignore is no good in this case? Is it simply
that you can't see the ignored files in git status, or is it that
adding and removing entries to .gitignore is too cumbersome? If it's
the latter you could probably put together a simple shell wrapper to
automate the task, as otherwise it seems like git ignore does what you
need.

Regards,

Andrew Ardill

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

* Re: Ignore on commit
  2012-10-05  1:00     ` Andrew Ardill
@ 2012-10-05  1:35       ` demerphq
  2012-10-05  2:20         ` Sitaram Chamarty
  2012-10-05  7:00       ` Philip Oakley
  1 sibling, 1 reply; 12+ messages in thread
From: demerphq @ 2012-10-05  1:35 UTC (permalink / raw)
  To: Andrew Ardill; +Cc: Marco Craveiro, pascal, git

On 5 October 2012 03:00, Andrew Ardill <andrew.ardill@gmail.com> wrote:
> On 5 October 2012 07:20, Marco Craveiro <marco.craveiro@gmail.com> wrote:
>> ...
>> Similar but not quite; the idea is that you know that there is some
>> code (I'm just talking about files here, so lets ignore hunks for the
>> moment) which is normally checked in but for a period of time you want
>> it ignored. So you don't want it git ignored but at the same time you
>> don't want to see these files in the list of modified files.
>
> What is the reason git ignore is no good in this case? Is it simply
> that you can't see the ignored files in git status, or is it that
> adding and removing entries to .gitignore is too cumbersome? If it's
> the latter you could probably put together a simple shell wrapper to
> automate the task, as otherwise it seems like git ignore does what you
> need.

Git ignore doesn't ignore tracked files.

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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

* Re: Ignore on commit
  2012-10-05  1:35       ` demerphq
@ 2012-10-05  2:20         ` Sitaram Chamarty
  2012-10-05  2:44           ` Junio C Hamano
  2012-10-05  2:44           ` Andrew Ardill
  0 siblings, 2 replies; 12+ messages in thread
From: Sitaram Chamarty @ 2012-10-05  2:20 UTC (permalink / raw)
  To: demerphq; +Cc: Andrew Ardill, Marco Craveiro, pascal, git

On Fri, Oct 5, 2012 at 7:05 AM, demerphq <demerphq@gmail.com> wrote:
> On 5 October 2012 03:00, Andrew Ardill <andrew.ardill@gmail.com> wrote:
>> On 5 October 2012 07:20, Marco Craveiro <marco.craveiro@gmail.com> wrote:
>>> ...
>>> Similar but not quite; the idea is that you know that there is some
>>> code (I'm just talking about files here, so lets ignore hunks for the
>>> moment) which is normally checked in but for a period of time you want
>>> it ignored. So you don't want it git ignored but at the same time you
>>> don't want to see these files in the list of modified files.
>>
>> What is the reason git ignore is no good in this case? Is it simply
>> that you can't see the ignored files in git status, or is it that
>> adding and removing entries to .gitignore is too cumbersome? If it's
>> the latter you could probably put together a simple shell wrapper to
>> automate the task, as otherwise it seems like git ignore does what you
>> need.
>
> Git ignore doesn't ignore tracked files.

would 'git update-index --assume-unchanged' work in this case?  Didn't
see it mentioned in any of the replies so far (but I have never used
it myself)

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

* Re: Ignore on commit
  2012-10-05  2:20         ` Sitaram Chamarty
@ 2012-10-05  2:44           ` Junio C Hamano
  2012-10-05  2:44           ` Andrew Ardill
  1 sibling, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2012-10-05  2:44 UTC (permalink / raw)
  To: Sitaram Chamarty; +Cc: demerphq, Andrew Ardill, Marco Craveiro, pascal, git

Sitaram Chamarty <sitaramc@gmail.com> writes:

>> Git ignore doesn't ignore tracked files.
>
> would 'git update-index --assume-unchanged' work in this case?  Didn't
> see it mentioned in any of the replies so far (but I have never used
> it myself)

The assume-unchanged bit is *not* an instruction to tell Git to
ignore changes.  It is your *promise* that you will not change it,
and tells Git that it is free to use the contents from the working
tree and the contents in the index interchangeably, taking whichever
is more convenient for Git to handle.

So, no, it might appear to work in some cases, but you are playing
with an undefined behaviour.

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

* Re: Ignore on commit
  2012-10-05  2:20         ` Sitaram Chamarty
  2012-10-05  2:44           ` Junio C Hamano
@ 2012-10-05  2:44           ` Andrew Ardill
  2012-10-05  6:09             ` Marco Craveiro
  1 sibling, 1 reply; 12+ messages in thread
From: Andrew Ardill @ 2012-10-05  2:44 UTC (permalink / raw)
  To: Sitaram Chamarty; +Cc: demerphq, Marco Craveiro, pascal, git

On 5 October 2012 12:20, Sitaram Chamarty <sitaramc@gmail.com> wrote:
> On Fri, Oct 5, 2012 at 7:05 AM, demerphq <demerphq@gmail.com> wrote:
>> On 5 October 2012 03:00, Andrew Ardill <andrew.ardill@gmail.com> wrote:
>>> On 5 October 2012 07:20, Marco Craveiro <marco.craveiro@gmail.com> wrote:
>>>> ...
>>>> Similar but not quite; the idea is that you know that there is some
>>>> code (I'm just talking about files here, so lets ignore hunks for the
>>>> moment) which is normally checked in but for a period of time you want
>>>> it ignored. So you don't want it git ignored but at the same time you
>>>> don't want to see these files in the list of modified files.
>>>
>>> What is the reason git ignore is no good in this case? Is it simply
>>> that you can't see the ignored files in git status, or is it that
>>> adding and removing entries to .gitignore is too cumbersome? If it's
>>> the latter you could probably put together a simple shell wrapper to
>>> automate the task, as otherwise it seems like git ignore does what you
>>> need.
>>
>> Git ignore doesn't ignore tracked files.
>
> would 'git update-index --assume-unchanged' work in this case?  Didn't
> see it mentioned in any of the replies so far (but I have never used
> it myself)

>From the help page:

--assume-unchanged, --no-assume-unchanged
    ...

    This option can be also used as a coarse file-level mechanism to
ignore uncommitted changes in tracked files (akin to what .gitignore
    does for untracked files).

Seems like it does everything required. I tested and it correctly
hides changes that I want hidden. The only thing I can't see how to do
is get git status to show files with the assume unchanged  bit set. I
think there is no way currently, but that might be a nice addition to
make the initial request feature complete. It could show either all
files with the bit set, or files with the bit set that have been
changed (or this could be configurable).

Regards,

Andrew Ardill

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

* Re: Ignore on commit
  2012-10-05  2:44           ` Andrew Ardill
@ 2012-10-05  6:09             ` Marco Craveiro
  0 siblings, 0 replies; 12+ messages in thread
From: Marco Craveiro @ 2012-10-05  6:09 UTC (permalink / raw)
  To: Andrew Ardill; +Cc: Sitaram Chamarty, demerphq, pascal, git

<git update-index --assume-unchanged>
> From the help page:
>
> --assume-unchanged, --no-assume-unchanged
>     ...
>
>     This option can be also used as a coarse file-level mechanism to
> ignore uncommitted changes in tracked files (akin to what .gitignore
>     does for untracked files).
>
> Seems like it does everything required. I tested and it correctly
> hides changes that I want hidden. The only thing I can't see how to do
> is get git status to show files with the assume unchanged  bit set. I
> think there is no way currently, but that might be a nice addition to
> make the initial request feature complete. It could show either all
> files with the bit set, or files with the bit set that have been
> changed (or this could be configurable).

This is indeed the solution outlined in [4] on my original post:

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

The presence in git status is quite important or else one has to
change the regular workflow with a second status command.

Cheers

Marco
-- 
So young, and already so unknown -- Pauli

blog: http://mcraveiro.blogspot.com

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

* Re: Ignore on commit
  2012-10-05  1:00     ` Andrew Ardill
  2012-10-05  1:35       ` demerphq
@ 2012-10-05  7:00       ` Philip Oakley
  1 sibling, 0 replies; 12+ messages in thread
From: Philip Oakley @ 2012-10-05  7:00 UTC (permalink / raw)
  To: Andrew Ardill, Marco Craveiro; +Cc: pascal, git

From: "Andrew Ardill" <andrew.ardill@gmail.com>
> On 5 October 2012 07:20, Marco Craveiro <marco.craveiro@gmail.com> 
> wrote:
>> ...
>> Similar but not quite; the idea is that you know that there is some
>> code (I'm just talking about files here, so lets ignore hunks for the
>> moment) which is normally checked in but for a period of time you 
>> want
>> it ignored. So you don't want it git ignored but at the same time you
>> don't want to see these files in the list of modified files.
>
> What is the reason git ignore is no good in this case? Is it simply
> that you can't see the ignored files in git status, or is it that
> adding and removing entries to .gitignore is too cumbersome? If it's
> the latter you could probably put together a simple shell wrapper to
> automate the task, as otherwise it seems like git ignore does what you
> need.
>

IIUC the files are already tracked, and a variant of ' git 
update-index --assume-unchanged' is being requested, so that the command 
doesn't need to be repeated if they checkuout / swap branches (which 
assumes I've understood the effect of such an index change correctly)

> Regards,
>
> Andrew Ardill
> --

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

* Re: Ignore on commit
  2012-10-04 21:20   ` Marco Craveiro
  2012-10-04 23:02     ` Andrew Wong
  2012-10-05  1:00     ` Andrew Ardill
@ 2012-10-05 13:30     ` Pascal Obry
  2 siblings, 0 replies; 12+ messages in thread
From: Pascal Obry @ 2012-10-05 13:30 UTC (permalink / raw)
  To: Marco Craveiro; +Cc: git


Marco,

> Similar but not quite; the idea is that you know that there is some
> code (I'm just talking about files here, so lets ignore hunks for the
> moment) which is normally checked in but for a period of time you want
> it ignored. 

Got it thanks! Would be useful some time indeed.

-- 

  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://v2p.fr.eu.org
  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

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

end of thread, other threads:[~2012-10-05 13:30 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-04 16:45 Ignore on commit Marco Craveiro
2012-10-04 20:06 ` Pascal Obry
2012-10-04 21:20   ` Marco Craveiro
2012-10-04 23:02     ` Andrew Wong
2012-10-05  1:00     ` Andrew Ardill
2012-10-05  1:35       ` demerphq
2012-10-05  2:20         ` Sitaram Chamarty
2012-10-05  2:44           ` Junio C Hamano
2012-10-05  2:44           ` Andrew Ardill
2012-10-05  6:09             ` Marco Craveiro
2012-10-05  7:00       ` Philip Oakley
2012-10-05 13:30     ` Pascal Obry

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).