[BUG] pre-applypatch can no longer add to staging area

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

 



Hi,

At $dayjob we've been using a pre-applypatch hook to keep an eye on
some software metrics as sub-area maintainers receive changes from
developers. When a particular metric goes up we inform the maintainer
that they should reject the patch and stop 'git am' from continuing.
When the metric goes down automatically update the stored metric count
and include that change in the commit. Prior to git 2.6.3 this was
working, its probably prior to 2.6.0 the last version I know worked
was 2.5.3

Consider the following pre-applypatch hook to stop people adding more
uses of strcpy() to an existing code base.

  #/bin/sh
  current=$(cat .count)
  new=$(git grep -c strcpy)
  if test "$new" -gt "$current"; then
    echo "Bad patch"
    exit 1
  fi

  if  test "$new" -lt "$current"; then
     echo "Awesome patch"
     echo "$new" >.count
     git add .count
  fi

  exit 0

When a maintainer runs 'git am patch.patch' the hook would run and
record the new metric value in the staging area before the commit is
created.

Based on my reading of the pre-applypatch documentation I think this
is a valid use-case. The hook is invoked with the changes applied but
before they are committed so it should be OK to add additional changes
to the staging area as part of the hook. Interestingly with the newer
git version the change is not even staged.

Thanks,
Chris
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



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