Skip to content

Commit

Permalink
Fixed init issue with git, added branch support to git-checkout and m…
Browse files Browse the repository at this point in the history
…inor optim to &lins
  • Loading branch information
bill committed Mar 10, 2024
1 parent 2b763f9 commit 3b270f9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 51 deletions.
42 changes: 30 additions & 12 deletions microemacs/macros/git.emf
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ set-variable .fhook-git-status.refresh "git-status-refresh"
set-variable .git.cnames "\b"
set-variable .git.cflags "\b"
set-variable .git.cdefs "\b"
set-variable .git.cvals "\b"
; Command 1 - Fetch
set-variable .git.cnames &lins .git.cnames -1 "Fetch"
set-variable .git.cflags &lins .git.cflags -1 "Bs*!$"
Expand Down Expand Up @@ -150,15 +149,15 @@ set-variable .git.cflags &lins .git.cflags -1 "CS*!D"
set-variable .git.cdefs &lins .git.cdefs -1 "||0|"
; Command 12 - Checkout
set-variable .git.cnames &lins .git.cnames -1 "Checkout"
set-variable .git.cflags &lins .git.cflags -1 "rS*!"
set-variable .git.cdefs &lins .git.cdefs -1 "|0|0|"
set-variable .git.cflags &lins .git.cflags -1 "Bbtr*!D"
set-variable .git.cdefs &lins .git.cdefs -1 "||0|1|0|"
; Command ?? - Blame

set-variable .git.ccount 15
set-variable .git.cstrv1 ""
set-variable .git.cstrv2 ""
set-variable .git.cstrv3 ""
set-variable .git.cstrv4 ""
set-variable .git.ccount &sub &len .git.cnames &len &rep .git.cnames "\b" ""
set-variable .git.cvals &spr "%n" &pdec .git.ccount 1 "\b"
set-variable .git.cstrv1 ""
set-variable .git.cstrv2 ""
set-variable .git.cstrv3 ""
set-variable .git.cstrv4 ""

