summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-06-18 10:54:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-06-18 20:17:16 (GMT)
commit4a4cf9e821f604b79817bc37b475828f3fb8b0a4 (patch)
tree99cb30bd03852e51ee2a2077c8a26815cfdc40ab
parenta9de98975479ef7d42986db63c16251c1f87ebcb (diff)
downloadgit-4a4cf9e821f604b79817bc37b475828f3fb8b0a4.zip
git-4a4cf9e821f604b79817bc37b475828f3fb8b0a4.tar.gz
git-4a4cf9e821f604b79817bc37b475828f3fb8b0a4.tar.bz2
pull: check if in unresolved merge state
Since d38a30d (Be more user-friendly when refusing to do something because of conflict., 2010-01-12), git-pull will error out with user-friendly advices if the user is in the middle of a merge or has unmerged files. Re-implement this behavior. While the "has unmerged files" case can be handled by die_resolve_conflict(), we introduce a new function die_conclude_merge() for printing a different error message for when there are no unmerged files but the merge has not been finished. Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--advice.c8
-rw-r--r--advice.h1
-rw-r--r--builtin/pull.c9
3 files changed, 18 insertions, 0 deletions
diff --git a/advice.c b/advice.c
index 575bec2..4965686 100644
--- a/advice.c
+++ b/advice.c
@@ -96,6 +96,14 @@ void NORETURN die_resolve_conflict(const char *me)
die("Exiting because of an unresolved conflict.");
}
+void NORETURN die_conclude_merge(void)
+{
+ error(_("You have not concluded your merge (MERGE_HEAD exists)."));
+ if (advice_resolve_conflict)
+ advise(_("Please, commit your changes before you can merge."));
+ die(_("Exiting because of unfinished merge."));
+}
+
void detach_advice(const char *new_name)
{
const char fmt[] =
diff --git a/advice.h b/advice.h
index 5ecc6c1..b341a55 100644
--- a/advice.h
+++ b/advice.h
@@ -24,6 +24,7 @@ __attribute__((format (printf, 1, 2)))
void advise(const char *advice, ...);
int error_resolve_conflict(const char *me);
extern void NORETURN die_resolve_conflict(const char *me);
+void NORETURN die_conclude_merge(void);
void detach_advice(const char *new_name);
#endif /* ADVICE_H */
diff --git a/builtin/pull.c b/builtin/pull.c
index b61cff5..1e688be 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -12,6 +12,7 @@
#include "run-command.h"
#include "sha1-array.h"
#include "remote.h"
+#include "dir.h"
static const char * const pull_usage[] = {
N_("git pull [options] [<repository> [<refspec>...]]"),
@@ -426,6 +427,14 @@ int cmd_pull(int argc, const char **argv, const char *prefix)
if (!opt_ff)
opt_ff = xstrdup_or_null(config_get_ff());
+ git_config(git_default_config, NULL);
+
+ if (read_cache_unmerged())
+ die_resolve_conflict("Pull");
+
+ if (file_exists(git_path("MERGE_HEAD")))
+ die_conclude_merge();
+
if (run_fetch(repo, refspecs))
return 1;