Interpreting git merge failures

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

 



What is the best way to determine why a git merge failed?
I'm writing a script that needs to do different things depending
on what went wrong.

Right now I'm parsing error messages.  It's obviously a bad
idea and prone to breakage but it does work.   Example:

    `git fetch origin #{tag || :master}`
    output = `git merge --ff-only FETCH_HEAD 2>&1`

    # warning, bad idea:
    if output =~ /Not possible to fast-forward/
      log "has different ancestry from upstream, removing and re-cloning."
      remove_and_reclone
    elsif msg =~ /You have unstaged changes/ ||
          msg =~ /Your local changes [a-z ]* would be overwritten/ ||
          msg =~ /commit your changes or stash them before you can merge/
      log "has unsaved changes, invalid doc/tags file in upstream repo?"
      work_around_tagsfile
    elsif msg =~ /untracked working tree files would be overwritten/
      log "has conflicting file, removing and re-cloning."
      abort  # don't blow away unknown file
    else
      log msg
      abort
    end

There's got to be a better way!  I could special-case each check
beforehand using git ls-files and friends but that seems almost as
ugly...  Hoping a smarter solution exists.

This is for https://github.com/bronson/vim-update-bundles

Thanks!

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