shithub: plan9front

Download patch

ref: fd9679d97b0bb7b8849f84f50c708d5f733708e1
parent: 4f3437a3ccde4fadf84f6de254a141cece9ca0af
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jun 5 09:40:28 EDT 2021

git: handle absolute paths better

we were catting $gitrel onto absolute paths. stop it.

--- a/sys/src/cmd/git/add	Sat Jun  5 08:17:03 2021
+++ b/sys/src/cmd/git/add	Sat Jun  5 09:40:28 2021
@@ -16,17 +16,18 @@
 if(~ $#* 0)
 	exec aux/usage
 
+paths=`$nl{cleanname -d $gitrel $*}
 if(~ $add tracked)
-	files=`$nl{walk -f $gitrel/$*}
+	files=`$nl{walk -f $paths}
 if not
-	files=`$nl{cd .git/index9/tracked/ && walk -f $gitrel/$*}
+	files=`$nl{cd .git/index9/tracked/ && walk -f $paths}
 
 for(f in $files){
-	if(! ~ `{cleanname $f} .git/*){
+	if(! ~ `$nl{cleanname $f} .git/*){
 		addpath=.git/index9/$add/$f
 		delpath=.git/index9/$del/$f
-		mkdir -p `{basename -d $addpath}
-		mkdir -p `{basename -d $delpath}
+		mkdir -p `$nl{basename -d $addpath}
+		mkdir -p `$nl{basename -d $delpath}
 		# We don't want a matching qid, so that
 		# git/walk doesn't think this came from
 		# a checkout.
--- a/sys/src/cmd/git/commit	Sat Jun  5 08:17:03 2021
+++ b/sys/src/cmd/git/commit	Sat Jun  5 09:40:28 2021
@@ -135,7 +135,7 @@
 
 files=()
 if(! ~ $#* 0)
-	files=`$nl{git/walk -c `$nl{cleanname $gitrel/$*}}
+	files=`$nl{git/walk -c `$nl{cleanname -d $gitrel $*}}
 if(~ $status '' || ~ $#files 0 && ! test -f .git/index9/merge-parents && ~ $#revise 0)
 	die 'nothing to commit' $status
 @{
--- a/sys/src/cmd/git/diff	Sat Jun  5 08:17:03 2021
+++ b/sys/src/cmd/git/diff	Sat Jun  5 09:40:28 2021
@@ -12,7 +12,7 @@
 
 files=()
 if(! ~ $#* 0)
-	files=`{cleanname $gitrel/$*}
+	files=`{cleanname -d $gitrel $*}
 
 branch=`{git/query -p $commit}
 if(~ $summarize 1){