From: Michael J Gruber <git@drmicha.warpmail.net>
To: Joshua Jensen <jjensen@workspacewhiz.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Automatically exclude hunks from the commit
Date: Tue, 20 Jul 2010 11:26:20 +0200 [thread overview]
Message-ID: <4C456BBC.8010203@drmicha.warpmail.net> (raw)
In-Reply-To: <4C4511C8.8090405@workspacewhiz.com>
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
prev parent reply other threads:[~2010-07-20 9:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C456BBC.8010203@drmicha.warpmail.net \
--to=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=jjensen@workspacewhiz.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).