aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-07-31 02:40:56 +0200
committerGravatar Tom Willemsen2012-07-31 02:40:56 +0200
commit7ca2408b51b94fc2d3740cbd4bb02b368efa457c (patch)
tree786d9aea02fd6b7d9fdab149d42af77f99887658 /src
parent731fba1dc41672c214d99beca6cf46f0f0c09e3e (diff)
downloadgitto-7ca2408b51b94fc2d3740cbd4bb02b368efa457c.tar.gz
gitto-7ca2408b51b94fc2d3740cbd4bb02b368efa457c.zip
Add relative directory parsing
As of now, when using `-r' or `-R', relative directories can be used. This *does not* include locations starting with `~', those still need to be handled by your shell. Because every repo is treated as a possible relative path, and thus passed on to `realpath', the paths have become very uniform. This means that it will now only register and unregister paths that don't have a trailing `/'. This is not true during usage, so those paths still work, but they can't be removed by gitto, and adding them again will create a duplicate entry. * gitto/Makefile (objects): Add `path.scm' and `path.go'. (.PHONY): Add `all' as a phony target. (all): New target, compiles all `.go' targets. ($(filter %.go,$(objects))): Use `env' to run guild so that include paths are setup properly. * gitto/main.scm (gitto): Use new `(gitto path)' module, it contains the `realpath' function. (register-repository): (remove-repository): Always pass REPOSITORY through `realpath' and use the result. * gitto/path.scm: New file. Loads the `libguile-gitto-path' extension and exports its `realpath' function. * src/Makefile (CFLAGS): (LDFLAGS): Use `pkg-config' to gather the necessary values for guile. (libguile-gitto-path.so): New guile extension, wraps the `readline' POSIX function. * src/gitto-path.c: New file, wraps and exports the `realpath' POSIX function from `stdlib.h'.
Diffstat (limited to 'src')
-rw-r--r--src/.gitignore2
-rw-r--r--src/Makefile20
-rw-r--r--src/gitto-path.c21
3 files changed, 39 insertions, 4 deletions
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..9d22eb4
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1,2 @@
+*.o
+*.so
diff --git a/src/Makefile b/src/Makefile
index 61946a0..584374e 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,11 +1,23 @@
DESTDIR ?= /usr/local
+CFLAGS = $(shell pkg-config --cflags guile-2.0) -fPIC
+LDFLAGS = $(shell pkg-config --libs guile-2.0)
-all:
+objects = gitto-path.o
+
+all: libguile-gitto-path.so
.PHONY: install uninstall
-install: gitto
+libguile-gitto-path.so: gitto-path.o
+ $(CC) $(CFLAGS) -shared -o libguile-gitto-path.so $^
+
+install-gitto: gitto
install -Dm 755 $^ ${DESTDIR}/bin/$^
+install-libguile-gitto-path: libguile-gitto-path.so
+ install -Dm 755 $^ \
+ $(shell pkg-config guile-2.0 --variable=extensiondir)/$^
+install: install-gitto install-libguile-gitto-path
-uninstall: gitto
- rm -f ${DESTDIR}/bin/$^
+uninstall:
+ rm -f ${DESTDIR}/bin/gitto
+ rm -f $(shell pkg-config guile-2.0 --variable=extensiondir)/libguile-gitto-path.so
diff --git a/src/gitto-path.c b/src/gitto-path.c
new file mode 100644
index 0000000..ad1400a
--- /dev/null
+++ b/src/gitto-path.c
@@ -0,0 +1,21 @@
+#include <stdlib.h>
+#include <libguile.h>
+
+SCM
+realpath_wrapper(SCM str)
+{
+ char *path = scm_to_locale_string(str);
+ char *resolved_path = realpath(path, NULL);
+ SCM scm_resolved_path = scm_from_locale_string(resolved_path);
+
+ free(path);
+ free(resolved_path);
+
+ return scm_resolved_path;
+}
+
+void
+init_gitto()
+{
+ scm_c_define_gsubr("realpath", 1, 0, 0, realpath_wrapper);
+}