4

I'm using git on Windows 7 (my user is in the local admin group) with my dev project, but everytime I commit changes, the file .git/COMMIT_EDITMSG change too : It's content is replaced with the last commit msg (which is fine) It's property changed to readonly.

Because of this property change, the next commit I'll make will return an error "Permission denied"...

As I saw in other posts, I tried to delete both files: - .git/COMMIT_EDITMSG - .git/COMMIT_EDITMSG.bak

Or I also tried to just uncheck the readonly property manually, but the problem is still there after the next successful commit...

What should I do to repair this problem ?

Notice that I've setted a prepare-commit-msg hook which can perhaps be the problem ? Hook content below :

#!/bin/bash

# Name this script "prepare-commit-msg"
# This script will prefix every commit msg with the branch name in brackets,
# except if we are on non working branch like develop or master.
# The branch name pattern is : {category}/{issue-nb}_{work-description}

if [ -z "$BRANCHES_TO_SKIP" ]; then
  BRANCHES_TO_SKIP=(master develop)
fi

# Find current branch name
BRANCH_NAME=$(git symbolic-ref --short HEAD)
# Remove category before slash (included)
BRANCH_NAME="${BRANCH_NAME##*/}"
# Remove description after first underscore (included)
BRANCH_NAME="${BRANCH_NAME%_*}"


# Check if the branch is excluded
BRANCH_EXCLUDED=$(printf "%s\n" "${BRANCHES_TO_SKIP[@]}" | grep -c "^$BRANCH_NAME$")
BRANCH_IN_COMMIT=$(grep -c "\[$BRANCH_NAME\]" $1)

# Check if branch name is not null, if the current branch is not an excluded one, and if the branch name is already in the commit msg
if [ -n "$BRANCH_NAME" ] && ! [[ $BRANCH_EXCLUDED -eq 1 ]] && ! [[ $BRANCH_IN_COMMIT -ge 1 ]]; then 
  # Add brackets around branch name and Prefix passed msg with it
  sed -i.bak -e "1s/^/[$BRANCH_NAME] /" $1
fi
ylerjen
  • 141
  • 5

0 Answers0