Compare commits

..

1 Commits

Author SHA1 Message Date
54db089b71 add weak git integration 2025-11-22 10:22:26 -05:00
9 changed files with 58 additions and 10 deletions

10
edef.h
View File

@@ -1,14 +1,18 @@
/* edef.h /* edef.h
* *
* Program definitions * Global variable definition
* *
* written by vx-clutch * written by vx-clutch
*/ */
#ifndef EDEF_H_ #ifndef EDEF_H_
#define EDEF_H_ #define EDEF_H_
enum { SINGLE = 1, FULL = 2 }; /* Initialized global external declarations. */
#define NPAT 4096 /* number of bytes for path buffer */ extern int git;
/* Other constants declarations */
enum { SINGLE, FULL };
#endif /* EDEF_H_ */ #endif /* EDEF_H_ */

View File

@@ -9,4 +9,10 @@
#define QAUTHOR 0 /* Force use the default author option */ #define QAUTHOR 0 /* Force use the default author option */
#define AUTHOR "fSD" /* Default author */ #define AUTHOR "fSD" /* Default author */
#define DEFAULT_GIT 0 /* Default git state */
/* Internal constants */
#define NPAT 128
#endif /* ESTRUCT_H_ */ #endif /* ESTRUCT_H_ */

5
file.c
View File

@@ -1,8 +1,7 @@
/* file.c /* file.c
* *
* The routines in this file handle the reading, writing * The routines in this file handle the reading, writing
* and lookup of disk files. All of details about the * and lookup of disk files.
* reading and writing of the disk are in "fileio.c".
* *
* written by vx-clutch * written by vx-clutch
*/ */
@@ -17,7 +16,7 @@
#include <unistd.h> #include <unistd.h>
#include "file.h" #include "file.h"
#include "edef.h" #include "estruct.h"
int ffwrite(char *path, char *fmt, ...) { int ffwrite(char *path, char *fmt, ...) {
FILE *f; FILE *f;

3
full.c
View File

@@ -10,6 +10,7 @@
#include "file.h" #include "file.h"
#include "full.h" #include "full.h"
#include "usage.h" #include "usage.h"
#include "git.h"
int full_project_init_and_cd(char *src) int full_project_init_and_cd(char *src)
{ {
@@ -72,5 +73,7 @@ more accurate attributions, if you desire.\n\
\n\ \n\
LATE MODIFIED DATE", src, src); LATE MODIFIED DATE", src, src);
ginit(); /* initialize a git repository */
return 0; return 0;
} }

17
git.c Normal file
View File

@@ -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;
}

6
git.h Normal file
View File

@@ -0,0 +1,6 @@
#ifndef GIT_H_
#define GIT_H_
int ginit();
#endif /* GIT_H_ */

6
globals.c Normal file
View File

@@ -0,0 +1,6 @@
#include "estruct.h"
#include "edef.h"
/* initialized global definitions */
int git = DEFAULT_GIT;

10
main.c
View File

@@ -17,6 +17,10 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include "edef.h" #include "edef.h"
#include "proj.h" #include "proj.h"
@@ -28,8 +32,8 @@ void usage(int status) {
printf("Usage: %s filename\n", PROGRAM_NAME); printf("Usage: %s filename\n", PROGRAM_NAME);
printf(" or: %s [options]\n\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\n", stdout);
fputs(" -S enable shell creation mode as a full project\n", fputs(" -S enable shell creation mode as a full project\n", stdout);
stdout); fputs(" --git initialize a git repository\n", stdout);
fputs(" --help display this help and exit\n", stdout); fputs(" --help display this help and exit\n", stdout);
fputs(" --version output version information 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; shell_mode = SINGLE;
else if (argv[carg][1] == 'S') else if (argv[carg][1] == 'S')
shell_mode = FULL; shell_mode = FULL;
else if (strcmp(argv[carg], "--git"))
git = 1;
else else
die("unknown option"); die("unknown option");
} else } else

View File

@@ -23,8 +23,9 @@ int makeshell(char *src, int complexity) {
if (complexity == SINGLE) if (complexity == SINGLE)
single_init(src); single_init(src);
else if (complexity == FULL) else if (complexity == FULL) {
full_project_init_and_cd(src); full_project_init_and_cd(src);
}
else else
die("invalid state! shell.c:%d", __LINE__); die("invalid state! shell.c:%d", __LINE__);