Re: [RFC PATCH 0/1] *** Add branchname in commit header ***

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

 



On 2019-12-29 at 22:26:32, Arnaud Bertrand wrote:
> From: Arnaud Bertrand <xda@xxxxxxxxxx>
> 
> For tracability purpose it is often necessary to know which
> commit is envolved in a branch
> Keeping track of the branchname in the commit header
> will make this traceability easy and will facilitate
> the graphical toolis that represent the branches and
> that have today to use complex algorithm to try to
> determine the branch of a commit that was known at
> the commit time.
> 
> no big change in the code, today rebase is not considered yet
> I'm waiting feedback about that before touching
> the rebase code.

I encourage you to read back in the history of the list as to why we
haven't done this and why it's not likely to be accepted now, but let me
provide a few reasons of my own.

First, as any contributor to the mailing list can tell you, I am
absolutely terrible at naming things.  I frequently name my branches
something that makes sense to me at the time without regard to whether
that will make sense in the future.  I don't want to memorialize my
momentary thoughtlessness in the history of the repository forever.

Second, one workflow I commonly use is creating a branch with many
commits and then breaking them down into small series that are logical
and easy for review.  If I have a branch called "test-fixes-part7" with
50 commits and then I decide to split that into two branches,
test-fixes-part7 and test-fixes-part8, by copying the branch and using
git reset --hard to truncate the old one, I don't want the old branch
name in my new branch.  A lot of Git workflows assume you can reset and
rename branches this way and having the branch name in the commit header
breaks those workflows.

Third, people reuse branch names.  Right now, I have eight branches with
test fixes all starting with "test-fixes-part" because I'm working on
one major project with all of those test fixes.  However, if a developer
working on another major project also has a lot of changes to the test
suite, they may have lots of identically named branches, which would be
confusing, since our identically named test fix branches would relate to
different projects.  (See my first point.)

However, despite the fact that we aren't likely to add this in the
commit header, there are definitely ways to achieve this.

If you want to include the branch name in the commit, you can do so with
a trailer.  git interpret-trailers can then be used to manipulate and
extract these, and along with a hook, add them automatically if they're
missing.

If you're working on a more centralized project and you want to require
the branch name in your commit trailers, you can set your CI system to
fail or reject commits that don't contain them.  This is the approach
that systems like Gerrit use when the required trailers are missing and
it seems to work reasonably well.

Hopefully these suggestions are helpful in getting you the traceability
you desire without requiring fundamental changes to the way Git works.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

Attachment: signature.asc
Description: PGP signature


[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]

  Powered by Linux