commit 54db089b71fc154b340191c1261792611b93eaee
parent fc2e47766512414f787e21e912ac05dfdc88bd74
Author: vx-clutch <[email protected]>
Date: Sat, 22 Nov 2025 10:22:26 -0500
add weak git integration
Diffstat:
9 files changed, 58 insertions(+), 10 deletions(-)
diff --git a/edef.h b/edef.h
@@ -1,14 +1,18 @@
/* edef.h
- *
- * Program definitions
+ *
+ * Global variable definition
*
* written by vx-clutch
*/
+
#ifndef EDEF_H_
#define EDEF_H_
-enum { SINGLE = 1, FULL = 2 };
+/* Initialized global external declarations. */
+
+extern int git;
-#define NPAT 4096 /* number of bytes for path buffer */
+/* Other constants declarations */
+enum { SINGLE, FULL };
#endif /* EDEF_H_ */
diff --git a/estruct.h b/estruct.h
@@ -9,4 +9,10 @@
#define QAUTHOR 0 /* Force use the default author option */
#define AUTHOR "fSD" /* Default author */
+#define DEFAULT_GIT 0 /* Default git state */
+
+/* Internal constants */
+
+#define NPAT 128
+
#endif /* ESTRUCT_H_ */
diff --git a/file.c b/file.c
@@ -1,8 +1,7 @@
/* file.c
*
* The routines in this file handle the reading, writing
- * and lookup of disk files. All of details about the
- * reading and writing of the disk are in "fileio.c".
+ * and lookup of disk files.
*
* written by vx-clutch
*/
@@ -17,7 +16,7 @@
#include <unistd.h>
#include "file.h"
-#include "edef.h"
+#include "estruct.h"
int ffwrite(char *path, char *fmt, ...) {
FILE *f;
diff --git a/full.c b/full.c
@@ -10,6 +10,7 @@
#include "file.h"
#include "full.h"
#include "usage.h"
+#include "git.h"
int full_project_init_and_cd(char *src)
{
@@ -72,5 +73,7 @@ more accurate attributions, if you desire.\n\
\n\
LATE MODIFIED DATE", src, src);
+ ginit(); /* initialize a git repository */
+
return 0;
}
diff --git a/git.c b/git.c
@@ -0,0 +1,17 @@
+/* git.c
+ *
+ * Routines for initilizing a git repository
+ *
+ * written by vx-clutch
+ */
+
+#include "git.h"
+#include "edef.h"
+#include <stdlib.h>
+
+int ginit()
+{
+ if (git) return 0;
+ system("git init --quiet");
+ return 0;
+}
diff --git a/git.h b/git.h
@@ -0,0 +1,6 @@
+#ifndef GIT_H_
+#define GIT_H_
+
+int ginit();
+
+#endif /* GIT_H_ */
diff --git a/globals.c b/globals.c
@@ -0,0 +1,6 @@
+#include "estruct.h"
+#include "edef.h"
+
+/* initialized global definitions */
+
+int git = DEFAULT_GIT;
diff --git a/main.c b/main.c
@@ -17,6 +17,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
#include "edef.h"
#include "proj.h"
@@ -28,8 +32,8 @@ void usage(int status) {
printf("Usage: %s filename\n", PROGRAM_NAME);
printf(" or: %s [options]\n\n", PROGRAM_NAME);
fputs(" -s enable shell creation mode\n", stdout);
- fputs(" -S enable shell creation mode as a full project\n",
- stdout);
+ fputs(" -S enable shell creation mode as a full project\n", stdout);
+ fputs(" --git initialize a git repository\n", stdout);
fputs(" --help display this help and exit\n", stdout);
fputs(" --version output version information and exit\n", stdout);
@@ -59,6 +63,8 @@ int main(int argc, char **argv) {
shell_mode = SINGLE;
else if (argv[carg][1] == 'S')
shell_mode = FULL;
+ else if (strcmp(argv[carg], "--git"))
+ git = 1;
else
die("unknown option");
} else
diff --git a/shell.c b/shell.c
@@ -23,8 +23,9 @@ int makeshell(char *src, int complexity) {
if (complexity == SINGLE)
single_init(src);
- else if (complexity == FULL)
+ else if (complexity == FULL) {
full_project_init_and_cd(src);
+ }
else
die("invalid state! shell.c:%d", __LINE__);