show a summary of conflicts and related problems after updating/merging files ok millert@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530
diff --git a/got/got.c b/got/got.c
index d37d125..a6905d4 100644
--- a/got/got.c
+++ b/got/got.c
@@ -2495,6 +2495,29 @@ done:
return error;
}
+struct got_update_progress_arg {
+ int did_something;
+ int conflicts;
+ int obstructed;
+ int not_updated;
+};
+
+void
+print_update_progress_stats(struct got_update_progress_arg *upa)
+{
+ if (!upa->did_something)
+ return;
+
+ if (upa->conflicts > 0)
+ printf("Files with new merge conflicts: %d\n", upa->conflicts);
+ if (upa->obstructed > 0)
+ printf("File paths obstructed by a non-regular file: %d\n",
+ upa->obstructed);
+ if (upa->not_updated > 0)
+ printf("Files not updated because of existing merge "
+ "conflicts: %d\n", upa->not_updated);
+}
+
__dead static void
usage_update(void)
{
@@ -2506,18 +2529,25 @@ usage_update(void)
static const struct got_error *
update_progress(void *arg, unsigned char status, const char *path)
{
- int *did_something = arg;
+ struct got_update_progress_arg *upa = arg;
if (status == GOT_STATUS_EXISTS ||
status == GOT_STATUS_BASE_REF_ERR)
return NULL;
- *did_something = 1;
+ upa->did_something = 1;
/* Base commit bump happens silently. */
if (status == GOT_STATUS_BUMP_BASE)
return NULL;
+ if (status == GOT_STATUS_CONFLICT)
+ upa->conflicts++;
+ if (status == GOT_STATUS_OBSTRUCTED)
+ upa->obstructed++;
+ if (status == GOT_STATUS_CANNOT_UPDATE)
+ upa->not_updated++;
+
while (path[0] == '/')
path++;
printf("%c %s\n", status, path);
@@ -2649,7 +2679,8 @@ cmd_update(int argc, char *argv[])
struct got_reference *head_ref = NULL;
struct got_pathlist_head paths;
struct got_pathlist_entry *pe;
- int ch, did_something = 0;
+ int ch;
+ struct got_update_progress_arg upa;
TAILQ_INIT(&paths);
@@ -2776,15 +2807,17 @@ cmd_update(int argc, char *argv[])
goto done;
}
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_checkout_files(worktree, &paths, repo,
- update_progress, &did_something, check_cancelled, NULL);
+ update_progress, &upa, check_cancelled, NULL);
if (error != NULL)
goto done;
- if (did_something)
+ if (upa.did_something)
printf("Updated to commit %s\n", commit_id_str);
else
printf("Already up-to-date\n");
+ print_update_progress_stats(&upa);
done:
free(worktree_path);
TAILQ_FOREACH(pe, &paths, entry)
@@ -5027,7 +5060,7 @@ cmd_branch(int argc, char *argv[])
if (error)
goto done;
if (worktree && do_update) {
- int did_something = 0;
+ struct got_update_progress_arg upa;
char *branch_refname = NULL;
error = got_object_id_str(&commit_id_str, commit_id);
@@ -5054,13 +5087,15 @@ cmd_branch(int argc, char *argv[])
commit_id);
if (error)
goto done;
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_checkout_files(worktree, &paths,
- repo, update_progress, &did_something,
- check_cancelled, NULL);
+ repo, update_progress, &upa, check_cancelled,
+ NULL);
if (error)
goto done;
- if (did_something)
+ if (upa.did_something)
printf("Updated to commit %s\n", commit_id_str);
+ print_update_progress_stats(&upa);
}
}
done:
@@ -6324,7 +6359,8 @@ cmd_cherrypick(int argc, char *argv[])
struct got_commit_object *commit = NULL;
struct got_object_qid *pid;
struct got_reference *head_ref = NULL;
- int ch, did_something = 0;
+ int ch;
+ struct got_update_progress_arg upa;
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
@@ -6405,14 +6441,16 @@ cmd_cherrypick(int argc, char *argv[])
if (error)
goto done;
pid = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_merge_files(worktree, pid ? pid->id : NULL,
- commit_id, repo, update_progress, &did_something, check_cancelled,
+ commit_id, repo, update_progress, &upa, check_cancelled,
NULL);
if (error != NULL)
goto done;
- if (did_something)
+ if (upa.did_something)
printf("Merged commit %s\n", commit_id_str);
+ print_update_progress_stats(&upa);
done:
if (commit)
got_object_commit_close(commit);
@@ -6444,7 +6482,8 @@ cmd_backout(int argc, char *argv[])
struct got_commit_object *commit = NULL;
struct got_object_qid *pid;
struct got_reference *head_ref = NULL;
- int ch, did_something = 0;
+ int ch;
+ struct got_update_progress_arg upa;
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
@@ -6523,13 +6562,15 @@ cmd_backout(int argc, char *argv[])
goto done;
}
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_merge_files(worktree, commit_id, pid->id, repo,
- update_progress, &did_something, check_cancelled, NULL);
+ update_progress, &upa, check_cancelled, NULL);
if (error != NULL)
goto done;
- if (did_something)
+ if (upa.did_something)
printf("Backed out commit %s\n", commit_id_str);
+ print_update_progress_stats(&upa);
done:
if (commit)
got_object_commit_close(commit);
@@ -6657,22 +6698,6 @@ done:
}
static const struct got_error *
-rebase_progress(void *arg, unsigned char status, const char *path)
-{
- unsigned char *rebase_status = arg;
-
- while (path[0] == '/')
- path++;
- printf("%c %s\n", status, path);
-
- if (*rebase_status == GOT_STATUS_CONFLICT)
- return NULL;
- if (status == GOT_STATUS_CONFLICT || status == GOT_STATUS_MERGE)
- *rebase_status = status;
- return NULL;
-}
-
-static const struct got_error *
rebase_complete(struct got_worktree *worktree, struct got_fileindex *fileindex,
struct got_reference *branch, struct got_reference *new_base_branch,
struct got_reference *tmp_branch, struct got_repository *repo)
@@ -6923,7 +6948,7 @@ cmd_rebase(int argc, char *argv[])
goto done;
if (abort_rebase) {
- int did_something;
+ struct got_update_progress_arg upa;
if (!rebase_in_progress) {
error = got_error(GOT_ERR_NOT_REBASING);
goto done;
@@ -6935,11 +6960,13 @@ cmd_rebase(int argc, char *argv[])
goto done;
printf("Switching work tree to %s\n",
got_ref_get_symref_target(new_base_branch));
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_rebase_abort(worktree, fileindex, repo,
- new_base_branch, update_progress, &did_something);
+ new_base_branch, update_progress, &upa);
if (error)
goto done;
printf("Rebase of %s aborted\n", got_ref_get_name(branch));
+ print_update_progress_stats(&upa);
goto done; /* nothing else to do */
}
@@ -7016,14 +7043,16 @@ cmd_rebase(int argc, char *argv[])
pid = SIMPLEQ_FIRST(parent_ids);
if (pid == NULL) {
if (!continue_rebase) {
- int did_something;
+ struct got_update_progress_arg upa;
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_rebase_abort(worktree, fileindex,
- repo, new_base_branch, update_progress,
- &did_something);
+ repo, new_base_branch, update_progress, &upa);
if (error)
goto done;
printf("Rebase of %s aborted\n",
got_ref_get_name(branch));
+ print_update_progress_stats(&upa);
+
}
error = got_error(GOT_ERR_EMPTY_REBASE);
goto done;
@@ -7062,16 +7091,23 @@ cmd_rebase(int argc, char *argv[])
pid = NULL;
SIMPLEQ_FOREACH(qid, &commits, entry) {
+ struct got_update_progress_arg upa;
+
commit_id = qid->id;
parent_id = pid ? pid->id : yca_id;
pid = qid;
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_rebase_merge_files(&merged_paths,
worktree, fileindex, parent_id, commit_id, repo,
- rebase_progress, &rebase_status, check_cancelled, NULL);
+ update_progress, &upa, check_cancelled, NULL);
if (error)
goto done;
+ print_update_progress_stats(&upa);
+ if (upa.conflicts > 0)
+ rebase_status = GOT_STATUS_CONFLICT;
+
if (rebase_status == GOT_STATUS_CONFLICT) {
error = show_rebase_merge_conflict(qid->id, repo);
if (error)
@@ -7939,7 +7975,8 @@ cmd_histedit(int argc, char *argv[])
struct got_object_id *base_commit_id = NULL;
struct got_object_id *head_commit_id = NULL;
struct got_commit_object *commit = NULL;
- int ch, rebase_in_progress = 0, did_something;
+ int ch, rebase_in_progress = 0;
+ struct got_update_progress_arg upa;
int edit_in_progress = 0, abort_edit = 0, continue_edit = 0;
int edit_logmsg_only = 0;
const char *edit_script_path = NULL;
@@ -7954,6 +7991,7 @@ cmd_histedit(int argc, char *argv[])
SIMPLEQ_INIT(&commits);
TAILQ_INIT(&histedit_cmds);
TAILQ_INIT(&merged_paths);
+ memset(&upa, 0, sizeof(upa));
while ((ch = getopt(argc, argv, "acF:m")) != -1) {
switch (ch) {
@@ -8049,11 +8087,12 @@ cmd_histedit(int argc, char *argv[])
printf("Switching work tree to %s\n",
got_ref_get_symref_target(branch));
error = got_worktree_histedit_abort(worktree, fileindex, repo,
- branch, base_commit_id, update_progress, &did_something);
+ branch, base_commit_id, update_progress, &upa);
if (error)
goto done;
printf("Histedit of %s aborted\n",
got_ref_get_symref_target(branch));
+ print_update_progress_stats(&upa);
goto done; /* nothing else to do */
} else if (abort_edit) {
error = got_error(GOT_ERR_NOT_HISTEDIT);
@@ -8163,7 +8202,8 @@ cmd_histedit(int argc, char *argv[])
if (error) {
got_worktree_histedit_abort(worktree, fileindex,
repo, branch, base_commit_id,
- update_progress, &did_something);
+ update_progress, &upa);
+ print_update_progress_stats(&upa);
goto done;
}
} else {
@@ -8176,7 +8216,8 @@ cmd_histedit(int argc, char *argv[])
if (error) {
got_worktree_histedit_abort(worktree, fileindex,
repo, branch, base_commit_id,
- update_progress, &did_something);
+ update_progress, &upa);
+ print_update_progress_stats(&upa);
goto done;
}
@@ -8187,7 +8228,8 @@ cmd_histedit(int argc, char *argv[])
if (error) {
got_worktree_histedit_abort(worktree, fileindex,
repo, branch, base_commit_id,
- update_progress, &did_something);
+ update_progress, &upa);
+ print_update_progress_stats(&upa);
goto done;
}
@@ -8265,12 +8307,16 @@ cmd_histedit(int argc, char *argv[])
error = got_worktree_histedit_merge_files(&merged_paths,
worktree, fileindex, pid->id, hle->commit_id, repo,
- rebase_progress, &rebase_status, check_cancelled, NULL);
+ update_progress, &upa, check_cancelled, NULL);
if (error)
goto done;
got_object_commit_close(commit);
commit = NULL;
+ print_update_progress_stats(&upa);
+ if (upa.conflicts > 0)
+ rebase_status = GOT_STATUS_CONFLICT;
+
if (rebase_status == GOT_STATUS_CONFLICT) {
error = show_rebase_merge_conflict(hle->commit_id,
repo);
@@ -8354,7 +8400,8 @@ cmd_integrate(int argc, char *argv[])
struct got_reference *branch_ref = NULL, *base_branch_ref = NULL;
struct got_fileindex *fileindex = NULL;
struct got_object_id *commit_id = NULL, *base_commit_id = NULL;
- int ch, did_something = 0;
+ int ch;
+ struct got_update_progress_arg upa;
while ((ch = getopt(argc, argv, "")) != -1) {
switch (ch) {
@@ -8453,13 +8500,15 @@ cmd_integrate(int argc, char *argv[])
goto done;
}
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_integrate_continue(worktree, fileindex, repo,
- branch_ref, base_branch_ref, update_progress, &did_something,
+ branch_ref, base_branch_ref, update_progress, &upa,
check_cancelled, NULL);
if (error)
goto done;
printf("Integrated %s into %s\n", refname, base_refname);
+ print_update_progress_stats(&upa);
done:
if (repo)
got_repo_close(repo);
@@ -8634,7 +8683,8 @@ cmd_unstage(int argc, char *argv[])
char *cwd = NULL;
struct got_pathlist_head paths;
struct got_pathlist_entry *pe;
- int ch, did_something = 0, pflag = 0;
+ int ch, pflag = 0;
+ struct got_update_progress_arg upa;
FILE *patch_script_file = NULL;
const char *patch_script_path = NULL;
struct choose_patch_arg cpa;
@@ -8704,8 +8754,11 @@ cmd_unstage(int argc, char *argv[])
cpa.patch_script_file = patch_script_file;
cpa.action = "unstage";
+ memset(&upa, 0, sizeof(upa));
error = got_worktree_unstage(worktree, &paths, update_progress,
- &did_something, pflag ? choose_patch : NULL, &cpa, repo);
+ &upa, pflag ? choose_patch : NULL, &cpa, repo);
+ if (!error)
+ print_update_progress_stats(&upa);
done:
if (patch_script_file && fclose(patch_script_file) == EOF &&
error == NULL)
diff --git a/regress/cmdline/commit.sh b/regress/cmdline/commit.sh
index 34da527..aafe145 100755
--- a/regress/cmdline/commit.sh
+++ b/regress/cmdline/commit.sh
@@ -302,6 +302,7 @@ function test_commit_rejects_conflicted_file {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
(cd $testroot/wt && got update > $testroot/stdout)
diff --git a/regress/cmdline/diff.sh b/regress/cmdline/diff.sh
index 5df3441..6fb2ea6 100755
--- a/regress/cmdline/diff.sh
+++ b/regress/cmdline/diff.sh
@@ -123,6 +123,7 @@ function test_diff_shows_conflict {
echo "C numbers" > $testroot/stdout.expected
echo -n "Updated to commit $head_rev" >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
(cd $testroot/wt && got update > $testroot/stdout)
diff --git a/regress/cmdline/rebase.sh b/regress/cmdline/rebase.sh
index 6b8664a..e6f7a88 100755
--- a/regress/cmdline/rebase.sh
+++ b/regress/cmdline/rebase.sh
@@ -200,6 +200,7 @@ function test_rebase_continue {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
echo -n "$short_orig_commit1 -> merge conflict" \
>> $testroot/stdout.expected
echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
@@ -335,6 +336,7 @@ function test_rebase_abort {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
echo -n "$short_orig_commit1 -> merge conflict" \
>> $testroot/stdout.expected
echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
@@ -451,6 +453,7 @@ function test_rebase_no_op_change {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
echo -n "$short_orig_commit1 -> merge conflict" \
>> $testroot/stdout.expected
echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
@@ -562,6 +565,7 @@ function test_rebase_in_progress {
2> $testroot/stderr)
echo "C alpha" > $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
echo -n "$short_orig_commit1 -> merge conflict" \
>> $testroot/stdout.expected
echo ": committing to alpha on newbranch" >> $testroot/stdout.expected
diff --git a/regress/cmdline/stage.sh b/regress/cmdline/stage.sh
index 27f30ad..a537bcb 100755
--- a/regress/cmdline/stage.sh
+++ b/regress/cmdline/stage.sh
@@ -252,6 +252,7 @@ function test_stage_conflict {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
(cd $testroot/wt && got update > $testroot/stdout)
diff --git a/regress/cmdline/status.sh b/regress/cmdline/status.sh
index c03418c..5abbce9 100755
--- a/regress/cmdline/status.sh
+++ b/regress/cmdline/status.sh
@@ -372,6 +372,7 @@ function test_status_shows_conflict {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
(cd $testroot/wt && got update > $testroot/stdout)
diff --git a/regress/cmdline/update.sh b/regress/cmdline/update.sh
index 1df7e3d..05fd291 100755
--- a/regress/cmdline/update.sh
+++ b/regress/cmdline/update.sh
@@ -666,6 +666,7 @@ function test_update_merges_file_edits {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
(cd $testroot/wt && got update > $testroot/stdout)
@@ -875,6 +876,8 @@ function test_update_conflict_wt_add_vs_repo_add {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
+
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
@@ -1354,6 +1357,7 @@ function test_update_to_another_branch {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
(cd $testroot/wt && got update -b newbranch > $testroot/stdout)
@@ -1492,6 +1496,8 @@ function test_update_bumps_base_commit_id {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files with new merge conflicts: 1" >> $testroot/stdout.expected
+
cmp -s $testroot/stdout.expected $testroot/stdout
ret="$?"
if [ "$ret" != "0" ]; then
@@ -1684,6 +1690,8 @@ function test_update_preserves_conflicted_file {
echo -n "Updated to commit " >> $testroot/stdout.expected
git_show_head $testroot/repo >> $testroot/stdout.expected
echo >> $testroot/stdout.expected
+ echo "Files not updated because of existing merge conflicts: 1" \
+ >> $testroot/stdout.expected
(cd $testroot/wt && got update > $testroot/stdout)
cmp -s $testroot/stdout.expected $testroot/stdout