Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-08-03 01:30:37 +0300
committerJunio C Hamano <gitster@pobox.com>2018-08-03 01:30:38 +0300
commit218608cacd478bfdf4bfe40ed7d0b11af94a6a60 (patch)
treec30026405afe95aa26fd0003387e00afe05f17d5 /wt-status.c
parentffc6fa0e396238de3a30623912980263b4f283ab (diff)
parent3506dc944558b7d88544408b312e795458383195 (diff)
Merge branch 'jk/has-uncommitted-changes-fix'
"git pull --rebase" on a corrupt HEAD caused a segfault. In general we substitute an empty tree object when running the in-core equivalent of the diff-index command, and the codepath has been corrected to do so as well to fix this issue. * jk/has-uncommitted-changes-fix: has_uncommitted_changes(): fall back to empty tree
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/wt-status.c b/wt-status.c
index 8827a256d3..fadbed0de9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -2340,7 +2340,17 @@ int has_uncommitted_changes(int ignore_submodules)
if (ignore_submodules)
rev_info.diffopt.flags.ignore_submodules = 1;
rev_info.diffopt.flags.quick = 1;
+
add_head_to_pending(&rev_info);
+ if (!rev_info.pending.nr) {
+ /*
+ * We have no head (or it's corrupt); use the empty tree,
+ * which will complain if the index is non-empty.
+ */
+ struct tree *tree = lookup_tree(the_hash_algo->empty_tree);
+ add_pending_object(&rev_info, &tree->object, "");
+ }
+
diff_setup_done(&rev_info.diffopt);
result = run_diff_index(&rev_info, 1);
return diff_result_code(&rev_info.diffopt, result);