mhagger / git-imerge

Incremental merge for git
GNU General Public License v2.0
2.68k stars 126 forks source link

Identifying list of conflicting commits #177

Closed ericcurtin closed 3 years ago

ericcurtin commented 3 years ago

I would like to use imerge (or git) just to identify the list of conflicting commits (excluding any common ancestors of course) without actually performing any merging. Is this possible with imerge?

ericcurtin commented 3 years ago

Never mind, I wrote a script to do it:

#!/bin/bash

git fetch > /dev/null 2>&1 &

ls_files=$(git diff --name-only --diff-filter=U)
np=$(nproc)

if [ -z "$ls_files" ]; then
  echo "No conflicts here!"
  exit 0
fi

task() {
  for i in $(git blame $i | awk '/<<<</,/>>>>/' | awk '{print $1}' | grep -v 0000 | sort | uniq); do
    if [ $(git branch -r --contains $i | grep -c "$1$\|$2$") -lt 2 ]; then
      git log --no-walk --pretty=format:"%h%x09%an%x09%ad%x09%s" $i | cut -c 1-80
    fi
  done
}

for i in $(echo $ls_files); do
  # Max 16 processes at any given time
  while [ $(jobs -r -p | wc -l) -gt $np ]; do
    sleep 1
  done

  task $1 $2&
done

wait

Sorry for bothering you, you have to pass in the two branches to this