git/log: handle absolute paths gracefully.
strip off the repo prefix if the path given is absolute, and then look up as though it was rooted in the repo.
This commit is contained in:
parent
a87a4b763f
commit
eeb0f9a9da
1 changed files with 11 additions and 5 deletions
|
@ -282,7 +282,7 @@ void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char path[1024], repo[1024], *p, *r;
|
char path[1024], repo[1024], *p, *r;
|
||||||
int i;
|
int i, nrepo;
|
||||||
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
case 'e':
|
case 'e':
|
||||||
|
@ -301,15 +301,21 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if(findrepo(repo, sizeof(repo)) == -1)
|
if(findrepo(repo, sizeof(repo)) == -1)
|
||||||
sysfatal("find root: %r");
|
sysfatal("find root: %r");
|
||||||
|
nrepo = strlen(repo);
|
||||||
if(argc != 0){
|
if(argc != 0){
|
||||||
if(getwd(path, sizeof(path)) == nil)
|
if(getwd(path, sizeof(path)) == nil)
|
||||||
sysfatal("getwd: %r");
|
sysfatal("getwd: %r");
|
||||||
if(strlen(path) < strlen(repo))
|
if(strncmp(path, repo, nrepo) != 0)
|
||||||
sysfatal("path changed");
|
sysfatal("path shifted??");
|
||||||
p = path + strlen(repo);
|
p = path + nrepo;
|
||||||
pathfilt = emalloc(sizeof(Pfilt));
|
pathfilt = emalloc(sizeof(Pfilt));
|
||||||
for(i = 0; i < argc; i++){
|
for(i = 0; i < argc; i++){
|
||||||
r = smprint("./%s/%s", p, argv[i]);
|
if(*argv[i] == '/'){
|
||||||
|
if(strncmp(argv[i], repo, nrepo) != 0)
|
||||||
|
continue;
|
||||||
|
r = smprint("./%s", argv[i]+nrepo);
|
||||||
|
}else
|
||||||
|
r = smprint("./%s/%s", p, argv[i]);
|
||||||
cleanname(r);
|
cleanname(r);
|
||||||
filteradd(pathfilt, r);
|
filteradd(pathfilt, r);
|
||||||
free(r);
|
free(r);
|
||||||
|
|
Loading…
Reference in a new issue