Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/diffcore-rotate.c # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / diffcore-rotate.c` 47 lines ยท 1064 bytes Raw Blame History 1 /* 2 * Copyright (C) 2021, Google LLC. 3 * Based on diffcore-order.c, which is Copyright (C) 2005, Junio C Hamano 4 */ 5 6 #include "git-compat-util.h" 7 #include "gettext.h" 8 #include "diff.h" 9 #include "diffcore.h" 10 11 void diffcore_rotate(struct diff_options *opt) 12 { 13 struct diff_queue_struct *q = &diff_queued_diff; 14 struct diff_queue_struct outq = DIFF_QUEUE_INIT; 15 int rotate_to, i; 16 17 if (!q->nr) 18 return; 19 20 for (i = 0; i < q->nr; i++) { 21 int cmp = strcmp(opt->rotate_to, q->queue[i]->two->path); 22 if (!cmp) 23 break; /* exact match */ 24 if (!opt->rotate_to_strict && cmp < 0) 25 break; /* q->queue[i] is now past the target pathname */ 26 } 27 28 if (q->nr <= i) { 29 /* we did not find the specified path */ 30 if (opt->rotate_to_strict) 31 die(_("No such path '%s' in the diff"), opt->rotate_to); 32 return; 33 } 34 35 rotate_to = i; 36 37 for (i = rotate_to; i < q->nr; i++) 38 diff_q(&outq, q->queue[i]); 39 for (i = 0; i < rotate_to; i++) { 40 if (opt->skip_instead_of_rotate) 41 diff_free_filepair(q->queue[i]); 42 else 43 diff_q(&outq, q->queue[i]); 44 } 45 free(q->queue); 46 *q = outq; 47 }