Compare commits
	
		
			1 Commits
		
	
	
		
			34965bb98d
			...
			5f2c5b58da
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5f2c5b58da | 
							
								
								
									
										14
									
								
								git-prompt.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								git-prompt.c
									
									
									
									
									
								
							@ -8,11 +8,18 @@
 | 
			
		||||
#include <sys/wait.h>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
#define check(CONDITION)                                                    \
 | 
			
		||||
  if (CONDITION) {                                                          \
 | 
			
		||||
    fprintf(stderr, "error: %s: %d: %s\n", __FILE__, __LINE__, #CONDITION); \
 | 
			
		||||
    exit(0);                                                                \
 | 
			
		||||
  }
 | 
			
		||||
#else
 | 
			
		||||
#define check(CONDITION) \
 | 
			
		||||
  if (CONDITION) {       \
 | 
			
		||||
    exit(0);             \
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef struct process {
 | 
			
		||||
  pid_t pid;
 | 
			
		||||
@ -78,13 +85,8 @@ char* inttostr(char* buffer, int value) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int main() {
 | 
			
		||||
  process_t process;
 | 
			
		||||
  // check we are in a git repo
 | 
			
		||||
  process = process_open("git rev-parse --git-dir");
 | 
			
		||||
  check(process_close(process));
 | 
			
		||||
 | 
			
		||||
  // get the current branch name
 | 
			
		||||
  process = process_open("git symbolic-ref --short HEAD");
 | 
			
		||||
  process_t process = process_open("git symbolic-ref --short HEAD");
 | 
			
		||||
  char branch_buf[256] = {};
 | 
			
		||||
  fread(branch_buf, 1, sizeof(branch_buf), process.out);
 | 
			
		||||
  if (process_close(process)) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user