summaryrefslogtreecommitdiff
path: root/add-patch.c
diff options
context:
space:
mode:
Diffstat (limited to 'add-patch.c')
-rw-r--r--add-patch.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/add-patch.c b/add-patch.c
index 33ecd8398a..8d770d203f 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1,5 +1,11 @@
#include "cache.h"
#include "add-interactive.h"
+#include "advice.h"
+#include "alloc.h"
+#include "editor.h"
+#include "environment.h"
+#include "gettext.h"
+#include "object-name.h"
#include "strbuf.h"
#include "run-command.h"
#include "strvec.h"
@@ -414,7 +420,7 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
strvec_push(&args,
/* could be on an unborn branch */
!strcmp("HEAD", s->revision) &&
- get_oid("HEAD", &oid) ?
+ repo_get_oid(the_repository, "HEAD", &oid) ?
empty_tree_oid_hex() : s->revision);
}
color_arg_index = args.nr;
@@ -483,7 +489,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)
if (!eol)
eol = pend;
- if (starts_with(p, "diff ")) {
+ if (starts_with(p, "diff ") ||
+ starts_with(p, "* Unmerged path ")) {
complete_file(marker, hunk);
ALLOC_GROW_BY(s->file_diff, s->file_diff_nr, 1,
file_diff_alloc);
@@ -1750,7 +1757,8 @@ int run_add_p(struct repository *r, enum add_p_mode mode,
s.mode = &patch_mode_add;
s.revision = revision;
- if (discard_index(r->index) < 0 || repo_read_index(r) < 0 ||
+ discard_index(r->index);
+ if (repo_read_index(r) < 0 ||
(!s.mode->index_only &&
repo_refresh_and_write_index(r, REFRESH_QUIET, 0, 1,
NULL, NULL, NULL) < 0) ||