git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Automatically exclude hunks from the commit
@ 2010-07-20  3:02 Joshua Jensen
  2010-07-20  5:17 ` Joshua Juran
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Joshua Jensen @ 2010-07-20  3:02 UTC (permalink / raw)
  To: git@vger.kernel.org

  I have some files I update frequently where I have some normally 
commented out debug code purposely uncommented during development.  
Git's hunk-level staging saves the day.  I can stage everything but the 
debug code without issue.

This got me to thinking.  Is there a better way?  Is there a facility in 
Git where I could mark a hunk as 'permanently frozen unstaged'?  
Anything marked as such would never be staged for commit.  I could rest 
assured I would never accidentally commit my debug code, be it extra 
printfs or a development server or a password or so on.

Thanks for the help.

Josh

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

* Re: Automatically exclude hunks from the commit
  2010-07-20  3:02 Automatically exclude hunks from the commit Joshua Jensen
@ 2010-07-20  5:17 ` Joshua Juran
  2010-07-20  5:36 ` Wincent Colaiuta
  2010-07-20  9:26 ` Michael J Gruber
  2 siblings, 0 replies; 4+ messages in thread
From: Joshua Juran @ 2010-07-20  5:17 UTC (permalink / raw)
  To: Joshua Jensen; +Cc: git@vger.kernel.org

On Jul 19, 2010, at 8:02 PM, Joshua Jensen wrote:

> I have some files I update frequently where I have some normally  
> commented out debug code purposely uncommented during development.   
> Git's hunk-level staging saves the day.  I can stage everything but  
> the debug code without issue.
>
> This got me to thinking.  Is there a better way?  Is there a  
> facility in Git where I could mark a hunk as 'permanently frozen  
> unstaged'?  Anything marked as such would never be staged for  
> commit.  I could rest assured I would never accidentally commit my  
> debug code, be it extra printfs or a development server or a  
> password or so on.

How about keeping your debug changes in a separate branch?  I work on  
a branch called 'hack', to which I'll commit pretty much anything.   
When a patch is ready, I cherry-pick it from master and rebase hack  
onto master.[1]

Passwords which are so sensitive that they can't ever be checked in  
should be stored in ignored files or outside the repo entirely.

Josh

[1] It's actually more complicated than that.  I create 'tip' as a  
merger of master and my formal topic branches, and hack stays rebased  
on tip.

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

* Re: Automatically exclude hunks from the commit
  2010-07-20  3:02 Automatically exclude hunks from the commit Joshua Jensen
  2010-07-20  5:17 ` Joshua Juran
@ 2010-07-20  5:36 ` Wincent Colaiuta
  2010-07-20  9:26 ` Michael J Gruber
  2 siblings, 0 replies; 4+ messages in thread
From: Wincent Colaiuta @ 2010-07-20  5:36 UTC (permalink / raw)
  To: Joshua Jensen; +Cc: git@vger.kernel.org

El 20/07/2010, a las 05:02, Joshua Jensen escribió:

> I have some files I update frequently where I have some normally commented out debug code purposely uncommented during development.  Git's hunk-level staging saves the day.  I can stage everything but the debug code without issue.
> 
> This got me to thinking.  Is there a better way?  Is there a facility in Git where I could mark a hunk as 'permanently frozen unstaged'?  Anything marked as such would never be staged for commit.  I could rest assured I would never accidentally commit my debug code, be it extra printfs or a development server or a password or so on.

A custom pre-commit hook might be of some use here. You could create one which rejects changes which are obviously debug code.

Cheers,
Wincent

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

* Re: Automatically exclude hunks from the commit
  2010-07-20  3:02 Automatically exclude hunks from the commit Joshua Jensen
  2010-07-20  5:17 ` Joshua Juran
  2010-07-20  5:36 ` Wincent Colaiuta
@ 2010-07-20  9:26 ` Michael J Gruber
  2 siblings, 0 replies; 4+ messages in thread
From: Michael J Gruber @ 2010-07-20  9:26 UTC (permalink / raw)
  To: Joshua Jensen; +Cc: git@vger.kernel.org

Joshua Jensen venit, vidit, dixit 20.07.2010 05:02:
>   I have some files I update frequently where I have some normally 
> commented out debug code purposely uncommented during development.  
> Git's hunk-level staging saves the day.  I can stage everything but the 
> debug code without issue.
> 
> This got me to thinking.  Is there a better way?  Is there a facility in 
> Git where I could mark a hunk as 'permanently frozen unstaged'?  
> Anything marked as such would never be staged for commit.  I could rest 
> assured I would never accidentally commit my debug code, be it extra 
> printfs or a development server or a password or so on.
> 
> Thanks for the help.
> 
> Josh

If you don't want to deal with the branch approach suggested by the
other Joshua you could (ab)use the clean&smudge filters (see "filter" in
gitattributes(5)):

Define a clean filter such as "fgrep -v GITIGNORE" and mark every source
line which you want to ignore with a comment:

printf("Happy we got this far but I have no clue why"); // GITIGNORE

You can do more clever things with awk or sed, of course. "GITIGNORE" is
just some hopefully unused string.

Note that a "checkout" would overwrite your debug lines!

Cheers,
Michael

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

end of thread, other threads:[~2010-07-20  9:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-20  3:02 Automatically exclude hunks from the commit Joshua Jensen
2010-07-20  5:17 ` Joshua Juran
2010-07-20  5:36 ` Wincent Colaiuta
2010-07-20  9:26 ` Michael J Gruber

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