From: Scott Bronson <bronson@rinspin.com>
To: git@vger.kernel.org
Subject: Interpreting git merge failures
Date: Thu, 7 Jul 2011 11:45:57 -0700 [thread overview]
Message-ID: <CAKmUPx5Qt2K+7F+BsW3WTmRjodBSrteuyG8p9oRHZuhApTu4+g@mail.gmail.com> (raw)
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
next reply other threads:[~2011-07-07 18:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-07 18:45 Scott Bronson [this message]
2011-07-12 6:33 ` Interpreting git merge failures Jeff King
2011-07-12 16:40 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKmUPx5Qt2K+7F+BsW3WTmRjodBSrteuyG8p9oRHZuhApTu4+g@mail.gmail.com \
--to=bronson@rinspin.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).