git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* feature request: .blameignore
@ 2019-04-15 20:55 Christian González
  2019-04-15 21:15 ` Thomas Gummerer
  0 siblings, 1 reply; 5+ messages in thread
From: Christian González @ 2019-04-15 20:55 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 2610 bytes --]

Hello git community,

I'm completely new here, and maybe my request is dumb, has already a
better solution, or I did not fully understand git. Please tell my if
so. I stumbled upon this idea while following the django developers
mailing list, people there discussing whether nor not to adopt *black*
(https://github.com/ambv/black, a python code formatting tool) as
enhancement in the development cycle. One of the main arguments against
black was that it changes git history by masking git blame. Whenever a
git commit with only a black formatting change is committed, you can't
easily see using git blame WHO did actially write a line of code
*before* that commit. It is possible to look further manually, and they
said there are tools like git-hyper-blame that circumvent that problem,
but I always asked myself since I use git, why isn't there a simple
possibility how I can e.g. fix a whitespace code "error", or do a code
reformatting WITHOUT taking away the original author's credits for that
line.

I know, there are some counter arguments about that:  e.g. whitespace
changes could lead to programming errors too, even to compiler errors,
depending on the language, and how the compiler engine treats whitespace.

I don't suggest git to ignore whitespace (or whatever) changes in the
blame history automatically.

What I suggest is: let git accept a file like .blameignore,
.gitblameignore, .gitblame etc., you name it.
In my simply suggest, I would see that file as one-hash-per-line that is
ignored by git blame. And for the sake of convenience, add a git option
to add that hash automatically:

    git commit -m "fix whitespace" --blame-ignore

This would add this commit's hash to the .gitblameignore (or whatever) file:

4070ddcdd3d3cc45ec7952e1b37ab374aed9083c # fix whitespace

and a "git blame any_file.txt" would ignore this one commit and show the
last commit's author of changed lines.

Even better would it be to allow chunks to be excluded, because bad
commit habits of whitespace AND real code changes at the same time are
not possible to undo later - except there would be a .gitblameignore file.

It would even be possible to incorporate this into tht .gitignore file,
with a section, or a certain prefix...

IMHO, this would allow better per-project maintainance of blame history
which could be changed later in time and  re-fixed if done wrong - all
within git history itself.

I'd love to hear what you think about that.

Yours,

Christian



-- 
Dr. Christian González
https://nerdocs.at
+43 (0) 650 7644477 


[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 16605 bytes --]

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

* Re: feature request: .blameignore
  2019-04-15 20:55 feature request: .blameignore Christian González
@ 2019-04-15 21:15 ` Thomas Gummerer
  2019-04-15 21:56   ` Christian González
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Gummerer @ 2019-04-15 21:15 UTC (permalink / raw)
  To: Christian González; +Cc: git, Barret Rhoden

On 04/15, Christian González wrote:
> Hello git community,
> 
> I'm completely new here, and maybe my request is dumb, has already a
> better solution, or I did not fully understand git. Please tell my if
> so. I stumbled upon this idea while following the django developers
> mailing list, people there discussing whether nor not to adopt *black*
> (https://github.com/ambv/black, a python code formatting tool) as
> enhancement in the development cycle. One of the main arguments against
> black was that it changes git history by masking git blame. Whenever a
> git commit with only a black formatting change is committed, you can't
> easily see using git blame WHO did actially write a line of code
> *before* that commit. It is possible to look further manually, and they
> said there are tools like git-hyper-blame that circumvent that problem,
> but I always asked myself since I use git, why isn't there a simple
> possibility how I can e.g. fix a whitespace code "error", or do a code
> reformatting WITHOUT taking away the original author's credits for that
> line.
> 
> I know, there are some counter arguments about that:  e.g. whitespace
> changes could lead to programming errors too, even to compiler errors,
> depending on the language, and how the compiler engine treats whitespace.
> 
> I don't suggest git to ignore whitespace (or whatever) changes in the
> blame history automatically.
> 
> What I suggest is: let git accept a file like .blameignore,
> .gitblameignore, .gitblame etc., you name it.
> In my simply suggest, I would see that file as one-hash-per-line that is
> ignored by git blame. And for the sake of convenience, add a git option
> to add that hash automatically:

This sounds roughly like what Barret Rhoden (added to Cc) has been
working on.  I haven't followed that patch series in detail, but you
can have a look at it atthe latest iteration at
https://public-inbox.org/git/20190410162409.117264-1-brho@google.com/.

>     git commit -m "fix whitespace" --blame-ignore
> 
> This would add this commit's hash to the .gitblameignore (or whatever) file:
> 
> 4070ddcdd3d3cc45ec7952e1b37ab374aed9083c # fix whitespace
> 
> and a "git blame any_file.txt" would ignore this one commit and show the
> last commit's author of changed lines.
> 
> Even better would it be to allow chunks to be excluded, because bad
> commit habits of whitespace AND real code changes at the same time are
> not possible to undo later - except there would be a .gitblameignore file.
> 
> It would even be possible to incorporate this into tht .gitignore file,
> with a section, or a certain prefix...
> 
> IMHO, this would allow better per-project maintainance of blame history
> which could be changed later in time and  re-fixed if done wrong - all
> within git history itself.
> 
> I'd love to hear what you think about that.
> 
> Yours,
> 
> Christian
> 
> 
> 
> -- 
> Dr. Christian González
> https://nerdocs.at
> +43 (0) 650 7644477 
> 

[-- Error: unable to create PGP subprocess! --]


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

* Re: feature request: .blameignore
  2019-04-15 21:15 ` Thomas Gummerer