; Add these to git-setup
set-variable .git.rep "origin"
Expand Down Expand Up @@ -413,6 +412,9 @@ set-variable .git-revision-op.lbl7 "|Head \Hto Master|\HMaster to Local|Head to
osd .osd.git-osd &inc #l2 1 "Sfh" " \HBranch: " &add #l2 1
osd .osd.git-osd &inc #l2 1 "EtxHfhz" .scheme.osd-entry 40 1 "" 1 git-osd-gstr
osd .osd.git-osd &inc #l2 1 "f" " "
!elif &seq #l1 "b"
osd .osd.git-osd &inc #l2 1 "fh" " "
osd .osd.git-osd &inc #l2 1 "Cptfx" &cat .osd.checkbox-chars "\} Create a \Hnew branch" #l0 git-osd-cbc
!elif &seq #l1 "C"
osd .osd.git-osd &inc #l2 1 "Sfh" " Co\Hmment: " &add #l2 1
@# git-osd-init-comment #l4
Expand Down Expand Up @@ -459,6 +461,9 @@ set-variable .git-revision-op.lbl7 "|Head \Hto Master|\HMaster to Local|Head to
!elif &seq #l1 "r"
osd .osd.git-osd &inc #l2 1 "fh" " "
osd .osd.git-osd &inc #l2 1 "Cptfx" &cat .osd.checkbox-chars "\} Refresh directory \Hlisting" #l0 git-osd-cbc
!elif &seq #l1 "t"
osd .osd.git-osd &inc #l2 1 "fh" " "
osd .osd.git-osd &inc #l2 1 "Cptfx" &cat .osd.checkbox-chars "\} \HTrack the branch" #l0 git-osd-cbc
!elif &seq #l1 "u"
osd .osd.git-osd &inc #l2 1 "fh" " "
osd .osd.git-osd &inc #l2 1 "Cptfx" &spr "%s\} List unintegrated changes from %s " .osd.checkbox-chars .git.rep #l0 git-osd-cbc
Expand Down Expand Up @@ -1336,12 +1341,25 @@ define-macro git-commit
define-macro git-checkout
12 git-osd
set-variable #l9 .git.values
set-variable #l2 &spr "%s checkout -- " .git.com
7 git-get-file-list 0 0 #l2
!if &len &set #l2 .git.cstrv1
!if .find-file.file-count
osd-dialog "Git - Checkout" " Checkout cannot operate on a branch and selected files at the same time! " " \HAbort "
!abort
!endif
!iif &sin " " #l2 set-variable #l2 &spr "\"%s\"" #l2
set-variable #l2 &spr "%s checkout %s%s%s" .git.com &con &lget #l9 2 "-b " "" #l2 &con &lget #l9 3 " --track" ""
7 git-get-file-list 1 0 #l2
!elif &not .find-file.file-count
osd-dialog "Git - Checkout" " Checkout requires a branch or selected files to operate on! " " \HAbort "
!abort
!else
set-variable #l2 &spr "%s checkout -- " .git.com
7 git-get-file-list 0 0 #l2
!endif
12 git-exec 3 $buffer-fname
!if &seq $buffer-fname ""
!elif &not &band $buffer-fmod 0x10000
!elif &lget #l9 2
!elif &lget #l9 4
dirlst-refresh
!endif
!emacro
Expand Down
77 changes: 38 additions & 39 deletions microemacs/src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2795,67 +2795,66 @@ gtfun(register int fnum, meUByte *fname) /* evaluate a function given name of f
case UFLINS:
case UFLSET:
{
int index=meAtoi(arg2), ii ;
meUByte cc, *s1, *s2 ;
s2 = arg1 ;
cc = *s2 ;
if(index <= 0)
int index, ii;
meUByte cc, *s1, *s2;
s2 = arg1;
cc = *s2;
if((index=meAtoi(arg2)) == 0)
s1 = s2+1;
else if(index > 0)
{
if((fnum == UFLINS) && (index < -1))
{
do
{
s1 = s2+1 ;
if((s2 = meStrchr(s1,cc)) == NULL)
{
s2 = s1-1 ;
break ;
}
*s2 = '\0' ;
if(index == -2)
ii = (meStrcmp(s1,arg3) < 0) ;
else
ii = (meStricmp(s1,arg3) < 0) ;
*s2 = cc ;
} while(ii) ;
s2 = s1-1 ;
}
else
{
if(index < 0)
s2 += meStrlen(s2)-1 ;
do {
s1 = s2+1 ;
}
if((s2 = meStrchr(s1,cc)) == NULL)
{
s2 = s1-1 ;
break ;
}
} while(--index > 0) ;
}
else
else if((fnum == UFLINS) && (index < -1))
{
do {
do
{
s1 = s2+1 ;
if((s2 = meStrchr(s1,cc)) == NULL)
{
s2 = s1-1 ;
break ;
}
} while(--index > 0) ;
*s2 = '\0' ;
if(index == -2)
ii = (meStrcmp(s1,arg3) < 0);
else
ii = (meStricmp(s1,arg3) < 0);
*s2 = cc;
} while(ii);
s2 = s1-1;
}
else
{
ii = meStrlen(s2);
s1 = s2+ii;
s2 += ii-1;
}
index = (int) (s1 - arg1) ;
index = (int) (s1 - arg1);
memcpy(evalResult,arg1,index);
ii = meStrlen(arg3);
if(ii+index < meBUF_SIZE_MAX)
{
memcpy(evalResult+index,arg3,ii);
index += ii ;
index += ii;
if(fnum == UFLINS)
s2 = s1-1 ;
ii = meStrlen(s2) ;
s2 = s1-1;
ii = meStrlen(s2);
if(ii+index < meBUF_SIZE_MAX)
{
memcpy(evalResult+index,s2,ii);
index += ii ;
index += ii;
}
}
evalResult[index] = '\0' ;
return evalResult ;
evalResult[index] = '\0';
return evalResult;
}
case UFFIND:
{
Expand Down

0 comments on commit 3b270f9

Please sign in to comment.