Download raw body.
Exclusive log end
On Sun, Mar 21, 2021 at 03:08:54PM -0400, Josh Rickmar wrote: > After seeing log -x, I realized what I really wanted was an exclusive > version of it. This allows for something like: > > $ got log -c featurebranch -X main -R -p > > to get a nice set of patches to send, instead of guessing the exact > amount with -l. > > ok? I have tried the same idea a while ago. We independently picked the same rather obvious option letter :) I put this aside because I felt it added too much clutter to the UI. But if you see a use for this then I am not against adding it. I even considered making -x exclusive by default, but decided against it. The rationale being that it is easy to ignore or filter out the unwanted trailing commit. It is harder to add a missing trailing commit back in. For reference, below is my patch. Please pick whatever you like from it and send another version with whatever combination of changes you prefer. And if you prefer your patch as-is, then that's fine, too. ----------------------------------------------- commit 9b1e46067bca6d73c5ae18df1b0c22391ddea5cc (logX, noel/logX) from: Stefan Sperling <stsp@stsp.name> date: Sun Nov 1 11:06:00 2020 UTC add -X option to 'got log' diff 7997598fec21fa0e639aad59858be44eea0822bc 0d5e96ff816555cb78b3f5ad97f82382dbe91b17 blob - 2af328db5bc16371a9ab63961a5e8cdffad041e8 blob + cb652b57152bf9798a9f91bdecf61a02e8e90fa0 --- got/got.1 +++ got/got.1 @@ -703,7 +703,7 @@ in a pattern. .It Cm st Short alias for .Cm status . -.It Cm log Oo Fl b Oc Oo Fl c Ar commit Oc Oo Fl C Ar number Oc Oo Fl l Ar N Oc Oo Fl p Oc Oo Fl P Oc Oo Fl s Ar search-pattern Oc Oo Fl r Ar repository-path Oc Oo Fl R Oc Oo Fl x Ar commit Oc Op Ar path +.It Cm log Oo Fl b Oc Oo Fl c Ar commit Oc Oo Fl C Ar number Oc Oo Fl l Ar N Oc Oo Fl p Oc Oo Fl P Oc Oo Fl s Ar search-pattern Oc Oo Fl r Ar repository-path Oc Oo Fl R Oc Oo Fl x Ar commit Oc Oo Fl X Ar commit Oc Op Ar path Display history of a repository. If a .Ar path @@ -780,10 +780,23 @@ in reverse order. .It Fl x Ar commit Stop traversing commit history as soon as the specified .Ar commit -has been traversed. +has been printed. This option has no effect if the specified .Ar commit -is never traversed. +is never encountered. +Cannot be used together with the +.Fl X +option. +.It Fl X Ar commit +Stop traversing commit history as soon as the specified +.Ar commit +is about to be printed. +This option has no effect if the specified +.Ar commit +is never encountered. +Cannot be used together with the +.Fl x +option. .El .It Cm diff Oo Fl C Ar number Oc Oo Fl r Ar repository-path Oc Oo Fl s Oc Oo Fl w Oc Op Ar object1 Ar object2 | Ar path When invoked within a work tree with less than two arguments, display blob - 40ab964e77891970bf5fa1e069607c1aa4a6c250 blob + 2a3d11fe8b23397c3bc891f7aab487575c3f821a --- got/got.c +++ got/got.c @@ -3513,7 +3513,8 @@ static const struct got_error * print_commits(struct got_object_id *root_id, struct got_object_id *end_id, struct got_repository *repo, const char *path, int show_changed_paths, int show_patch, const char *search_pattern, int diff_context, int limit, - int log_branches, int reverse_display_order, struct got_reflist_head *refs) + int log_branches, int reverse_display_order, int traverse_end_commit, + struct got_reflist_head *refs) { const struct got_error *err; struct got_commit_graph *graph; @@ -3555,6 +3556,10 @@ print_commits(struct got_object_id *root_id, struct go if (id == NULL) break; + if (!traverse_end_commit && end_id && + got_object_id_cmp(id, end_id) == 0) + break; + err = got_object_open_as_commit(&commit, repo, id); if (err) break; @@ -3654,8 +3659,8 @@ __dead static void usage_log(void) { fprintf(stderr, "usage: %s log [-b] [-c commit] [-C number] [ -l N ] " - "[-p] [-P] [-x commit] [-s search-pattern] [-r repository-path] " - "[-R] [path]\n", getprogname()); + "[-p] [-P] [-x commit] [-X commit] [-s search-pattern] " + "[-r repository-path] [-R] [path]\n", getprogname()); exit(1); } @@ -3733,7 +3738,7 @@ cmd_log(int argc, char *argv[]) char *repo_path = NULL, *path = NULL, *cwd = NULL, *in_repo_path = NULL; const char *start_commit = NULL, *end_commit = NULL; const char *search_pattern = NULL; - int diff_context = -1, ch; + int diff_context = -1, ch, traverse_end_commit = 1; int show_changed_paths = 0, show_patch = 0, limit = 0, log_branches = 0; int reverse_display_order = 0; const char *errstr; @@ -3750,7 +3755,7 @@ cmd_log(int argc, char *argv[]) limit = get_default_log_limit(); - while ((ch = getopt(argc, argv, "bpPc:C:l:r:Rs:x:")) != -1) { + while ((ch = getopt(argc, argv, "bpPc:C:l:r:Rs:x:X:")) != -1) { switch (ch) { case 'p': show_patch = 1; @@ -3789,8 +3794,18 @@ cmd_log(int argc, char *argv[]) search_pattern = optarg; break; case 'x': + if (end_commit) + err(1, "-x and -X options are mutually " + "exclusive"); end_commit = optarg; break; + case 'X': + if (end_commit) + err(1, "-x and -X options are mutually " + "exclusive"); + end_commit = optarg; + traverse_end_commit = 0; + break; default: usage_log(); /* NOTREACHED */ @@ -3911,7 +3926,8 @@ cmd_log(int argc, char *argv[]) error = print_commits(start_id, end_id, repo, path ? path : "", show_changed_paths, show_patch, search_pattern, diff_context, - limit, log_branches, reverse_display_order, &refs); + limit, log_branches, reverse_display_order, traverse_end_commit, + &refs); done: free(path); free(repo_path);
Exclusive log end