@ 2019-04-15 21:56   ` Christian González
  2019-04-16 14:52     ` Barret Rhoden
  0 siblings, 1 reply; 5+ messages in thread
From: Christian González @ 2019-04-15 21:56 UTC (permalink / raw)
  To: Thomas Gummerer; +Cc: git, Barret Rhoden

[-- Attachment #1: Type: text/plain, Size: 2001 bytes --]

Am 15.04.19 um 23:15 schrieb Thomas Gummerer:
> This sounds roughly like what Barret Rhoden (added to Cc) has been
> working on.  I haven't followed that patch series in detail, but you
> can have a look at it atthe latest iteration at
> https://public-inbox.org/git/20190410162409.117264-1-brho@google.com/.

As far as I can see this is an "automagic" way of creating those "blame
skips" - which can be easier in some way, but until it works "perfect"
It is prone to produce problems IMHO.

The git history is a "document" that _has_ not to be changed by design.
So if this "heuristic" produces a wrong result, it's kind of
unpredictable what was wrong.

I think it would be MUCH easier to mark chunks or whole commits as  "not
important" explicitly - by using a file.

Look at .gitignore: git isn't trying to heuristically determine which
files should be ignored when committing. This is done explicitly in a
.gitignore file.

For blames this could be done too.

Heuristics could lead to other kind of problems too, as the engine does
not know anything about the project. Maybe there will be a programming
language in near future where trailing whitespaces matter (bah, please
not). But the project should decide, not git itself.

So IMHO project specific .*ignore files are the better way of handling
this than doing the skipping on heuristics alone - which could be
helpful though when *creating* that files, even during the commit
process... like

    git ccheckut
    git: 'ccheckut' is not a git command. See 'git --help'.

    The most similar command is
    checkout

Maybe a lazy:

    git commit -a -m "big, clunky, fixes everything and the rest"

could produce a message like:

    There are whitespace changes in files <file_a>, <file_b> ... -
    git automatically marked them as not important
    commits. They are ignored when using git-blame.

Christian

--

Dr. Christian González
https://nerdocs.at


[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 16605 bytes --]

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

* Re: feature request: .blameignore
  2019-04-15 21:56   ` Christian González
@ 2019-04-16 14:52     ` Barret Rhoden
  2019-04-16 16:33       ` Christian González
  0 siblings, 1 reply; 5+ messages in thread
From: Barret Rhoden @ 2019-04-16 14:52 UTC (permalink / raw)
  To: Christian González, Thomas Gummerer; +Cc: git

Hi -

On 4/15/19 5:56 PM, Christian González wrote:
> Am 15.04.19 um 23:15 schrieb Thomas Gummerer:
>> This sounds roughly like what Barret Rhoden (added to Cc) has been
>> working on.  I haven't followed that patch series in detail, but you
>> can have a look at it atthe latest iteration at
>> https://public-inbox.org/git/20190410162409.117264-1-brho@google.com/.
> 
> As far as I can see this is an "automagic" way of creating those "blame
> skips" - which can be easier in some way, but until it works "perfect"
> It is prone to produce problems IMHO.
> 
> The git history is a "document" that _has_ not to be changed by design.
> So if this "heuristic" produces a wrong result, it's kind of
> unpredictable what was wrong.
> 
> I think it would be MUCH easier to mark chunks or whole commits as  "not
> important" explicitly - by using a file.

I think there's a slight misunderstanding.  In the patchset that Michael 
and I are working on, the user specifies whole commits explicitly.  This 
is usually done with a file, but can also be done from the command line 
for "one-off" ignored commits.  That sounds like what you want.

The heuristics come in when we try to pass blame for specific *lines* 
that an ignored commit touched.  We pass the blame to the parent commit, 
but we also want to match the lines to a specific line in the parent 
commit.  That way we can find the 'right' ancestor commmit.  We're not 
able to always identify the 'right' commit, hence the heuristics.

Barret


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

* Re: feature request: .blameignore
  2019-04-16 14:52     ` Barret Rhoden
@ 2019-04-16 16:33       ` Christian González
  0 siblings, 0 replies; 5+ messages in thread
From: Christian González @ 2019-04-16 16:33 UTC (permalink / raw)
  To: Barret Rhoden, Thomas Gummerer; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 901 bytes --]


> I think there's a slight misunderstanding.  In the patchset that
> Michael and I are working on, the user specifies whole commits
> explicitly.  This is usually done with a file, but can also be done
> from the command line for "one-off" ignored commits.  That sounds like
> what you want.
>
> The heuristics come in when we try to pass blame for specific *lines*
> that an ignored commit touched.  We pass the blame to the parent
> commit, but we also want to match the lines to a specific line in the
> parent commit.  That way we can find the 'right' ancestor commmit. 
> We're not able to always identify the 'right' commit, hence the
> heuristics.
>
Oh - that's something different, yes - thank you for clarifying!
Misunderstanding on my side, yes. This is a really great feature! Is
there a vague time schedule for a release? Still this year?

Thanks!

Christian


[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 16605 bytes --]

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

end of thread, other threads:[~2019-04-16 16:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15 20:55 feature request: .blameignore Christian González
2019-04-15 21:15 ` Thomas Gummerer
2019-04-15 21:56   ` Christian González
2019-04-16 14:52     ` Barret Rhoden
2019-04-16 16:33       ` Christian González

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