* [9front] [PATCH] git/query: leave range commits in topological order
@ 2022-01-23 0:39 Michael Forney
2022-01-23 15:17 ` ori
0 siblings, 1 reply; 3+ messages in thread
From: Michael Forney @ 2022-01-23 0:39 UTC (permalink / raw)
To: 9front
This prevents commits from getting reordered incorrectly during rebase
or export.
---
diff 108d74cb0a8d27e82550d2772ae64fd7748e151d bb59fa1f40b5e5756639480fc08e0f33c7e19019
--- a/sys/src/cmd/git/ref.c Fri Jan 7 02:37:02 2022
+++ b/sys/src/cmd/git/ref.c Sat Jan 22 16:39:21 2022
@@ -51,26 +51,6 @@
ev->p++;
}
-int
-objdatecmp(void *pa, void *pb)
-{
- Object *a, *b;
- int r;
-
- a = readobject((*(Object**)pa)->hash);
- b = readobject((*(Object**)pb)->hash);
- assert(a->type == GCommit && b->type == GCommit);
- if(a->commit->mtime == b->commit->mtime)
- r = 0;
- else if(a->commit->mtime < b->commit->mtime)
- r = -1;
- else
- r = 1;
- unref(a);
- unref(b);
- return r;
-}
-
void
push(Eval *ev, Object *o)
{
@@ -406,7 +386,7 @@
range(Eval *ev)
{
Object *a, *b, *p, *q, **all;
- int nall, *idx, mark;
+ int nall, *idx;
Objset keep, skip;
b = pop(ev);
@@ -424,7 +404,6 @@
all = nil;
idx = nil;
nall = 0;
- mark = ev->nstk;
osinit(&keep);
osinit(&skip);
osadd(&keep, a);
@@ -459,7 +438,6 @@
nall++;
}
free(all);
- qsort(ev->stk + mark, ev->nstk - mark, sizeof(Object*), objdatecmp);
return 0;
error:
free(all);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] [PATCH] git/query: leave range commits in topological order
2022-01-23 0:39 [9front] [PATCH] git/query: leave range commits in topological order Michael Forney
@ 2022-01-23 15:17 ` ori
2022-01-23 15:29 ` hiro
0 siblings, 1 reply; 3+ messages in thread
From: ori @ 2022-01-23 15:17 UTC (permalink / raw)
To: 9front
Quoth Michael Forney <mforney@mforney.org>:
>
> This prevents commits from getting reordered incorrectly during rebase
> or export.
> ---
> diff 108d74cb0a8d27e82550d2772ae64fd7748e151d bb59fa1f40b5e5756639480fc08e0f33c7e19019
> --- a/sys/src/cmd/git/ref.c Fri Jan 7 02:37:02 2022
> +++ b/sys/src/cmd/git/ref.c Sat Jan 22 16:39:21 2022
> @@ -51,26 +51,6 @@
> ev->p++;
> }
>
> -int
> -objdatecmp(void *pa, void *pb)
> -{
> - Object *a, *b;
> - int r;
> -
> - a = readobject((*(Object**)pa)->hash);
> - b = readobject((*(Object**)pb)->hash);
> - assert(a->type == GCommit && b->type == GCommit);
> - if(a->commit->mtime == b->commit->mtime)
> - r = 0;
> - else if(a->commit->mtime < b->commit->mtime)
> - r = -1;
> - else
> - r = 1;
> - unref(a);
> - unref(b);
> - return r;
> -}
> -
> void
> push(Eval *ev, Object *o)
> {
> @@ -406,7 +386,7 @@
> range(Eval *ev)
> {
> Object *a, *b, *p, *q, **all;
> - int nall, *idx, mark;
> + int nall, *idx;
> Objset keep, skip;
>
> b = pop(ev);
> @@ -424,7 +404,6 @@
> all = nil;
> idx = nil;
> nall = 0;
> - mark = ev->nstk;
> osinit(&keep);
> osinit(&skip);
> osadd(&keep, a);
> @@ -459,7 +438,6 @@
> nall++;
> }
> free(all);
> - qsort(ev->stk + mark, ev->nstk - mark, sizeof(Object*), objdatecmp);
> return 0;
> error:
> free(all);
>
looks good; if someone really wants sorted commits,
the right way to go would be to add a 'sort' operator
to the query mini-language. something like:
git/query a..b @sort
rather than baking it into the range itself.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] [PATCH] git/query: leave range commits in topological order
2022-01-23 15:17 ` ori
@ 2022-01-23 15:29 ` hiro
0 siblings, 0 replies; 3+ messages in thread
From: hiro @ 2022-01-23 15:29 UTC (permalink / raw)
To: 9front
calling it a language enlightened me
On 1/23/22, ori@eigenstate.org <ori@eigenstate.org> wrote:
> Quoth Michael Forney <mforney@mforney.org>:
>>
>> This prevents commits from getting reordered incorrectly during rebase
>> or export.
>> ---
>> diff 108d74cb0a8d27e82550d2772ae64fd7748e151d
>> bb59fa1f40b5e5756639480fc08e0f33c7e19019
>> --- a/sys/src/cmd/git/ref.c Fri Jan 7 02:37:02 2022
>> +++ b/sys/src/cmd/git/ref.c Sat Jan 22 16:39:21 2022
>> @@ -51,26 +51,6 @@
>> ev->p++;
>> }
>>
>> -int
>> -objdatecmp(void *pa, void *pb)
>> -{
>> - Object *a, *b;
>> - int r;
>> -
>> - a = readobject((*(Object**)pa)->hash);
>> - b = readobject((*(Object**)pb)->hash);
>> - assert(a->type == GCommit && b->type == GCommit);
>> - if(a->commit->mtime == b->commit->mtime)
>> - r = 0;
>> - else if(a->commit->mtime < b->commit->mtime)
>> - r = -1;
>> - else
>> - r = 1;
>> - unref(a);
>> - unref(b);
>> - return r;
>> -}
>> -
>> void
>> push(Eval *ev, Object *o)
>> {
>> @@ -406,7 +386,7 @@
>> range(Eval *ev)
>> {
>> Object *a, *b, *p, *q, **all;
>> - int nall, *idx, mark;
>> + int nall, *idx;
>> Objset keep, skip;
>>
>> b = pop(ev);
>> @@ -424,7 +404,6 @@
>> all = nil;
>> idx = nil;
>> nall = 0;
>> - mark = ev->nstk;
>> osinit(&keep);
>> osinit(&skip);
>> osadd(&keep, a);
>> @@ -459,7 +438,6 @@
>> nall++;
>> }
>> free(all);
>> - qsort(ev->stk + mark, ev->nstk - mark, sizeof(Object*), objdatecmp);
>> return 0;
>> error:
>> free(all);
>>
>
> looks good; if someone really wants sorted commits,
> the right way to go would be to add a 'sort' operator
> to the query mini-language. something like:
>
> git/query a..b @sort
>
> rather than baking it into the range itself.
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-01-23 19:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-23 0:39 [9front] [PATCH] git/query: leave range commits in topological order Michael Forney
2022-01-23 15:17 ` ori
2022-01-23 15:29 ` hiro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).